Welcome! Log In Create A New Profile

Advanced

optimization guidelines...

Posted by Ilan Berkner 
Ilan Berkner
optimization guidelines...
January 14, 2009 05:40PM
Does anyone have specific or "generic" optimization guidelines for running
Nginx in the following configuraiton?

- Dedicated Nginx server (1)
- PHP FPM
- FastCgi

- Dedicated DB Server
- MySQL

Traffic on our site is increasing and I noticed that CPU utilization on our
Nginx server is going over 50%, primarily to php-cgi processes. We are
optimizing php using APC.

Any suggestions would be greatly appreciated (additional information can be
provided).

Thanks
Joe Aston
Re: optimization guidelines...
January 14, 2009 05:50PM
I seem to remember using PHP APC with FastCGI was a bad idea because php-cgi
processes couldn't share the same cache - they all required their own unique
caches.

How many php-cgi processes are you running?

On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected]> wrote:

> Does anyone have specific or "generic" optimization guidelines for running
> Nginx in the following configuraiton?
>
> - Dedicated Nginx server (1)
> - PHP FPM
> - FastCgi
>
> - Dedicated DB Server
> - MySQL
>
> Traffic on our site is increasing and I noticed that CPU utilization on our
> Nginx server is going over 50%, primarily to php-cgi processes. We are
> optimizing php using APC.
>
> Any suggestions would be greatly appreciated (additional information can be
> provided).
>
> Thanks
>
>
>
>
Ilan Berkner
Re: optimization guidelines...
January 14, 2009 06:00PM
We are running 10. Is that to little or to much, how can you tell?

Below is a chart showing a snapshot of utilization which is what is killing
the CPU:

[email protected] [/etc]# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
%CPU PID USER COMMAND
21.3 30097 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
21.1 30095 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
19.1 30078 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
18.6 30091 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
18.6 30080 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
18.2 30087 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
17.8 30083 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
17.7 30093 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf
17.2 30076 spellcit /usr/local/bin/php-cgi --fpm --fpm-config
/etc/php-fpm.conf



On Wed, Jan 14, 2009 at 11:31 AM, Joe Aston <[email protected]> wrote:

> I seem to remember using PHP APC with FastCGI was a bad idea because
> php-cgi processes couldn't share the same cache - they all required their
> own unique caches.
>
> How many php-cgi processes are you running?
>
>
> On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected]> wrote:
>
>> Does anyone have specific or "generic" optimization guidelines for running
>> Nginx in the following configuraiton?
>>
>> - Dedicated Nginx server (1)
>> - PHP FPM
>> - FastCgi
>>
>> - Dedicated DB Server
>> - MySQL
>>
>> Traffic on our site is increasing and I noticed that CPU utilization on
>> our Nginx server is going over 50%, primarily to php-cgi processes. We are
>> optimizing php using APC.
>>
>> Any suggestions would be greatly appreciated (additional information can
>> be provided).
>>
>> Thanks
>>
>>
>>
>>
>
>
Andrew Thornton
Re: optimization guidelines...
January 14, 2009 06:00PM
Isn't PHP FPM a form of cgi?

On Wed, Jan 14, 2009 at 11:31 AM, Joe Aston <[email protected]> wrote:

> I seem to remember using PHP APC with FastCGI was a bad idea because
> php-cgi processes couldn't share the same cache - they all required their
> own unique caches.
>
> How many php-cgi processes are you running?
>
>
> On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected]> wrote:
>
>> Does anyone have specific or "generic" optimization guidelines for running
>> Nginx in the following configuraiton?
>>
>> - Dedicated Nginx server (1)
>> - PHP FPM
>> - FastCgi
>>
>> - Dedicated DB Server
>> - MySQL
>>
>> Traffic on our site is increasing and I noticed that CPU utilization on
>> our Nginx server is going over 50%, primarily to php-cgi processes. We are
>> optimizing php using APC.
>>
>> Any suggestions would be greatly appreciated (additional information can
>> be provided).
>>
>> Thanks
>>
>>
>>
>>
>
>
Olivier Bonvalet
Re: optimization guidelines...
January 14, 2009 06:15PM
Hello,

