How can a web server handle multiple user's incoming requests at a time on a single port (80)?

user2032344 picture user2032344 · Jun 6, 2013 · Viewed 46.4k times · Source

How does a web server handle multiple incoming requests at the same time on a single port(80)?

Example : At the same time 300k users want to see an image from www.abcdef.com which is assigned IP 10.10.100.100 and port 80. So how can www.abcdef.com handle this incoming users' load?

Can one server (which is assigned with IP 10.10.100.100) handle this vast amount of incoming users? If not, then how can one IP address be assigned to more than one server to handle this load?

Answer

Marquis of Lorne picture Marquis of Lorne · Jun 6, 2013

A port is just a magic number. It doesn't correspond to a piece of hardware. The server opens a socket that 'listens' at port 80 and 'accepts' new connections from that socket. Each new connection is represented by a new socket whose local port is also port 80, but whose remote ip:port is as per the client who connected. So they don't get mixed up. You therefore don't need multiple IP addresses or even multiple ports at the server end.