Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am configuring a server for a friend.The server has the following specs

Quad Core processor 
100 mbps port

However all php files are loadking very slowly.I did a speedtest and server takes 16 secs to Load FIRST byte.I strongly believe its my php-fpm configuration.Server uses nginx and php only , no mysql etc...

My current php-fpm configuration

pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 35

Server load and ram usage are perfectly fine

Please suggest me a good configuration for this server


This configuration works fine

pm.max_children = 20
pm.start_servers = 7
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 100

The problem with first byte load time is solved.However after like 15-20 hours First byte load time increase gradually. I have to reload php-fpm to get small load time Based on my conf above what i modify to it so that first byte load time remain small and i don't have to restart it:P

UPDATE 2: Before i restarted the php-fpm Time to load first byte: 1.5 sec Total page load time :3.0 sec Time after i restart php-fpm Time to load first byte: 0.3 sec Total page load time :1.5 sec

This clearly shows its a matter of php-fpm configuration , not of slow code

share|improve this question

closed as not a real question by EEAA, Michael Hampton, Martin Fjordvald, mgorven, John Gardeniers Aug 28 '12 at 8:23

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Way too many workers! Use APC to speed up your code and I fully agree with @Martin Fjordvald that slow code is simply slow code. You could for instance post your index.php and we could help you find the bottleneck.

You can have a look at my personal configuration at GitHub. Last load test with a Drupal installation showed loading times of around 120 ms.

Create a new cronjob via crontab -e and put the following into the file:

# Simple reload every hour.
@hourly /etc/init.d/php5-fpm reload

# And restart at midnight.
@daily /etc/init.d/php5-fpm restart
share|improve this answer
Thanks so site load fast.Need to check how server performs with your configuration – Werulz Aug 27 '12 at 15:06
I already use APC – Werulz Aug 27 '12 at 15:07
Check my updated post – Werulz Aug 28 '12 at 3:39
Actually I reload php-fpm every hour and restart it every day via a cronjob. This helps to keep it perfectly stable. Check my updated answer. – Fleshgrinder Aug 28 '12 at 16:06
Thanks ......However i though that there must be some way to fix it.However i guess no one has solution so i install the cron job – Werulz Aug 29 '12 at 7:04

Slow code is slow code and your server configuration cannot do anything about it. The only case that can cause slow speed is if you have so much traffic that your requests have to wait for a process to become available.

Since you're using PHP-FPM enable the slow log and figure out why your code is slow.

share|improve this answer
The code is not that slow , page was loading in 1-2 sec when no user was downloading , now when 10-12 users donload , php pages takes much time to load .HTML pages are load almost instantly – Werulz Aug 26 '12 at 13:57
1-2 seconds is still slow, add in a blocking issue and 10-12 users will cause huge problems. Just enable the damn slow log instead of fumbling around blindly in the dark. – Martin Fjordvald Aug 27 '12 at 15:47
Check my post , i updated it – Werulz Aug 28 '12 at 3:39
So because restarting PHP often fixes the slow code issue it's not a PHP issue but a php-fpm configuration issue? That logic is severely flawed. – Martin Fjordvald Aug 28 '12 at 13:46
Several site uses this script and non have this problem-most are on apache – Werulz Aug 28 '12 at 17:09

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