msgbartop
msgbarbottom

31 Jan 07 If You’re Not Using memcached You’re Doing It Wrong

If you’re building web sites or applications, and you’re not using memcached yet, you should be. Hogan showed me memcache a while back, and I literally implemented it the same day. Even if your site isn’t high traffic it hopefully will be in the future. When that time comes you’re going to wish you had made some better architecture choices. Don’t make not having used memcached one of them. memcached has allowed me to do things that would be completely impractical without it. Just recently I re-implemented a caching system using memcache, and I the system can handle several orders of magnitude more traffic. Not only that, but the code was actually cleaner and simpler. memcached’s automatic expiration of unused cache objects is superb for caching dynamic content.

So, like SEO Blackhat said: if you’re not using memcached yet, don’t wait until you need it or get around to it. Do it fucking now.

If you like what’s here, please follow me on twitter here.

Reader's Comments

  1. |

    quick question for you – this solutions is pretty sweet (just based on your site’s performance) and looks easy to implement. Is this a fix that can only be used when you are hosting your own boxes?
    thanks!

  2. |

    It’s hard to accept PHP as a viable solution in such cases when you know that Zend pro-actively avoids incorporating such features into PHP in an effort to gain commercial customers.

    Either the PHP developer is forced to use a free third party solution such as this, or PHPA, or accept that PHP is nor longer suitable for the task and opt for another sustainable language which understands server resources and does not need to be run under a persistent parser in order to perform reasonably well.

    Hint #1: Perl.
    Hint #2: Perl is not CGI :)
    Hint #3: http://tnx.nl/php has some interesting facts.

  3. |

    [...] Distrubuted Caching with Memcached Use Server-Side Caching When Possible (memcached) If You’re Not Using memcached You’re Doing It Wrong [...]

  4. |

    I saw the title of this post and kicked myself in the ass. I’ve always wanted to use memcached, but I have been stuck developing for other people that are usually on shared hosting accounts, so using something like this is out of the question. But now that I am finally working on my own site, I can. Glad I found your blog and read this so I dont have to add it later.

    As for language debate, if there was one language that was perfect for everything, there wouldn’t be a need for anything else, just my 2 cents.

  5. |

    We used to wait until a site became successful before implementing memcached. Now we just roll it out from day one. It’s so easy to implement and as long as you have a clean database access layer, shouldn’t take more than a few minutes to setup.

    If you’re using PHP, I would also recommend throwing in a PHP compiler like eaccelerator or ach. Those help by eliminating the need to recompile the PHP instructions on each page load.

    As for memcached, if anyone is looking for a step-by-step tutorial (their website is a bit lacking in that department), here’s Chris outlining how to get memcached up and running on a FreeBSD machine with PHP 4.x:
    How to install Memcached

  6. |

    Yeah pretty much. Unless you could convince your host to install it. The downside is that there is absolutely no authentication with memcached, so you really wouldn’t want to use it on a shared box.

  7. |

    Zeeshan,

    You might notice that nowhere in my article do I mention PHP…

    So here you are on a high horse about how awful PHP is. Unfortunately, you neither understand what “this” (being memcached) is, nor do you have any clue as to what you’re talking about. Perl is not the solution for high performance web applications, it never will be. The old PHP FUD is tired, most of it isn’t even true anymore. Neither PHP nor Perl are perfect languages. Grow up.