Caching Strategies for Load Reduction on High Traffic Web Applications

Diploma Thesis by Alexander Kirk.

This is the HTML version (download) of the thesis. As it has been optimized for printing, see the PDF version for best results.

Abstract

In this thesis we discuss the problem of web applications that have to work under heavy load of a high number of visitors. We evaluate the application Bandnews.org as an example and tune it using various caching strategies. They include caching by a proxy server, a compiler cache, database caching using a query cache and application based caching using Smarty.

This work shows that gain in speed is possible if methods are applied carefully. We compare and combine caching strategies to come to a stage where every page is generated in reasonable time even under high load.

Kurzfassung

In dieser Diplomarbeit wird das Problem von Web Applikationen behandelt, die unter hoher Last und einer großen Zahl von Benutzern arbeiten müssen. Die Applikation Bandnews.org wird als Beispiel untersucht und mittels verschiedener Caching Strategien beschleunigt. Dies beinhält das Cachen mittels einem Proxy Server, einem Compiler Cache, Datenbank Caching mittels Query Cache und applikationsbasiertes Caching mittels Smarty.

Diese Arbeit zeigt, dass Geschwindigkeitssteigerungen möglich sind, wenn die Methoden umsichtig eingesetzt werden. Die Caching Strategien werden miteinander verglichen und kombiniert, um eine Stufe zu erreichen in der jede Seite in vertretbarer Zeit geladen wird, sogar unter hoher Last.

Contents
1 Introduction
 1.1 Motivation
 1.2 Method
 1.3 Expected Results
 1.4 Outline of the Thesis
2 Terms
 2.1 Caching
 2.2 Load
I  Environment
3 Application
 3.1 Bandnews.org
4 Tools
 4.1 Apache
 4.2 PHP
 4.3 MySQL
 4.4 Smarty
 4.5 Squid
 4.6 Advanced PHP Cache
 4.7 Advanced PHP Debugger
 4.8 ApacheBench ab
II  Tuning the Application
5 Evaluation
 5.1 Goal definition
 5.2 Processing a Request
 5.3 Possible Hooking Points
 5.4 Bandnews.org
 5.5 Testing
6 Squid
 6.1 Considerations
 6.2 Preparation
 6.3 Results
 6.4 Conclusions for Squid
7 APC
 7.1 Considerations
 7.2 Preparation
 7.3 Results
 7.4 Conclusions for APC
8 MySQL
 8.1 Considerations
 8.2 Preparation
 8.3 Results
 8.4 Conclusions for MySQL
9 Smarty Caching
 9.1 Considerations
 9.2 Preparation
 9.3 Results
 9.4 Conclusions for Smarty Caching
10 Conclusions
 10.1 Further Work
A File Sources
 A.1 Benchmark Script
 A.2 Patch Files
References
References