Showing posts with label memcached. Show all posts
Showing posts with label memcached. Show all posts

Monday, August 27, 2007

anatomy of a memcached daemon

Before you start experimenting with memcached, here's a quick description of the command line options that will be used when starting it up. (note there is no configuration file for memcached).

It seems as if the most common command line options are used: -l -d -p -m -c

Here is what each of them do, per the memcached man pages:

-l
Listen on ; default to INDRR_ANY. This is an important
option to consider as there is no other way to secure the
installation. Binding to an internal or firewalled network
interface is suggested.

-d Run memcached as a daemon.

-m
Use MB memory max to use for object storage; the default
is 64 megabytes.

-c
Use max simultaneous connections; the default is 1024.

-p
Listen on TCP port , the default is port 11211.

Here is an example command line script to fire up memcached with some options:

$ memcached -d -m 128 -l 10.0.0.40 -p 11211
This will start memcached as a daemon, allocate 128 MB memory max for storage of the memcached hashed query, listen on ip address 10.0.0.40, and listen on TCP port 11211.

So that's all there is to starting the daemon with a variety of options. Note there are more options in the man pages, but the above options are enough to give it a whirl. If you ever need to stop your memcached daemons, issue the following command:
$ killall memcached
Here is a couple helpful posts of using memcached with Rails:

http://townx.org/rails_and_memcached

http://nubyonrails.com/articles/2006/08/17/memcached-basics-for-rails

http://avoir.uwc.ac.za/avoir/index.php?module=wiki&pagename=MemcachedInstallDebianEtch&action=wikilink

installing MemCacheD on Mac OS X with MacPorts

installing MemCacheD on Mac OS X with MacPorts couldn't be easier:

1. as long as you have MacPorts (frmly DarwinPorts) installed on your Mac, just open up a bash shell and type the following:

$ sudo port install memcached
Because memcached utilizes libevent, MacPorts will check to see if libevent-dev is found... if it is not, it will fetch libevent-1.3d.tar.gz from http://monkey.org/~provos/, verify checksum, install... then likewise fetch memcached, verify checksum, extract, configure, install. This currently at the time of this post installs memcached 1.2.2_1.

Thursday, August 23, 2007

memcached

Check out memcached, if you're into researching ways of making your web apps speedy through clever database caching. (used by LiveJournal, Slashdot, Wikipedia, SourceForge). Very very cool.

By having your app first check the memcache instead of going to the database directly, you reduce the overhead that is inherent with ACID properties in relational database management system transactions. --as I understand it from reading about it on a few sites, by hashing database records in a cache reading from that hash where possible and updating the hash when that data is not available, you end up greatly reducing the demand on the database.

Makes me excited to think about the possibilities of an upcoming RESTful Rails app deployed on an clustered Ubuntu instance on EC2, utilizing memcached, that is Gears-enabled for offline capability as well... whoops, I wandered off...

Here's some info on memcached. I'm going to definitely check it out and try to implement:

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

http://www.danga.com/memcached/

http://www.deveiate.org/projects/RMemCache/


http://nubyonrails.com/articles/2006/08/17/memcached-basics-for-rails