Some time ago I discovered a web server called Cherokee. The web server itself is promoted as “The Fastest free Web Server out there!”. So for a while I was just curious to do a benchmarks and compare it with Apache web server and see which one is faster in standard LAMP environment.
Why Apache vs. Cherokee? Because Apache is most common in LAMP environments and most widely used web server around the globe.
The main difference of Cherokee when compared with other web server software is that it is configured using web interface. The configuration file itself has a comment “don’t edit me by hand!” or something like that. Actually I was amazed with web interface, because it was very simple and easy to understand, user friendly and everything just worked
BTW, for benchmarking I used FreeBSD box, because that’s the only one which I’ve got under my table at home.
I’ve chosen to test newest WordPress version by date (3.1.3) just running ab against index page. Both web applications were clean installs.
I’ve tested these configurations:
- Apache + mod_php
- Cherokee + php-cgi (using FastCGI)
- Apache + mod_php + eAccelerator extension
- Cherokee + php-cgi (using FastCGI) + eAccelerator extension
ab was doing 1000 requests with different concurrency levels (1, 5, 10, 20, 50 and 100).
Web server software versions (compiled from ports):
- Cherokee 1.2.2
- Apache 2.2.19
Web application:
- WordPress 3.1.3
Test system / environment:
# Aspersa System Summary Report ##############################
Date | 2011-06-21 20:49:12 UTC (local TZ: EEST +0300)
Hostname | mercury.insplash.com
Uptime | 43 days, 16:37, 2 users, load averages: 1.70, 14.19, 14.68
Platform | FreeBSD
Release | 7.4-RELEASE-p1
Kernel | 199506
Architecture | CPU = 64-bit, OS = 64-bit
Virtualized | No virtualization detected
# Processor ##################################################
Processors | virtual = 4
Speeds | 2331
Models | Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz
# Memory #####################################################
Total | 4.0G
Virtual | 4.8G
Used | 1.9G
UsedRSS | 22.4M
php info (without eAccelerator):
PHP 5.2.17 with Suhosin-Patch 0.9.7 (cli) (built: Jun 15 2011 14:03:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies
php-cgi info (without eAccelerator):
PHP 5.2.17 with Suhosin-Patch 0.9.7 (cgi-fcgi) (built: Jun 15 2011 14:03:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies
The Setup
Cherokee’s and Apache’s configurations are practically default with no performance tuning or any additional modules.
PHP was tested with almost standard module set which is used by common PHP setups. Maybe you could just notice that it is with Suhosin Patch, but this one shouldn’t affect performance significantly. Zend optimizer is also pretty standard in LAMP setups. It is used just for loading encoded files.
eAccelerator configuration:
- eaccelerator.shm_size = “128″
- eaccelerator.enable = “1″
- eaccelerator.optimizer = “1″
- eaccelerator.shm_only = “1″
- eaccelerator.compress = “1″
- eaccelerator.compress_level = “9″
- eaccelerator.keys = “shm_only”
- eaccelerator.sessions = “shm_only”
- eaccelerator.content = “shm_only”
The Results
The first table shows how many requests per second each setup could handle by increasing concurrency level.
| Requests per second | ||||
| Concurrency | Apache + mod_php | Cherokee + php-cgi | Apache + mod_php + eA | Cherokee + php-cgi + eA |
| 1 | 4.64 | 4.99 | 14.59 | 19.33 |
| 5 | 16.14 | 16.97 | 24.22 | 62.97 |
| 10 | 15.95 | 17.33 | 15.00 | 62.69 |
| 20 | 15.85 | 17.22 | 9.89 | 61.93 |
| 50 | 15.47 | 17.17 | 2.81 | 62.04 |
| 100 | 15.21* | 17.33 | 2.96** | 62.72 |
This table indicates the longest request time for each benchmark. From this table you can see that Cherokee is handling concurrent requests a lot better than Apache.
| Longest request (100%) | ||||
| Concurrency | Apache + mod_php | Cherokee + php-cgi | Apache + mod_php + eA | Cherokee + php-cgi + eA |
| 1 | 327 | 230 | 760 | 75 |
| 5 | 751 | 869 | 3671 | 146 |
| 10 | 4014 | 786 | 7081 | 235 |
| 20 | 11992 | 1452 | 13040 | 457 |
| 50 | 22081 | 3147 | 96152 | 921 |
| 100 | 29690* | 6065 | 143878** | 4560 |
And the last one shows average request time for each benchmark.
| Time per request (mean, across all concurrent requests) | ||||
| Concurrency | Apache + mod_php | Cherokee + php-cgi | Apache + mod_php + eA | Cherokee + php-cgi + eA |
| 1 | 215.674 | 200.209 | 68.549 | 51.736 |
| 5 | 61.962 | 58.910 | 41.285 | 15.879 |
| 10 | 62.677 | 57.694 | 66.679 | 15.951 |
| 20 | 63.090 | 58.071 | 101.140 | 16.147 |
| 50 | 64.651 | 58.225 | 356.294 | 16.118 |
| 100 | 65.747* | 57.715 | 338.261** | 15.945 |
* – Apache failed to serve 17 requests out of 1000
** – Apache failed to serve 793 requests out of 1000
So those results are not quite correct and influenced by failures.
Conclusions
When running benchmarks without eAccelerator you could see that Cherokee is a little bit faster. As concurrency grows Apache suffers some kind of concurrency / threading problems, because performance is degrading while Cherokee holds almost steady results.
A was very surprised when I saw that eAccelerator gives negative effect on Apache when concurrency level increases. While monitoring the process tree I saw some kind of flock() issues. I’ll try to investigate this deeper in the future.
eAccelerator and WordPress is a very good combination, because eA gives about 4x performance gain.
And yes! I know, I should benchmark some other web applications to get more objective results. I’ll do it in near future.