DISQUS

Jangro.com: Website Performance Tools: How I Installed Memcached

  • Scott · 2 years ago
    Jury's out on that ddn. I was just so happy to get it running that I wanted to write about it before I forgot all the details.

    Tried it out in a few spots and got some 2x improvements -- but we're talking about milisecond execution times on DB hits, so there isn't much room for improvement on those.

    I'll follow up when I've got some meatier results.
  • ddn · 2 years ago
    You'll definitely see the difference as traffic ramps up. It may not be so much a speed thing as scalability. You should be able to drop the number of queries to the DB by several orders of magnitude.

    Have fun.
  • mark from 45n5.com · 2 years ago
    what type of setup do you have for hosting your sites? I've never ventured outside of shared hosting, and never needed to.
  • Scott · 2 years ago
    Hey Mark, we've got a number of dedicated servers. Nice for when you've got to do stuff like this.
  • Gene Kavner · 2 years ago
    Scott -- I was hit with the exact problem you described last week. The brand new Blog Window widget that I created became so popular that my server was getting hit at an average of 2-3 times per second. I didn't expect the load to go up so fast. Unfortunately, this overwhelmed the hosting site I was using. I'm using ASP.NET so your trick doesn't help me, however, I rearchitected by implementing the cache in the ASP.NET code. Also, upgraded to a dedicated dual-proc, 4GB system, so the CPU meter now barely budges even under heavy load.
  • Scott · 2 years ago
    thanks fernando.

    Yeah, that's next on the list. getting lighttpd set up for serving the static assets like images.
  • fernando · 2 years ago
    You'd be surprise how well lighttpd with PHP does... and you can load balance php across servers, and now that you have memcached you can store sessions on memcached and things will fly... I can't say enough good things about lighttpd.

    Here is a great post on their blog:
    http://blog.lighttpd.net/articles/2006/12/28/li...
  • Nicholas Thompson · 2 years ago
    Regarding this error:

    memcached: error while loading shared libraries: libevent-1.3a.so.1: cannot open shared object file: No such file or directory

    I tried making the symlink as you suggested (except for me, it was in lib64) and it worked, but it left a little bit of a "hack-like" taste in my mouth.

    I noticed the first line is ld.so.cache. With a little research, I found an alternative and less hack-tasting (imho) method: in /etc/ld.so.conf.d/ make a file called libevent.conf and write in this file the path to the libevent libraries (eg /usr/local/lib). Finally, run ldconfig (as root) and the cache get regenerated.

    The advantage of this method is that as the cache gets checked before the system path, it means the system does less "looking" for the file. In any case - both methods work.

    Thanks for this blog!
  • Scott · 2 years ago
    It was a total hack, Nick, yeah.

    thanks for adding this. great info.

    --scott
  • Nicholas Thompson · 2 years ago
    No probs - glad to help. I've already implemented this in my ThingyMaJig site. It brought page generation times from 400ms to just over 100ms. Thats MASSIVE!

    I'm currently (litterally - i'm doing it NOW) working with a friend to create an official module for Drupal. He's made a very good start (the base for TMJ) and I'm extending it.
  • matthieu · 2 years ago
    Thank you for this article ; I couldn't find the library not found error for the libevent. I'm sure this article is useful to dozens of people :-)
  • Sudhir · 2 years ago
    Hey Scott,

    Great work with the article, you saved me a ton of time in getting the memcacheed working with PHP!.
    I owe you a beer :) Keep up your good work.
  • Sean · 2 years ago
    We memcached some internal API stuff about a month ago at b5media.com, and it drastically improved things. DB load was slashed by 2/3. I'm looking forward to caching more stuff!

    I'd suggest building packages out of libevent, memcached, and the PECL module to make it easier to manage your servers. My blog has some links on the latter, libevent ships with a .spec file, and memcached is only a couple of files.

    Sean
  • MorganLighter · 2 years ago
    Scott - What a lifesaver you are. Our site had some issues as described above last year and what a debacle. With memcache and your instructions for installation, we won't run into this problem again. One respondent said he'd buy you a beer - heck, I'll buy you dinner! Thanks.