What exactly is a pre-fork web server model?

Pre-forking basically means a master creates forks which handle each request. A fork is a completely separate *nix process.

Update as per the comments below. The pre in pre-fork means that these processes are forked before a request comes in. They can however usually be increased or decreased as the load goes up and down.

Pre-forking can be used when you have libraries that are NOT thread safe. It also means issues within a request causing problems will only affect the process which they are processed by and not the entire server.

The initialisation running multiple times all depends on what you are deploying. Usually however connection pools and stuff of that nature would exist for each process.

In a threading model the master would create lighter weight threads to dispatch requests too. But if a thread causes massive issues it could have repercussions for the master process.

With tools such as Nginx, Apache 2.4’s Event MPM, or gevent (which can be used with Gunicorn) these are asynchronous meaning a process can handle hundreds of requests whilst not blocking.

Leave a Comment