Thursday, May 16, 2013

YOU’VE BEEN……memcached!

Listen to this song. This is a great song.


That was in no way relevant to this post.

Further in pursuit of making SolomonSays faster, I have been looking into caching solutions for a while now. After going through a ton of blog posts, I decided to go with using memcached as a caching back-end. I started this yesterday, and owing to extreme ease of installation and use (and my own, personal awesomeness), SolomonSays today runs on memchached.
The expected benefits are:
  1. Fewer queries being run means snappier performance. This will matter more and more as the site gains visitors because Django doesn’t support database connection pooling out of the box.
  2. A direct consequence of #1 is that the load on our MYSQL data server reduces. This is pertinent because the site runs on EC2 micro instance (free tier) and computational resources are minimal.
On the LINUX production system, the process was simple as:
  1. yum install memcached
  2. memcached –d –m  128 (to run memcached as a daemon with 128MB of memory)
  3. Configure memcached as the caching backend for Django as described here.
After that it was just a matter of analyzing what needed to be cached in the application and  using the cache for this. Currently I cache popular review (for right panel of most screens), the data for building the top menu, and reviews by their ids.

The tricky bit was setting memcached up for my development environment which is Windows. As Zurmo.org mentions:
Memcache was designed with Linux in mind and not windows, so it has posed some installation issues because Windows users are not so familiar with having to compile code from source as memcache does not come with any installation software.
However, it all worked out in the end with the help of the link above and this.

Hopefully you are now experiencing a website which is faster than it was before.
Thoughts?  Still think it’s too slow? Feel free to drop me a line.

No comments:

Post a Comment