Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Based on many online sources, in serving static files, Apache2 will create new thread on every different connection... results in resource hungry

But how about serving PHP through Apache2 (mod_php, MPM worker, etc)? Does apache will also open new thread like serving static files?

(AFAIK, in nginx php-fpm, we can set the max thread, but I dont know how many connection per thread)

I'm planning to use Apache2 in serving PHP, and hope it will be same as nginx PHP-FPM or even better in resource usage and performance.

share|improve this question
    
Creating threads/processes does not equate to 'resource hungry'. With threads they share memory due to being in the same process. With forks (processes) they still share memory due to linux's copy-on-write memory management. In both models, each worker (for each connection) still has to maintain its own data though. Basically dont jump to conclusions. If this model was bad, it wouldnt exist... –  Patrick Jun 9 '12 at 7:28
add comment

1 Answer

up vote 3 down vote accepted

Yes, Apache creates a separate thread (or process, with the pre-fork MPM) to serve each concurrent PHP request.

share|improve this answer
    
Apache 2.4 now has an Event MPM. No idea how well that plays with mod_php. –  Ladadadada Jun 9 '12 at 8:57
    
@Ladadadada: I can't imagine it'd end well. It's tricky enough getting mod_php to play well with worker (as Rasmus himself said, "people aren't smart enough to write thread-safe code"). But then again, I don't recommend people ever run mod_php, so the whole problem never comes up for me any more. –  womble Jun 10 '12 at 0:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.