Monday, March 24, 2008

Memcached, making an app with a DB backend really fast

Reading about twitter's queueing engine got me interested in memcached, which looks awesome. It is used by some of the biggest players on the Internet: livejournal, sourceforge, slashdot, wikipedia, etc. The idea is whenever you do a select on a DB, you first look in the memcache. Similarly, when you delete/update in the DB you also remove/change the values in the cache, which means the data in the cache never actually expires.

This could provide vast speedups for pretty much any app that interacts heavily with databases. I have two projects I work on in mind....

There is a great idea called mint cache that even handles the 'dog-pile' effect that occurs when the data in the cache is stale, and many requests are received while the new values are being generated. Cool. The memcached FAQ includes this design example and lots of other good ideas.

No comments: