4

While I was talking with my co-workers few days ago, one of them mentioned that apache creates a thread per connection.

What does he mean by per connection exactly?

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?

3
  • Explaining threads properly means crossing over into the programming side of things. Are you after that much detail or do you just want a simple conceptual overview? Mar 4, 2011 at 11:35
  • Yes, I am after that much detail!
    – Moon
    Mar 4, 2011 at 11:40
  • I also want a simple conceptual overview to get started.
    – Moon
    Mar 4, 2011 at 11:40

2 Answers 2

8

"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.

5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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