PHP, easy as APC

No Comments
I moved my web services from Mediatemple to a box in a rack somewhere in Atlanta. I'm leasing the 1U from Chris Kelly, who is leasing several other Us, as well as power and bandwidth. My nerdier friends demand to know the specs (I ordered the box in parts from Newegg with "reasonable" as my only goal), but I'm not focused on such things -- merely being glad to be out of the Mediatemple grid server ghetto. Okay, fine, it's an AMD 64X2 5400+ with 4G of RAM and a terabyte of storage. Another 4G of RAM is on its way. Mmm, RAM. That is neither here nor there, since it's the personal (if physically distant) control that I wanted. Case in point: PHP opcode caching, in the form of APC. (I tried XCache, but things went haywire in ways that might not have been XCache's fault, but when in a community (like Gallery) it's often useful to stick with what other people are doing rather than reinventing the wheel. I'd like to mention that XCache has an "isset" function and APC does not, meaning that if you want to store a FALSE (presumably the result of a complicated but memoizable computation) you have to wrap it in something else. You probably have to wrap everything then, but that's something that can be worked out. So, Zach wanted to see benchmarks of APC versus not-APC. Enter our old friend ab. I ran some tests from a neighboring box over gigabit ethernet because I wanted to get a real maximum requests number, including a bare minimum network overhead. This information was common to each run:
This is ApacheBench, Version 2.0.40-dev Revision: 1.146 apache-2.0 Server Software: Apache/2.2.8 Server Hostname: gallery2.jpmullan.com Server Port: 80 Concurrency Level: 1 Complete requests: 100 Failed requests: 0 Write errors: 0
APC On
ab -n 100 http://gallery2.jpmullan.com/
Time taken for tests:   13.41635 seconds
Total transferred:      694500 bytes
HTML transferred:       652400 bytes
Requests per second:    7.67 [#/sec] (mean)
Time per request:       130.416 [ms] (mean)
Time per request:       130.416 [ms] (mean, across all concurrent requests)
Transfer rate:          51.99 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   127  129   3.6    130     161
Waiting:      127  129   3.6    130     161
Total:        127  129   3.6    130     161
APC Off
$ ab -n 100 http://gallery2.jpmullan.com/
Time taken for tests:   33.743932 seconds
Total transferred:      694500 bytes
HTML transferred:       652400 bytes
Requests per second:    2.96 [#/sec] (mean)
Time per request:       337.439 [ms] (mean)
Time per request:       337.439 [ms] (mean, across all concurrent requests)
Transfer rate:          20.09 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   323  336  11.1    336     410
Waiting:      322  336  11.1    336     410
Total:        323  336  11.1    336     410
However, the front page only says so much. Let's view a large album inside of my gallery (incidentally full of pictures from my recent vacation in San Francisco). APC On
ab -n 100 http://gallery2.jpmullan.com/v/scans/2008/04/20080420/
Time taken for tests:   26.385255 seconds
Total transferred:      1542900 bytes
HTML transferred:       1503000 bytes
Requests per second:    3.79 [#/sec] (mean)
Time per request:       263.853 [ms] (mean)
Time per request:       263.853 [ms] (mean, across all concurrent requests)
Transfer rate:          57.08 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   259  263  10.6    261     355
Waiting:      256  260  10.4    258     350
Total:        259  263  10.6    261     355
APC Off
ab -n 100 http://gallery2.jpmullan.com/v/scans/2008/04/20080420/
Time taken for tests:   52.541065 seconds
Total transferred:      1542900 bytes
HTML transferred:       1503000 bytes
Requests per second:    1.90 [#/sec] (mean)
Time per request:       525.411 [ms] (mean)
Time per request:       525.411 [ms] (mean, across all concurrent requests)
Transfer rate:          28.66 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.9      0      19
Processing:   517  524   5.1    525     548
Waiting:      504  510   4.7    510     533
Total:        517  524   6.3    525     567
Let's summarize: in the four test runs, APC allowed my server to return data at least twice as fast. That seems like reason enough to keep it.
APC StateRequests
per second
Speedup
On7.67259%
Off2.96
On3.79199%
Off1.90

Be the first to write a comment!