superkart Posted May 18, 2011 Share Posted May 18, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/236760-considerable-performance-drop-after-sleep-is-introduced/ Share on other sites More sharing options...
superkart Posted May 18, 2011 Author Share Posted May 18, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/236760-considerable-performance-drop-after-sleep-is-introduced/#findComment-1217064 Share on other sites More sharing options...
requinix Posted May 18, 2011 Share Posted May 18, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/236760-considerable-performance-drop-after-sleep-is-introduced/#findComment-1217085 Share on other sites More sharing options...
superkart Posted May 19, 2011 Author Share Posted May 19, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/236760-considerable-performance-drop-after-sleep-is-introduced/#findComment-1217395 Share on other sites More sharing options...
superkart Posted May 19, 2011 Author Share Posted May 19, 2011 requinix thanks for the reply. It was your reply that led to config changes.. Quote Link to comment https://forums.phpfreaks.com/topic/236760-considerable-performance-drop-after-sleep-is-introduced/#findComment-1217396 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.