If you read my previous post about our scaling issues, you’ll know that I was planning on trying out a number of other ideas to see if we could improve the performance of our system. Well, one of the things I tried was to test out Memcached. I set up a six node VPS (2.4 ghz, 1.5gb ram, 1500gb bandwidth) and installed Memcached on it. Setting it up was pretty spectacularly simple, “apt-get install memcached”, followed by changing two variables in its config file.
I modified our applications to start checking Memcached first, using the PECL ‘Memcache’ extension, and if no results were found, access the database, get the data and put it into Memcached. Below are a couple of graphs of the first hour of our rollout:


As you can see, the number of requests started out pretty low, as the number of application instances ramped up… This caused a massive spike in misses whilst the cache warmed up. However, as soon as the number of requests started to rise, the balance shifted, and since the rollout, the ratio has remained a fairly stable 60/40 split in favour of hits.
As you may also be able to tell from the graphs, this means that of the 2.5 million hits an hour, we’re managing to catch 1.5 million before they ever make it to the database. This is a huge saving for us, and we’re now looking at where else we can roll this out with similar effect.
On the note of our scaling issues, I’ll be writing up some more of what we’ve done with the databases later. We’re at a point now where the improvements are actually starting to make a difference!





