memcached - first impressions and issues

Andy Bakun
18 Dec 2003 18:16:26 -0600

memcached is a very intresting piece of software.  The code is very
clean and easy to follow too -- gotta love that (although I have not
delved deeply into it yet).

Initial results on the websites I'm considering using it on are
extremely promising.  In my situation, we're using a single MySQL
instance to store cached page content for a pool of webservers running
mod_php.  All the pages are broken down into distinct atoms, which can
be nested together to build an entire page, over 95% of the atoms appear
on multiple pages, and there is a lot of per-user customization (with
more planned in the future).  The major influence on page build time (to
initially populate the cache) is, with MySQL, the time it takes to get a
negative result back from the database telling us that something isn't
cached.  Using only a single instance of memcached on the same machine
as the webserver, atom and page build time is between 1/5 and 1/12
(depending on the number of atoms per page and how deeply they are
nested).  After things are cached, the difference between memcached and
my homebrew MySQL caching scheme (in my development environment, the
webserver, MySQL and memcached are all on the same machine) is small
enough to be statistical noise.  Right now, my goal is to reduce load on
our database server by getting caching off of MySQL.

The PHP API, linked from the memcached web page, works great, although
the lack of more complete sample code caused a few misstarts on my
part.  It appears to have a problem with not returning right away if it
can't connect, so it's difficult to gracefully recover, but I need to
look into this more (perhaps I'm missing an option?).

One problem I've noticed is that the protocol docs mention a flush_all
command, which doesn't seem to exist in the 1.1.9 distribution.

Also, are there any plans for additional reporting features?  One thing
I'm in need of is a way to list all the keys that are currently cached,
and their expiration time.  Along with this, I'd like to be able to
delete keys that match a certain pattern (although I can certainly do
this myself if I can get a list of all keys).  I realize this may be a
problem if there are multiple memcached servers, but aggragation of key
lists could happen in the client portion.  Also, I have not yet looked
into the data structures used by memcached to know if this is even

I have RPM .spec files if anyone is interested (although the
installations for libevent and memcached are relatively simple, so I'm
not bragging here, heh).  A quick search didn't turn up any others
(other than an older libevent for Mandrake).

Andy Bakun: more than a mere hindrance, it's a whole new barrier