I have a PHP file that gets HTML from Memcached and serves it to the user. When I test it like this:
ab -n 1000 -c 100 http://website.com/test.php
It does 22 requests per second.
But when I put the same HTML to an HTML file and do this test:
ab -n 1000 -c 100 http://website.com/test.html
I get like 4500 requests per second.
I need to stick to PHP because the first time I need to generate HTML, and the next times I just get the generated one from Memcached. And moreover the HTML I display is different for every other user (recognized based on $_GET ['user_id'] value). Is there any way to make RPS higher? Closer to serving plain HTML?
I use lighttpd as the web server.
Chain of thoughts (to be continued....):
First I would test if the problem is triggered by or significantly worsened by concurrency. With your -n 1000 -c 100 test you had a ratio of 22/4500. What about -n 1000 -c 10 or -n 1000 -c 1?
Then I would try the same again + keeping track of memory consumption, disk I/O and CPU usage. Is any of this clearly the limiting factor?
Then I'd test simple PHP scripts:
test.html copied over to test.phpecho $mc->get(string $key)How do those compare to test.html?
Edit:
Let's take Web Server Performance Comparison: LiteSpeed 2.0 VS as a comparison point. The benchmark was performed "for" another "rivaling" webserver product but for the moment let's assume they weren't (too) biased ;-)
They had a
The lighthttpd served 15475 files per second of 100 bytes, scripts helloworld.php 1593 times per second and phpinfo.php 399 times per second (both FastCGI). That's a ratio of ~ 1:10 (hello world) or 1:40 (phpinfo). "Your" ratio is 22:4500 ~ 1:200. And even stranger it doesn't change when the script changes. Your "real" script or an empty PHP script, no matter always 1:22. That raises the "strangeness factor" quite a bit (even though the tests are not identical).
First of all I would double-check if PHP was compiled with FastCGI support, see http://www.fastcgi.com/docs/faq.html#PHP.
Then I'd test "my" lighthttpd with a simple C/C++ FastCGI program as mentioned in the test, a real simple "hello world". There's an example at http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm#4263. If this scales "well", i.e. significantly better than your PHP FastCGI, I'd try it with a "barely running" PHP version, i.e. compiled with --disable-all and only those modules (re)actived and built-in that are necessary to start PHP and let it print "hello world". Also use the default php.ini. Does this change anything?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With