Spreading key/value pairs across multiple memcached servers

Chris Hartjes chartjes at gmail.com
Wed Dec 1 08:46:15 PST 2004

Pardon my ignorance of memcached as I post the following scenario:

1) I create an instance of a memecached client (PHP version)
2) I'm using memcached to cache MySQL result sets, using the query
itself as the key
3) I ask memcached "hey, retrieve this key from memcache for me"

Now, if I have two servers, what server will it talk to in order to
find out where the key is?  Will it always talk to the first server in
the list?  I understand that the various servers are aware of what
server a particular key is on.  I also understand it will only take
one request to find out where a key is.  But again, will that request
for the location of the key always go to one server?

On Wed, 1 Dec 2004 11:39:35 -0500, Christopher Schmidt
<crschmidt at wedu.com> wrote:
> On Dec 1, 2004, at 11:25 AM, Chris Hartjes wrote:
> > I had a chat about this with my boss, and his concern is not that we
> > distribute the keys evenly, his concern is distributing the request to
> > find out what server a key is sitting on.  I figure he doesn't want
> > the first memcached server getting constantly pounded with requests
> > for the location of a key, while the second server could be helping
> > out in that regards.
> The location of the key is determined in the client, by the hashing
> algorithm. Only one request for a key is ever made:
> ADD data1:abc -> hash -> server1
> ADD data2:bcd -> hash -> server2
> GET data2:
> data2->hash = server 2
> There is no overload on the servers checking where the key is: it's
> alwyas in exactly one place.
> --
> Christopher Schmidt
> crschmidt at wedu.com

Chris Hartjes

"I know monkeys, and monkeys are good people!"

More information about the memcached mailing list