Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have never thought about that but now I am interested about few basic things behind the scenes. 1) Does webserver close connection after each request? 2) When I have more browser windows opened and all request data from some webserver, does the webserver uses some kind of standard socket communication in order to recognize which connection was requesting what? 3)What if there are more users than free ports (say 66k requesting something at the same time)

Thanks :)

share|improve this question
up vote 2 down vote accepted
  1. Depends on what version of HTTP the request is using. HTTP 1.0 connections are closed immediately when the server finishes sending the response back to the user agent. HTTP1.1 added support for keepalives which lets the socket connection stay open after the response has been returned to the user agent. In this case a Connection: Keep-Alive HTTP header is sent by the user-agent indicating that it wishes to maintain the open connection, implying that it's going to be sending more requests on through.
  2. Yes. This is basic socket functionality. The client opens a socket on a (typically high) unused local port and attempts to open a connection with a specific destination port (eg: 80 for HTTP) on the remote host. Every other connection the client creates opens a local socket on a different port, but could still attempt a connection on the same port on the remote host.
  3. The listener process on the server will spawn worker processes to handle the multiple incoming requests, leaving the listener free to handle incoming requests. Most http servers will have a configuration option to govern the number of simultaneous requests to handle.
share|improve this answer

1) Generally each page request is confined to one connection open and closed.

2) Your computer changes its source port for each request it makes. The server uses the IP/source port combination to keep track of which requests came from which hosts

3) Well the server is answering all HTTP requests on port 80. But as for the clients, if you could generate 66K requests from 1 client at the exact same time you might have problems, I'm not sure on that one.

share|improve this answer

1) Keepalive is supported in most modern webservers, so if the browser supports it, the webserver will honour more than one request per connection.

2) Yes, each connection gets it's own socket, which is an IP:PORT pair.

3) If you have 65,535 people simultaneously requesting from a single server, you need to step back and consider what you're doing! :) Seriously, unless you are very lucky you will feel the need to loadbalance before you reach this problem. A problem you could have sooner is running out of file descriptors. The default in bash is 1024 (see "ulimit" in the bash manpage).

share|improve this answer

Your Answer


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