I did some very basic benchmarks this weekend that seemed to indicate that APC was causing PHP not to do any work in parallel. Turns out that was wrong. PHP was suddenly only using 1 CPU because it was just that much more efficient with APC enabled.
Without APC:
Transactions: 78729 hits Availability: 100.00 % Elapsed time: 599.35 secs Data transferred: 320.13 MB Average response time: 3.30 secs Transaction rate: 131.36 trans/sec Throughput: 0.53 MB/sec Concurrency: 432.88 Successful transactions: 78729 Failed transactions: 0 Longest transaction: 7.71 secs Shortest transaction: 0.05 secs
With APC:
Transactions: 344604 hits Availability: 100.00 % Elapsed time: 599.51 secs Data transferred: 1402.36 MB Average response time: 0.37 secs Transaction rate: 574.81 trans/sec Throughput: 2.34 MB/sec Concurrency: 211.28 Successful transactions: 344604 Failed transactions: 0 Longest transaction: 4.35 Shortest transaction: 0.08
That’s almost an order of magnitude difference in response time.
This was a timed test using Siege, a neat little tool with a couple of caveats. (Your user’s open files limit needs to be huge, and you need to have the hostname you’re attacking in /etc/hosts, or Siege will make a new DNS lookup with every request–stupid.)
The test was timed: create 500 “warriors,” and for 10 minutes get back as many hits as you can.
You may notice the concurrency is significantly different between runs. The number of “warriors” was the same, but less of their time was spent actually attacking, because the requests were that much faster. These “warriors” were able to plunder 4.3 times as many pages with APC turned on as with it turned off.
System load during the tests:
08:38:02 AM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked 08:41:01 AM 24 810 17.78 5.87 2.10 0 08:44:01 AM 24 794 23.91 14.17 6.00 0 08:47:01 AM 27 798 24.36 18.77 9.23 1 08:50:01 AM 0 308 14.58 18.87 11.08 0
CPU usage during the tests:
08:38:02 AM CPU %user %nice %system %iowait %steal %idle 08:41:01 AM all 53.28 0.00 2.94 0.04 0.00 43.73 08:44:01 AM all 95.56 0.00 4.43 0.00 0.00 0.01 08:47:01 AM all 95.48 0.00 4.51 0.00 0.00 0.01 08:50:01 AM all 80.53 0.00 4.06 0.01 0.00 15.40 08:53:01 AM all 65.67 0.00 14.34 0.24 0.00 19.75 08:56:01 AM all 78.21 0.00 19.61 0.38 0.00 1.79 08:59:01 AM all 77.60 0.00 19.93 0.48 0.00 1.98 09:02:01 AM all 41.28 0.00 11.16 0.29 0.00 47.28 09:05:01 AM all 2.71 0.00 0.90 0.23 0.00 96.16
I need to have some peer review and independent verification of these results, but I’m fairly convinced at this point: with PHP 5.4 and FPM, APC is a definite win.