Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Jun 12, 2013 3:16 pm 
Offline
Senior Member

Joined: Sun Mar 28, 2010 2:43 pm
Posts: 76
Website: http://tomakefast.com
Location: Texas
For a particular site I have two Linodes. One that runs NginX and PHP and the other is for the database. Now that I have separate Linodes, I'm wondering if I should crank up the # of PHP children since I have extra CPU/Memory available.

But I'm thinking of leaving the # of children alone, since the real bottleneck is the database. And I'm thinking MySQL won't necessarily perform better if more children are opening more connections.

So how many PHP children is too many? Or do you think it's best to have as many PHP children as I can fit into memory?

_________________
PHP Development @ Tomakefast


Top
   
PostPosted: Wed Jun 12, 2013 9:18 pm 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
Configure 'status' in the php-fpm pool config file. Then you can get a current status report in your browser.

One item in the status report is 'max children reached'. If you see that number incrementing then you may want to increase the number of children.

_________________
sleddog


Top
   
PostPosted: Thu Jun 13, 2013 4:56 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
My rule of thumb is 1.5n to 2.0n children, where n is the number of cores in the system, but I haven't based that on anything in particular as much as gut feeling and "seems to work well for me".


Top
   
PostPosted: Fri Jun 14, 2013 7:15 pm 
Offline
Senior Member

Joined: Sun Mar 28, 2010 2:43 pm
Posts: 76
Website: http://tomakefast.com
Location: Texas
Guspaz wrote:
My rule of thumb is 1.5n to 2.0n children, where n is the number of cores in the system, but I haven't based that on anything in particular as much as gut feeling and "seems to work well for me".


Great, I have about that many. I'll leave it alone then.

Not exactly sure how many cores I have but I'm guessing it's either 4 or 8.

@sleddog I'll keep that in mind but I'm actually using spawn on this server. (If it ain't broke...)

_________________
PHP Development @ Tomakefast


Top
   
PostPosted: Fri Jun 21, 2013 2:18 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
New linodes should have 8 cores. I'd suggest somewhere between 8 and 16 children is probably appropriate, but it really depends on load. If all you've got with PHP is a few little scripts that execute quickly and are seldom used (or only internally used), then even 8 might be overkill. On the other hand, if you've got lots of long-running streaming ajax scripts that dedicate a PHP process to a single user for minutes or hours on end, then 16 processes won't be anywhere near enough.


Top
   
PostPosted: Sat Jun 22, 2013 9:09 am 
Offline
Senior Member
User avatar

Joined: Tue Nov 24, 2009 1:59 pm
Posts: 362
Yeah, agreed.

I guess general rule is that if your site is sometimes getting non-responsive because all PHP handlers are busy waiting (not as much if busy processing), and you have RAM for it... add more.

I have been running 20 PHP children on a pre-upgrade 4-core Li512, because some of them are usually just stuck waiting for the DB, or for a http transfer to complete.

_________________
rsk, providing useless advice on the Internet since 2005.


Top
   
PostPosted: Tue Oct 15, 2013 3:50 pm 
Offline
Newbie

Joined: Tue Oct 15, 2013 3:41 pm
Posts: 4
The number of children should be primarily based on amount of RAM you have rather than CPU cores, otherwise you'll end up swapping, and no amount of CPUs will help you there.

To work it out is pretty simple. When running your application under "normal" load:

ps -ylC php5-fpm --sort:rss

RSS column will show non-swapped physical memory usage by php5-fpm processes in KB. So, best value for pm.max_children can be calculated as:

pm.max_children = Total RAM dedicated to the web server / Max child process size. In my case it was around 50MB per process, and if I wanted to leave 768MB for php5-fpm:
pm.max_children = 768MB / 50MB = 15.

pm.start, min etc just requires tweaking. Keep in mind you'll need to redo this with any major application (php) upgrade, php config change (xcache settings etc).

If you want to test high load: https://www.blitz.io is pretty good. Keep an eye on your httpd/php5-fpm error logs during the test to see where limits are reached.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group