Varnish HTTP Accelerator

by marcus on 22/02/2008



A few days ago, I was searching for a reverse proxy that is capable of caching dynamic content for a specified period of time. Apache2 + mod_proxy / disk_cache seemed to be the perfect solution, but in fact it did not work properly in the scenario I set up (LAMP / Typo3). After googling around, I did *not* try squid, as I found the Varnish HTTP accelerator.To sum it up: that thing works.

I experimented a bit for a pretty large Typo3 site that we are hosting. Not that the site is slow (we run it on a neat “Sun Fire”) – I just wondered if it is really necessary to pass every request to Typo. The content on the site is changed frequently, but a caching time of 3 minutes or so would not hurt anyone…

Enough talking, let’s see the facts. I measured with apachebench on one of our development machines:

———
Without varnish – direct requests to Typo3. Typo3 caching enabled.

[root@uradium:~]# ab -g result.txt -n 500 -c 3 http://xxxxxxxxxxxxxxxxx.de
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking xxxxxxxxxxxx.de (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests

Server Software: Apache
Server Hostname: xxxxxxxxxxxx.de
Server Port: 80

Document Path: /some/path/
Document Length: 35584 bytes

Concurrency Level: 3
Time taken for tests: 77.802856 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 17898500 bytes
HTML transferred: 17792000 bytes
Requests per second: 6.43 [#/sec] (mean)
Time per request: 466.817 [ms] (mean)
Time per request: 155.606 [ms] (mean, across all concurrent requests)
Transfer rate: 224.66 [Kbytes/sec] received

———————————
Same machine, same website, same connection, different approach:
Apache on ext:80 with mod_proxy => Varnish on localhost => Apache on localhost:8080

[root@uradium:~]# ab -g result.txt -n 500 -c 3 http://varnish.xxxxxxxxxxxxxx.de/
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking varnish.xxxxxxx.de (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests

Server Software: Apache
Server Hostname: xxxxxx.de
Server Port: 80

Document Path: /some/path/
Document Length: 32700 bytes

Concurrency Level: 3
Time taken for tests: 1.672068 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 16529554 bytes
HTML transferred: 16378753 bytes
Requests per second: 299.03 [#/sec] (mean)
Time per request: 10.032 [ms] (mean)
Time per request: 3.344 [ms] (mean, across all concurrent requests)
Transfer rate: 9653.91 [Kbytes/sec] received

—————————

Even this rough-and-ready setup gave me 46 times more requests per second, and even the uncacheable sections of the site do in fact work, because Typo does a good job when it comes to cache headers.

Does not seem to be too hard to adopt this to CF projects!

Comments on this entry are closed.

Previous post:

Next post: