Why not let the fs handle this ??
sgrimm at facebook.com
Tue Jun 6 15:52:52 UTC 2006
Constantin B wrote:
> How do you manage this in big setups ?
> do you have a dozen of memcaches around ???
Yes. One common setup is to run a memcached instance on every machine
rather than dedicating machines specifically to it. Have a memcached on
each web server. Since each item is only cached on one server, you can
get by with a relatively small cache on each machine. And then your
database load only goes up a little if you lose or reboot one of the
> the fs has another greate advantage , it cache only used files in fs
> buffer , so this mean that the ram usage is very small compared to
> memcache filled with all data .
memcached is an LRU cache, same as the filesystem's disk buffers. If you
size the cache appropriately you will get nearly the same caching
behavior either way, except that running a backup or a "find /" won't
destroy your cache performance if you're using memcached. You don't have
to size memcached to hold every possible value in your database if you
only get significant performance gains from caching very recently
accessed data. (Though in general the bigger the better, of course,
within the limits of your available memory -- and you want to have some
spare capacity to handle one of the cache servers dying.)
> Ps2 : i think it can be cool to make memcache , cache on disk the
> unused keys this and this will make it persistent on reboot too.
Think of the database as your on-disk cache of unused keys. If you're
aggressive enough with your caching that's pretty much the situation
If you go the route of persisting your cached data onto local disk, make
sure you think about the failure modes around cache coherence. What
happens if your server goes down then reboots and reads locally-cached
data from its disk? All good -- unless the underlying data changed while
the server was down, in which case you have a cache server handing out
stale data to clients without knowing it. Not a good situation unless
you're only caching static data.
More information about the memcached