1

So I've got nginx and php-fpm on a cloud server. Using apache benchmark with these settings:

ab -n 300 -c 5 http://example.com/

So the cloud server (from rackspace) was a 256mb one. I ran htop while apache benchmark was going so I could see the server resources.

All four processors (which, do I just have a part of four individual processors on rackspace? I'm not sure how much I have access to) are at 100% (or 98% or something way high) the entire time apache benchmark is running.

Currently I get 15 requests per second. My first thought was to resize the server (I changed it to the 512mb one, so it should have twice as much as everything.). Still, requests per second were exactly the same and processor usage was at/near 100% the whole time.

Then I tried changing php-fpm to have a static 20 processes (instead of 10). This yieled the same results as before.

What could the bottleneck be?

My general application (written in php) on this particular page just connects to a database and gets a list of products. It then just lists them in a table. Not a whole lot of complicate queries (though there are quite a few)

So maybe it's database related?

Matthew
  • 1,769
  • 4
  • 21
  • 32

3 Answers3

1

The best way to go about this is to install a code profiler, like XDebug. Install XDebug and then enable the profiler. It will generate a report that you can quickly inspect, and find out exactly which parts of your code are taking up the most processing time and memory usage. You can then pinpoint these areas in your code to optimize.

Donald
  • 341
  • 2
  • 4
0

Can you provide some more information about what the PHP code is actually doing?

gabbelduck
  • 329
  • 1
  • 3
0

You can run "top" and see which processes (nginx, php-fpm or mysql) actually eat CPU. This would indicate the bottleneck. For easier interpretation of results, please temporary set the number of php-fpm processes to 4. E.g., if you get 4 php-fpm processes each eating 90% of CPU, 5% on nginx and 20% on mysql, then some heavy math in your PHP scripts is the bottleneck. And if php-fpm processes are mostly idle and mysql eats a lot of CPU, then the database is the bottleneck, think about adding an index or two.

AEP
  • 432
  • 2
  • 4