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

Admittedly this is a simple question but 20 minutes of googling and I just can't find an answer... I will frame my question with an example.

say I own www.reallypopular.com and my website sees 100 GET requests per second. Also let's say the average time for my server to respond to that GET request is 1 second (for the sake of the example just assume some server side processing.) My understanding of ports would say that the first client to contact my server would then block anyone else from connection to port 80 for 1 second. Following this logic, effectively only 1% of all users would actually be responded to and the rest would get "Port busy" or "not responding" or some such error.

Obviously I am missing something because this is clearly not what is happening so instead of proposing my theories as to why I'd love it if someone could set me straight here or point me to something I could read to clear this up. Thanks much.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

The answer can be found in this wikipedia article:

Applications implementing common services often use specifically reserved, well-known port numbers for receiving service requests from client hosts. This process is known as listening and involves the receipt of a request on the well-known port and reestablishing one-to-one server-client communications on another private port, so that other clients may also contact the well-known service port.

Also, from this article on Berkeley sockets on wikipedia.

When an application is listening for stream-oriented connections from other hosts, it is notified of such events (cf. select() function) and must initialize the connection using the accept() function. Accept() creates a new socket for each connection and removes the connection from the listen queue.

share|improve this answer
    
60 seconds ahead of me AND you follow up with further information! Nice work. +1. –  Jed Daniels Jul 3 '11 at 22:56
    
Thanks. I try my best to help. :) –  sybreon Jul 4 '11 at 10:43
add comment

TCP doesn't work that way. A connection to a port from another system does not mean that port can't receive other connections. From the wikipedia article on TCP:

Arriving TCP data packets are identified as belonging to a specific TCP connection by its sockets, that is, the combination of source host address, source port, destination host address, and destination port.

share|improve this answer
add comment

Modern web servers like Apache are multithreaded. When the daemon starts, it 'listens' on a port, meaning it registers with the OS to receive network traffic that is addressed to that port. Every time a TCP connection is established, the daemon spawns a new thread to handle it.

As far as performance goes, I've heard that lighttpd (pronounced light-ee) is great for handling many connections, but I'm not a web server expert.

share|improve this answer
    
so what happens to the connection on port 80? is it summarily closed? I guess I mean how do 2 clients simultaneously have connection to my port 80? –  deepee1 Jul 3 '11 at 5:19
add comment

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.