Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

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.

share|improve this answer

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

share|improve this answer
    
Sure. I'll add it to the question right now. –  Matthew Sep 17 '10 at 16:48

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.