memcached

Caching data in an in-memory cache is an approach used to speed up data access. memcached is one such key/value based distributed object caching system that works this magic for you.

I was about to write a blog about memcached and found this wonderful “story” – http://code.google.com/p/memcached/wiki/TutorialCachingStory . I love the way its been written. Enjoy the read

If you are wondering how to install memcached on Mac OS X, check out https://wincent.com/wiki/Installing_memcached_1.4.4_on_Mac_OS_X_10.6.2_Snow_Leopard . Its amazing how at the end you feel you need to be awarded a phd! I guess that shows I am not a UNIX/Linux geek

I did though install it with no sweat on my Ubuntu 10.10 Virtual Machine with one simple command –

>> sudo apt-get install memcached

Memcached server runs as instances on 1+ machines. Memcached clients know where all the memcached servers are but the servers have no idea about other servers.  Client libraries use a common hashing algorithm to locate a single memcached server, after which they proceed with the read/write operation. The important point to remember here is that the data itself is not replicated to each of the memcached servers. So if a server goes down the data on that server is lost. Another server unfortunately cannot pick up the slack since the hashing algorithm forces the client to the dead node. The memcached FAQ states that you could add a new server with a different ip address or reuse the same ip address. The former can invalidate your cache. If your client library uses a hashing algorithm that does not depend on IP addresses then you should be fine.

Memcached client API’s are available in various languages including Java, C, C#, Ruby,etc. memcached is self recovering – in that a server coming down does not affect the other servers. When the “sick” server comes back up it simply joins the club of “live” servers.