Is memcached really faster than MySQL on very simple query?
sgrimm at facebook.com
Fri Jul 14 03:29:57 UTC 2006
Paul T wrote:
> From what I saw on this list, Facebook had to patch
> memcached to switch to UDP to handle 20K hps (but I
> dunno what are their 'values'. I assume they are
> marshalling the 'typical' memcached payload 10-50K(?)
> My 20-40K are for tiny payload < 512 bytes. ( It is
> also funny to talk in this kind of numbers ignoring
> the hardware and the OS version, but still ... better
> than having no numbers at all, I guess. )
Just to set the record straight, our UDP work was not about hit rate. It
was about reducing the total number of connections to memcached. Our
memcached can handle about the same number of hits per second over UDP
as it can over TCP.
Also, we don't use UDP exclusively. Our client switches to temporary TCP
connections for cache writes (where you want reliability) and for gets
of large numbers of keys (where the expected return value would span
many UDP packets and would thus be especially sensitive to packet loss.)
But as a practical matter we mostly use UDP -- our traffic is very
get-heavy and the vast majority of our gets are small enough to not
trigger a switch to TCP.
> I think that Facebook did 'the righ thing' going UDP ,
> but there are some other reasons to stay with TCP ...
We've been generally happy with it, but with the caveat that it makes us
extremely sensitive to network flakiness -- if one of our switches
starts acting up we find out about it fast in the form of increased
database load. But our operations people keep a close eye on our
network's health and we typically see no more than 3 or 4 dropped UDP
memcached packets per day out of many billions of requests. I would not
recommend it for people who don't have extremely high confidence in the
quality of their internal networks.
More information about the memcached