Major new memcached goodie checked into svn
Steven Grimm
sgrimm at facebook.com
Thu Nov 23 08:01:48 UTC 2006
The "multithreaded" branch in svn now has, as the name implies, a
version of memcached that can be compiled as a multithreaded server. We
are running memcached on 4-core servers; whereas before we had to split
memcached up into separate smaller processes when we bottlenecked on
CPU, now we can run one large process and take advantage of increased
multi-key "get" batching, etc.
I made the change such that you can continue to compile memcached as a
single-threaded server if you are not bottlenecking on CPU time; in
fact, single-threaded mode is the default, since it is sufficient for
almost all memcached installations and runs with less overhead (no need
to synchronize between threads.) That was a major design goal since it
will, if people are satisfied with the changes, allow this version to be
folded back into the memcached trunk at some point without breaking
platforms that don't have thread support.
An overview of the change is in doc/threads.txt. Briefly, the change
involves assigning each incoming connection to one of a small fixed
number of worker threads; each worker thread acts like a miniature
memcached instance, using libevent to divide its time among all the
clients it's in charge of. The UDP socket is shared among all the worker
threads.
For now this is perhaps best considered an experimental change, though
we are running it successfully on a number of our production servers.
If other people could give it a whirl in either multi- or
single-threaded mode, that'd be great. I did most of the development on
Mac OS X, and the production servers are running Linux on AMD64, but it
is essentially untested on platforms other than those. In theory it
should work fine on any platform that supports both pthreads and
libevent, but it'd be nice to have some real-life success reports!
-Steve
More information about the memcached
mailing list