Apache on linux and i18n : spawning processes or threads?
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 f开发者_运维问答rom 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().
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
精彩评论