How does apache creates a thread?

"Let's say I have a HTML file that contains three images. When I access the file, my browsers request three images to a server. so...does apache make a thread for each images?"

Yes, if two things are true: First, the browser would have to request the three images using three separate connections. Second, the three requests would have to overlap in their processing on the server side.

If the browser uses only one connection, using HTTP/1.1 keepalives, then even if Apache uses a thread for each connection, there's still only one thread. And even if the browser does use three connections, if the browser closes each connection before opening the next, then Apache may be able to re-use the same thread, and not need three different threads to handle the three connections.


The way Apache handles multiple connections is by use of a Multi-Processing Module (MPM). The default MPM depends on the environment your server is installed in.

The default MPMs in the two most common environments are as follows:

Unix    prefork
Windows mpm_winnt

The prefork MPM is process based and does not make use of threads. The alternative in Unix environments is the worker MPM, which uses multiple processes and multiple threads per process.

The mpm_winnt MPM uses 1 server process, 1 child process and multiple threads within the child process.