Benchmarking php with apc, memcached

As we are very extensively using techniques to speed up web applications we build or host, I’d like to share some benchmarks. One of our clients is running site on our machines which is using SOAP/WSDL to get data. The application is extremely slow, result are very poor. Apache is able to server this webapp within cca 23 pages per second, which is bad. Here are the ab results:

[root@webmel4 ~]# ab -n 400 -c 5 http://beta.somedomain.cz/
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 beta.somedomain.cz (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 400 requests

Server Software:        Apache
Server Hostname:        beta.somedomain.cz
Server Port:            80

Document Path:          /
Document Length:        45829 bytes

Concurrency Level:      5
Time taken for tests:   17.637183 seconds
Complete requests:      400
Failed requests:        0
Write errors:           0
Total transferred:      18473376 bytes
HTML transferred:       18348354 bytes
Requests per second:    22.68 [#/sec] (mean)
Time per request:       220.465 [ms] (mean)
Time per request:       44.093 [ms] (mean, across all concurrent requests)
Transfer rate:          1022.84 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        6    6   0.2      6       9
Processing:   176  212  26.1    207     380
Waiting:      142  172  21.4    169     277
Total:        182  218  26.1    213     386

Percentage of the requests served within a certain time (ms)
  50%    213
  66%    221
  75%    225
  80%    230
  90%    252
  95%    272
  98%    290
  99%    325
 100%    386 (longest request)

We decided to implement memcached which means some small code rewrite, which is quite simple. After that apache serves the pages within the 47 pages per second. Nice but still poor.

[root@webmel4 ~]# ab -n 400 -c 5 http://beta.somedomain.cz/
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 beta.somedomain.cz (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 400 requests

Server Software:        Apache
Server Hostname:        beta.somedomain.cz
Server Port:            80

Document Path:          /
Document Length:        11128 bytes

Concurrency Level:      5
Time taken for tests:   8.403883 seconds
Complete requests:      400
Failed requests:        0
Write errors:           0
Total transferred:      4579944 bytes
HTML transferred:       4455233 bytes
Requests per second:    47.60 [#/sec] (mean)
Time per request:       105.049 [ms] (mean)
Time per request:       21.010 [ms] (mean, across all concurrent requests)
Transfer rate:          532.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4    5   1.2      6      16
Processing:    45   98  40.8     88     249
Waiting:       37   81  34.0     73     218
Total:         51  104  40.7     94     253

Percentage of the requests served within a certain time (ms)
  50%     94
  66%    113
  75%    131
  80%    139
  90%    165
  95%    177
  98%    205
  99%    231
 100%    253 (longest request)

Finally we decided to add apc php cache. Speed up is quite better cca 130 pages per second.

[root@webmel4 ~]# ab -n 400 -c 5 http://beta.somedomain.cz/
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 beta.somedomain.cz (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 400 requests

Server Software:        Apache
Server Hostname:        beta.somedomain.cz
Server Port:            80

Document Path:          /
Document Length:        11128 bytes

Concurrency Level:      5
Time taken for tests:   3.70608 seconds
Complete requests:      400
Failed requests:        0
Write errors:           0
Total transferred:      4584288 bytes
HTML transferred:       4459266 bytes
Requests per second:    130.27 [#/sec] (mean)
Time per request:       38.383 [ms] (mean)
Time per request:       7.677 [ms] (mean, across all concurrent requests)
Transfer rate:          1457.69 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        6    6   0.2      6       9
Processing:    21   31   8.2     30      83
Waiting:       14   23   7.9     22      76
Total:         27   37   8.2     36      89

Percentage of the requests served within a certain time (ms)
  50%     36
  66%     39
  75%     41
  80%     43
  90%     47
  95%     51
  98%     60
  99%     78
 100%     89 (longest request)

So, as you can see, there are ways to speedup the web apps not mentioning that the app itself can be better. We have seen the code and it seems to me that the programmer did not optimize anything within the code.

Benchmarks were run against CentOS 4.8 machine running:

httpd-2.0.52-41.ent.4.centos4
memcached-1.4.1-2.el4.hrb
php-5.1.6-3.el4s1.10
php-pecl-apc-3.0.19-1.el4.hrb
php-pecl-memcache-3.0.4-3.el4.hrb

You can find non distribution packages within my repos.


Comments:

Аня -

Сайт отличный. Награду бы Вам за него или орден почета. ;)

Lucian -

Wow, impressive! APC really makes the difference here. Btw, thanks for packaging it for Centos.