I got a new Mac this week – Quad Core Dual 2.66 Intel, pretty sweet. Anyways, the Apple Migration Assistant can only transfer so much. I had to setup PHP 5, MySQL, as well as quite a few other manual install and custom configuration files. Well, I wasn’t getting the performance I was expecting out of my PHP apps, until I remembered that APC wasn’t installed.
Now I’m not that big of an optimization freak, so my code isn’t that lean and mean, but man APC does some amazing stuff.
Here’s the results of an apachebench [ab] on my localhost -
Without APC (~40 req/s):
ucommbieber:~ bbieber$ ab -k -c 50 -t 300 http://localhost/events/
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
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 localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Finished 12202 requests
Server Software: Apache/1.3.33
Server Hostname: localhost
Server Port: 80
Document Path: /events/
Document Length: 23809 bytes
Concurrency Level: 50
Time taken for tests: 300.002 seconds
Complete requests: 12202
Failed requests: 952
(Connect: 0, Length: 952, Exceptions: 0)
Broken pipe errors: 0
Non-2xx responses: 2
Keep-Alive requests: 0
Total transferred: 269977940 bytes
HTML transferred: 267940001 bytes
Requests per second: 40.67 [#/sec] (mean)
Time per request: 1229.31 [ms] (mean)
Time per request: 24.59 [ms] (mean, across all concurrent requests)
Transfer rate: 899.92 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 4.0 0 76
Processing: 117 1226 2243.5 1065 33964
Waiting: 117 1226 2243.4 1065 33936
Total: 117 1227 2246.6 1065 33990
Percentage of the requests served within a certain time (ms)
50% 1065
66% 1097
75% 1119
80% 1133
90% 1184
95% 1375
98% 1764
99% 3704
100% 33990 (last request)
With APC (~208 req/s)
ucommbieber:~ bbieber$ ab -k -c 50 -t 300 http://localhost/events/
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
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 localhost (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Completed 20000 requests
Completed 25000 requests
Completed 30000 requests
Completed 35000 requests
Completed 40000 requests
Completed 45000 requests
Finished 50000 requests
Server Software: Apache/1.3.33
Server Hostname: localhost
Server Port: 80
Document Path: /events/
Document Length: 23809 bytes
Concurrency Level: 50
Time taken for tests: 239.538 seconds
Complete requests: 50000
Failed requests: 0
Broken pipe errors: 0
Keep-Alive requests: 0
Total transferred: 1198823976 bytes
HTML transferred: 1190473809 bytes
Requests per second: 208.74 [#/sec] (mean)
Time per request: 239.54 [ms] (mean)
Time per request: 4.79 [ms] (mean, across all concurrent requests)
Transfer rate: 5004.73 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.0 0 101
Processing: 19 239 43.4 234 1489
Waiting: 19 238 43.4 233 1489
Total: 19 239 44.1 234 1489
Percentage of the requests served within a certain time (ms)
50% 234
66% 238
75% 241
80% 244
90% 254
95% 265
98% 294
99% 349
100% 1489 (last request)
And all you’ve gotta do is:
sudo pear install pecl/apc
sudo apachectl graceful
I went from 40 requests per second to 208 requests per second. Wowzers. You should seriously install it.