Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  John Gardeniers Mar 4 '11 at 11:35
    
Yes, I am after that much detail! –  Moon Mar 4 '11 at 11:40
    
I also want a simple conceptual overview to get started. –  Moon Mar 4 '11 at 11:40

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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