Yogesh lele
Yogesh lele

Reputation: 412

Does php handle concurrent requests in multithreaded or multiprocess manner?

I am wondering, what goes behind the scenes when simultaneous requests are served by php(apache2).

If it's a multithreaded model, How are the threads managed and what is the bench mark of the concurrent requests.

Upvotes: 8

Views: 1239

Answers (2)

voodoo417
voodoo417

Reputation: 12101

See Apache Multi-Processing Module (MPM).

Upvotes: -3

Joe Watkins
Joe Watkins

Reputation: 17148

The correct answer is: PHP is able to do both, and so can Apache.

With the prefork mpm, a multi-process model is used, several instances of apache are forked upon server startup which in turn initialize the PHP interpreter, one interpreter for every process.

With the worker mpm, the model is thread based; there can be as little as one process, for each thread that Apache initializes, it again initializes a PHP interpreter.

In either mode, the instances of the interpreter are isolated from one another, in prefork mode because that's the way forking works, and in worker mode because of TSRM, an omnipresent part of PHP that nobody really talks about.

Upvotes: 11

Related Questions