if you use a wrapper for PHP with for exemple "export
PHP_FCGI_CHILDREN=16", then the opcode cache will be shared between 16
php instances.

If you have 4 or more CPU, you should try to use "xcache" instead of
"apc" (and don't forget to adjust the xcache.count parameter), which
give much better results for us (about 75% faster in high load).

Good luck,
Olivier

Joe Aston a écrit :
> I seem to remember using PHP APC with FastCGI was a bad idea because
> php-cgi processes couldn't share the same cache - they all required
> their own unique caches.
>
> How many php-cgi processes are you running?
>
> On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected]
> <mailto:[email protected]>> wrote:
>
> Does anyone have specific or "generic" optimization guidelines for
> running Nginx in the following configuraiton?
>
> - Dedicated Nginx server (1)
> - PHP FPM
> - FastCgi
>
> - Dedicated DB Server
> - MySQL
>
> Traffic on our site is increasing and I noticed that CPU
> utilization on our Nginx server is going over 50%, primarily to
> php-cgi processes. We are optimizing php using APC.
>
> Any suggestions would be greatly appreciated (additional
> information can be provided).
>
> Thanks
>
>
>
>
>
Ilan Berkner
Re: optimization guidelines...
January 14, 2009 06:30PM
Thanks for the advice, I will research.

On Wed, Jan 14, 2009 at 11:56 AM, Olivier Bonvalet <[email protected]>wrote:

