views:

20

answers:

1

Hello, I would like to understand better exactly what is going on when Apache on linux receive an HTTP request in a process pre-fork model.

Let's say we have 20 Apache child processes waiting.

When I receive an HTTP request, is it true to say that 1 child process will be chosen to handle the request and that this process won't handle another request from another user until the first one is finished ?

I am asking the question because of a PHP limitation that states :

The locale information is maintained per process, not per thread.
If you are running PHP on a multithreaded server API like IIS or Apache
on Windows, you may experience sudden changes in locale settings while a script
is running, though the script itself never called setlocale(). This happens due
to other scripts running in different threads of the same process at the same
time, changing the process-wide locale using setlocale().

Thanks Jerome Wagner

A: 

Generally if you work with mpm-prefork that each PHP instance has its own process so it is safe to change locale, if you work with mpm-worker or mpm-event then you are not safe.

Also if you run PHP as fastcgi process behind any server it forks as well and it has process per connection. So it should be safe as well.

Notes:

  • Generally there is no reason not to use mpm-prefork under Linux when running PHP.
  • Under windows there is no such thing as "fork" so apache is multi-threaded under Windows
Artyom