0

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.

apasajja
  • 167
  • 3
  • 10
  • 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... – phemmer Jun 09 '12 at 07:28

1 Answers1

3

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

womble
  • 96,255
  • 29
  • 175
  • 230
  • Apache 2.4 now has an Event MPM. No idea how well that plays with mod_php. – Ladadadada Jun 09 '12 at 08: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 00:24