Monday, February 2, 2015

Prefork vs Worker in Apache

Everyone knows about apache and most of us also have hands on experience with apache. Today let us see multi processing modules in it. Apcahe comes with 2 multi processing modules(MPMs):

1. Prefork
2. Worker

The defalut MPM is prefork.

What is the difference between this two?
  • Prefork MPM uses multiple child processes with one thread each and each process handles one connection at a time.
  • Worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time.
On most of the systems, speed of both the MPMs is comparable but prefork uses more memory than worker.

Which one to use?
On high traffic websites worker is preferable because of low memory usage as comparison to prefork MPM but prefork is more safe if you are using libraries which are not thread safe.
For example, you cannot use mod_php with worker MPM as it is not thread safe.
So if you are using all thread safe libraries then go with worker and if you are not sure then use prefork MPM, you may have to increase your RAM in case of high traffic.

No comments:

Post a Comment