PECL memcache extension
Don MacAskill
don at smugmug.com
Fri Feb 3 22:37:36 UTC 2006
So I was excited to see the PECL memcache extension had gotten multiple
server support. But after installing it and playing with it, it doesn't
seem to work the way I'd hoped (and the way I currently use memcache).
Maybe I'm just being dumb, and if so, I'd love to hear how I can get
smart. Until my dumb-ness has been established, though, let me describe
how it looks like the PECL extension is working:
- using 'addServer', you can add multiple servers and assign each a
different bucket weight (Example: 3 servers, each with 1 bucket = 3
total buckets). Good.
- When a server fails, that server's buckets are removed from the pool
and all future get/set/etc commands are reallocated to the remaining
pool. (Example: ServerB fails, so the "set key1" that was going to
ServerB instead now goes to ServerA)
And now, how my memcached setup works:
- When a server fails, I mark those buckets as "offline" and no longer
permit get/set to that portion of the memcache cluster. All of that
data must be served from it's original source (filesystem, MySQL,
whatever) until that server comes back up, in which case it's flushed
and marked as "active". Yes, I know it's slower during a failure, but
since we have lots of memcache servers, it's only a % of the entire
cluster slower. And failures are rare to boot.
- Note that the "bucket weight" calculation still takes the "offline"
buckets into account, so keys are destined for dead servers rather than
re-allocated.
And now why:
If "set key1" is destined to ServerB's buckets, but ServerB fails, I
don't want "key1" being redirected to ServerA instead. Why? Because
when ServerB comes online, I now have "key1" in two places, and one of
them will now potentially get out of date. Should ServerB fail again
before "key1" has expired, calls to "get key1" will return old stale
data from ServerA instead of fresh data or no result.
Make sense? Am I doing something wrong? Can the PECL extension work in
this fashion?
Don
More information about the memcached
mailing list