Published by nick on 11 Feb 2009 at 02:18 pm
I only block for memcached
Want to know the magic secret to building scalable apps? Don’t have blocking calls. Think back to all the performance problems you’ve ever had. Chances are your app was waiting on one of the following:
- Database
- HTTP ( a remote web service)
- File system (either local or remote [NFS])
- Some other blocking service
Remove all these, and your app is fast! The one exception that has always treated me well is memcached. memcached in and of itself doesn’t block, and if you can write an app that only blocks on memcached, you’ve written a very well scaled app.
You may think I’m exaggerating. And maybe I am, to make a point. But I just did built an app that scales using memcached, and it powers all of Wikia’s ad traffic on two servers, handling approximately 500 transactions a second, and storing 7500 pieces of data per second.
Actually, one server can handle the load, I just use two for redundancy.
Scale with memcached, skip all the other blocking calls! Tip: Ajax isn’t blocking.
I liked this idea so much that I had T-shirts made that say "I only block for memcached". I’ve sold a couple to friends, and I will be giving one to Brad Fitzpatrick, the creator of memcached, as a Thank You from all of the users of memcached. Thanks Brad!

Clint Byrum on 12 Feb 2009 at 12:05 am #
One who is interested in stating things more elegantly might say:
I only block for milliseconds.
Unfortunately 999 milliseconds is a long ass time to block. Damn.
You get the point though. The reason blocking for memcached is ok, is that you know as long as you’re using it in a reasonable way that it will not ever block for more than a handful of milliseconds.
Most web storage activities need not be synchronous. However, our obsession with things like MySQL has made us learn to deal with the pain of overly complex, overly flexible, synchronous storage systems. Your example of recording 7200 things per second in memcached is a perfect example. Its async (I’m sure something comes along and puts those values in a safe place later), and even if you lost an hour of data, probably nobody would care.
Simplify your communications, queue/delay hard things, and.. be well John Spartan.
Marc’s Voice » Blog Archive » Compendium of coolio posts - blogging Feb ‘09 on 12 Feb 2009 at 1:17 pm #
[…] I only block for memcached […]