Simple php benchmark results: requesting the download page 40000 times, with concurrency of 3 with ab tool:
- apache prefork with mod_php:
54,4 #/sec 55,11 ms/req 3,07 5-minute-load
- apache prefork with mod_fcgid
55,7 #/sec 53,85 ms/req 3,00
- apache worker with mod_fcgid
56,9 #/sec 52,68 ms/req 3,02
→ As expected no significant difference in php performance or load, however memory usage with prefork/mod_php combination is "insane", since every apache worker needs RAM for running php, while with mod_fcgid apache processes themselves need almost no ressources, only the php workers consume RAM. Especially when running multiple vhosts (wiki and silverstripe), and each using different php, this adds up.
- for comparison nginx with php-fpm
58,16 #/sec 51,58 ms/req 3,05
→ confirms that the time spent is php - cannot be faster than that/is cpu bound. (similar with mod_fcgid nginx itself doesn't consume resources, only the php-fpm pool's processes consume memory
Where nginx kicks apache's butt however is in connection handling/serving static content from disk, especially with https:
- serving static copy of the download page from disk via https (http)
nginx: ~ 660 #/sec 4,5 ms/req (> 32000 #/sec 0,09ms)
apache: ~ 450 #/sec 6,7 ms/req (~ 10000 #/sec 0,30ms)
- even more apparent when keepalive is turned on:
nginx: > 16000 #/sec 0,18 ms/req (> 70000 #/sec 0,04ms)
apache: 6800 #/sec 0,43 ms/req (~ 10500 #/sec 0,28ms)
Serving static files via plain http is a no-brainer for both configuration, although nginx easily outperforms apache in this regard).
Serving content via https however introduces quite a bit of computational overhead in the connection-handling, and here nginx with keepalive really makes apache look old.
Conclusion: The Load issues from the current server could not be reproduced by just checking silverstripe in isolation, with requesting one page a lot of time. Nevertheless it is clear that apache prefork with mod_php is the clear looser - not so much because of CPU usage (after all neither has noteworthy impact on php execution), but because of memory usage.
fast-cgi / php-fpm definitely is the way to go. And if we have the choice to use either apache or nginx, I'd go for nginx, due to the mixed nature of the site (many static files from disk in addition to the php).
If (contrary to expectations) the load is still high, we can still enable creating static html from silverstripe for many page-types and avoid php-roundtrip for those completely.