Simple threading question

Ian Hobson ian at ianhobson.co.uk
Mon Sep 27 15:59:37 MSD 2010


On 27/09/2010 07:05, Ankur Gupta wrote:
> I have a bunch of nginx and php-fpm worker threads.  I am running a
> very simple test with a script doing: <? sleep(20); ?>.  I notice that
> if I make two requests at the same time (from the same IP address), they
> get serialized on the
> php-fpm side and have a twenty second differential.  Why would this
> happen and the two requests not get processed in parallel when there
> are an abundant number of threads?

This is a feature of PHP.

It carefully sequences the accesses so that only one thread at a time 
can access the session variables.

You can call session_write_close() after you have updated all your 
session variables, to tell php you are done with the session and it will 
release any waiting thread.

If nginx is serving static content, these serves will not be effected.

Regards

Ian




More information about the nginx mailing list