Jump to content

Considerable Performance drop after sleep is introduced


superkart

Recommended Posts

Hi All,

 

I'm new to PHP and I'm probably making a fundamental mistake somewhere, however, enough time wasted, I thought you might be able to shed some light on my problem.

 

I basically have a php script running with nginx and fast_cgi. The whole script is just a large switch statement that does some matching against the request strings and returns a template rendered by Tenjin. It all works fine and it's quite performant based on a simple curl-loader test.

The simple performance figures are taken from curl-loader and show 400 CAPS (Call Attempts Per Second).

The test is 200 clients requesting the same url for 100 cycles.

 

The problem arises when I introduce a "sleep" into the php code for 150 milliseconds, which is my basic idea of introducing latency to the system. The performance for the same test of 200 clients * 100 cycles produces 55 CAPS which is a huge drop in performance based on 150 millisecond delay. The sleep method used is "usleep" and I've also tried "time_nanosleep".

 

I know there's not a huge amount of info there but based on performance figures above, is there something fundamental/trivial I'm missing or doing??? Are there any known issues with the sleep methods???

 

I've tried setting 'set_time_limit(0)' before the sleep call but that didn't help. Any advice you can offer is greatly appreciated..

Link to comment
Share on other sites

Oh the system and software versions:

The whole thing is running on Linux (Ubuntu 10.04)

PHP:

php -v

PHP 5.3.2-1ubuntu4.9 with Suhosin-Patch (cli) (built: May  3 2011 00:43:34)

Copyright © 1997-2009 The PHP Group

Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies

    with Suhosin v0.9.29, Copyright © 2007, by SektionEins GmbH

 

php-fpm -v

PHP 5.3.2-1ubuntu4.7ppa5~lucid1 (fpm-fcgi) (built: Jan 14 2011 13:40:51)

Copyright © 1997-2009 The PHP Group

Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies

    with Suhosin v0.9.29, Copyright © 2007, by SektionEins GmbH

 

php5 -v

PHP 5.3.2-1ubuntu4.9 with Suhosin-Patch (cli) (built: May  3 2011 00:43:34)

Copyright © 1997-2009 The PHP Group

Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies

    with Suhosin v0.9.29, Copyright © 2007, by SektionEins GmbH

Link to comment
Share on other sites

Hmm, weird. Normally performance drops until you get sleep, and then goes back to normal the next day... Oh...

 

sleep() means your script will take longer, so a drop in numbers makes sense. For an 8x drop I would expect that means your scripts are taking 8x longer: originally around 20ms, now around 170ms.

Might that be the case?

Link to comment
Share on other sites

OK. So it looks like I was able to resolve this by initiating more fastcgi threads/processes and increasing the fastcgi buffers and sizes in the server config.. I'm not sure if this is the right course of action but it works and the heads are happy.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.