> Hello,
>
> if you use a wrapper for PHP with for exemple "export
> PHP_FCGI_CHILDREN", then the opcode cache will be shared between 16 php
> instances.
>
> If you have 4 or more CPU, you should try to use "xcache" instead of "apc"
> (and don't forget to adjust the xcache.count parameter), which give much
> better results for us (about 75% faster in high load).
>
> Good luck,
> Olivier
>
> Joe Aston a
Just Marc
Re: optimization guidelines...
January 14, 2009 07:35PM
Most of the times a load increase on PHP nodes is a direct result of a
slow db, or certain slow db queries. Turn on the slow query log on your
mysql box and eliminate any slow queries you see, especially ones that
show up often. Turn on the mysql log which shows sql queries that don't
use indices and add the appropriate indices.

If you have PHP processes consistently having NOTICEABLE load and you've
made sure no db queries are slow try http://xdebug.org/ and it will
give you very useful information - although most of the time this is a
more advanced method for higher traffic / higher performance sites who
care deeply about how their scripts behave.

There are countless ways to monitor and keep track of important
performance metrics on your servers. Most often it's useful to watch
more than a few parameters and regularly make sure that the are under
control.

Marc

Olivier Bonvalet wrote:
> Hello,
>
> if you use a wrapper for PHP with for exemple "export
> PHP_FCGI_CHILDREN", then the opcode cache will be shared between 16
> php instances.
>
> If you have 4 or more CPU, you should try to use "xcache" instead of
> "apc" (and don't forget to adjust the xcache.count parameter), which
> give much better results for us (about 75% faster in high load).
>
> Good luck,
> Olivier
>
> Joe Aston a écrit :
>> I seem to remember using PHP APC with FastCGI was a bad idea because
>> php-cgi processes couldn't share the same cache - they all required
>> their own unique caches.
>>
>> How many php-cgi processes are you running?
>>
>> On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Does anyone have specific or "generic" optimization guidelines for
>> running Nginx in the following configuraiton?
>> - Dedicated Nginx server (1)
>> - PHP FPM
>> - FastCgi
>> - Dedicated DB Server
>> - MySQL
>> Traffic on our site is increasing and I noticed that CPU
>> utilization on our Nginx server is going over 50%, primarily to
>> php-cgi processes. We are optimizing php using APC.
>> Any suggestions would be greatly appreciated (additional
>> information can be provided).
>> Thanks
>>
>>
>
>
Ilan Berkner
Re: optimization guidelines...
January 14, 2009 08:15PM
Thanks, been working on various avenues to track down particular
bottlenecks. For one thing, I realized we weren't caching PHP pages (we had
turned it off the other day).

On Wed, Jan 14, 2009 at 2:03 PM, Just Marc <[email protected]> wrote:

> Most of the times a load increase on PHP nodes is a direct result of a slow
> db, or certain slow db queries. Turn on the slow query log on your mysql
> box and eliminate any slow queries you see, especially ones that show up
> often. Turn on the mysql log which shows sql queries that don't use indices
> and add the appropriate indices.
>
> If you have PHP processes consistently having NOTICEABLE load and you've
> made sure no db queries are slow try http://xdebug.org/ and it will give
> you very useful information - although most of the time this is a more
> advanced method for higher traffic / higher performance sites who care
> deeply about how their scripts behave.
>
> There are countless ways to monitor and keep track of important performance
> metrics on your servers. Most often it's useful to watch more than a few
> parameters and regularly make sure that the are under control.
>
> Marc
>
>
> Olivier Bonvalet wrote:
>
>> Hello,
>>
>> if you use a wrapper for PHP with for exemple "export
>> PHP_FCGI_CHILDREN", then the opcode cache will be shared between 16 php
>> instances.
>>
>> If you have 4 or more CPU, you should try to use "xcache" instead of "apc"
>> (and don't forget to adjust the xcache.count parameter), which give much
>> better results for us (about 75% faster in high load).
>>
>> Good luck,
>> Olivier
>>
>> Joe Aston a
mike
Re: optimization guidelines...
January 14, 2009 08:20PM
Php-fpm handles the children automatically. No need for the
environment vars.

On Jan 14, 2009, at 9:06 AM, "Ilan Berkner" <[email protected]> wrote:

> Thanks for the advice, I will research.
>
> On Wed, Jan 14, 2009 at 11:56 AM, Olivier Bonvalet <[email protected]
> > wrote:
> Hello,
>
> if you use a wrapper for PHP with for exemple "export
> PHP_FCGI_CHILDREN", then the opcode cache will be shared between
> 16 php instances.
>
> If you have 4 or more CPU, you should try to use "xcache" instead of
> "apc" (and don't forget to adjust the xcache.count parameter), which
> give much better results for us (about 75% faster in high load).
>
> Good luck,
> Olivier
>
> Joe Aston a écrit :
> I seem to remember using PHP APC with FastCGI was a bad idea because
> php-cgi processes couldn't share the same cache - they all required
> their own unique caches.
>
> How many php-cgi processes are you running?
>
> On Wed, Jan 14, 2009 at 4:14 PM, Ilan Berkner <[email protected] <mailto:[email protected]
> >> wrote:
>
> Does anyone have specific or "generic" optimization guidelines for
> running Nginx in the following configuraiton?
> - Dedicated Nginx server (1)
> - PHP FPM
> - FastCgi
> - Dedicated DB Server
> - MySQL
> Traffic on our site is increasing and I noticed that CPU
> utilization on our Nginx server is going over 50%, primarily to
> php-cgi processes. We are optimizing php using APC.
> Any suggestions would be greatly appreciated (additional
> information can be provided).
> Thanks
>
>
>
>
>
luben karavelov
Re: optimization guidelines...
January 14, 2009 10:35PM
Ilan Berkner wrote:
> We are running 10. Is that to little or to much, how can you tell?
>
> Below is a chart showing a snapshot of utilization which is what is
> killing the CPU:
>


My experience with perl fcgi application is that you get maximum
throughput when the number of fcgi processes is between the number of
cores and 2 times number of cores on the system. For example if you have
2 QuadCore Xeons , that means that you get max throughput between 8
and 16 fcgi proceesses.

I doubt that it will be very different with php+mysql.

Best regards
Sorry, only registered users may post in this forum.

Click here to login