Challenge: Finding a cost effective solution to issues with traffic spikes

Reducing the impact of traffic spikes through page request caching.

Design & Development No comments
Share on Google+ Share on LinkedIn

The team at Stickyeyes recently designed and developed a major footballing website that amongst its other functionality displays live scores from football leagues and competitions around the world. Due to the incredible success of the site, it has seen a massive increase in traffic, particularly during peak game activity during the weekend. An investigation was thus launched in how to reduce the impact of traffic spikes during these peak times, a common network traffic problem, which many developers face regularly. Mobile Site Mobile Site

Hardware Solution

Our first approach was to increase the hardware resource available. Although this is the easiest solution to implement, with no changes required to the software, we needed to increase the server resources by around 300%. Although this did resolve the issues, it would cost considerably more; hence a more cost-effective solution needed to be found.

Software Solution

Our next step was to look into a software solution, but first we had to evaluate the actual performance of the system to determine where meaningful improvements might lie. It soon became apparent that the database was an area that required closer investigation. The obvious first solution to database performance is caching the database requests. However after further consideration, an even more powerful solution was thought worthy of detailed review – page request caching.

Page Request Caching

Page request caching can improve the response time of dynamically created web pages that are frequently requested but consume a comparatively large amount of time to construct. Page request caching can be done in a number of ways, and after investigation, we chose to consider a Memcache server.


Memcache is a tried-and-tested cache implementation, which works by using RAM to cache data. RAM is better suited to this type of caching than a hard disk because it is much faster to read and write from. In this case, it does not matter that RAM is transient (e.g. rebooting the server empties the cache).

There are numerous Memcache implementations to choose from, but we chose Couchbase as it is easy to install and provides a useful web-based administration panel for cache analysis. Once installed and running it is easy to access and utilise from the website codebase.

The solution was implemented so that the entire HTML output of each URL is saved to the cache for a set amount of time. If that URL is accessed whilst the cached version is available then we simply output the cached HTML.

Benchmarking and Improvements

To prove the robustness of the solution it had of course to be benchmarked across several variables, comparing the old setup to the new setup.

Page load times were tested by requesting pages at varying rates from two separate web servers; one with the caching solution implemented (server A) and one without (server B). We found that server A was consistently quicker to serve the page than server B. For instance, at 50 requests per minute, each page was three times quicker to load; at 200 requests per minute it was 11 times quicker!

Client-side improvements are not the only benefit from utilising a Memcache system. On the server-side the CPU load reduced by 60% and the amount of database queries reduced by 90%. This is because of the reduction in PHP scripts called when the server only needs to get the cached HTML. By fetching the cached HTML rather than calling the PHP scripts the database access is negated too.


This reduction in load allowed us to reduce the amount of web servers in the pool back to its original amount and significantly reduce the amount of CPU and memory required by the database servers. This means we are now in a position to handle much more traffic than before on less hardware.

In conclusion, we found that it is worthwhile investigating the addition of a Memcache layer to your website if it’s struggling with high volumes of traffic – both for client-side and server-side improvements.

Add your comment

Your email address will not be published. Required fields are marked *

× Megaphone

Fancy more of this?