Memcached – one big server vs several smaller ones

memcached

I am considering whether we should get one big (48 Gb RAM) server or buy 4 smaller (12Gb RAM) servers for running memcached service. In either case I would also have stand-by spares for redundancy, and I will be able to add more servers if needed later, so this question is purely about performance, not fault tolerance or scalability.

I am leaning towards having one big server just because its easier to manage, "greener" and takes less space, but I don't know if it can perform on par with a set of smaller servers.

Any ideas would be greatly appreciated!

Best Answer

Andrey,

To answer your question I would refer you to the snippet below. Performance wise memcache client library would still be doing two internal lookups regardless of whether you have 1 or more instance.

But having only one instance might hurt because it would take sometime for the backup to warmup when it comes online.

http://www.linuxjournal.com/article/7451?page=0,1 A request to get/set a key with a value requires that the key be run through a hash function. A hash function is a one-way function mapping a key (be it numeric or string) to some number that is going to be the bucket number. Once the bucket number has been calculated, the list of nodes for that bucket is searched, looking for the node with the given key. If it's not found, a new one can be added to the list.

So how does this relate to Memcached? Memcached presents to the user a dictionary interface (key -> value), but it's implemented internally as a two-layer hash. The first layer is implemented in the client library; it decides which Memcached server to send the request to by hashing the key onto a list of virtual buckets, each one representing a Memcached server. Once there, the selected Memcached server uses a typical hash table.