Hacker News new | ask | show | jobs
by illumin8 3110 days ago
Actually, I have to call this out as false - you can't handle millions of HTTP connections on a single machine, because there are only 65,535 available TCP ports. I think you meant that you can handle millions of HTTP connections on a few dozen machines...

Please try again, and stop spouting obviously false facts.

4 comments

Ports are not used up by connections. One port can support 65K simultaneous connections from a single IP. If a thousand machines connect, each with their own IP, one port can handle 65 million connections. If you decide to accept HTTP requests on all ports, then each port of your 65K ports supports millions of connections or more. Suddenly you're talking about a total of billions or trillions of connections all going to one machine. And that's still only using a thousand machines to connect. Open up to the entire internet and you can push that to quintillions of theoretically possible simultaneous connections.
A port doesn't actually get consumed by a TCP connection. Connections are uniquely identified by a (host, port, host, port) combination; i.e. my machine with IP 1.1.1.1 and yours with 2.2.2.2 can have only 2^32 connections between us (slightly less in practice). Even assuming I have a webserver, so my port is fixed to 443, your machine can connect from each of those 2^16 ports - as can every other of the 2^32 machines on the network. In practice, you're limited by memory, not port numbers. Many machines I know of regularly have connection counts in the hundreds of thousands.
You can. Have many IPs that all "route" to the same machine. You get 65535 ports per IP, not per kernel or whatever. It's the reason why ex. hosting companies can give virtual servers on their dedicated hosts and not worry about port conflicts or anything.
Unless, somehow, every one of those sockets happened to share the same port on said machine, say... port 80. So yes, you need to use the mythological TCP server to pull this one off; it's true that you can't have more than 2^15 outbound connections from the same IP though.