views:

88

answers:

3

Is there a way to overcome the port limit on a linux system? We have a server running that accepts incoming connection and it uses very little memory and cpu. It's rather silly that we have to build a cluster of small linux boxes just to overcome a software limit (number of points of around 60k). Any ideas?

+5  A: 

This isn't a software limit of ports, it's a networking limit.

http://en.wikipedia.org/wiki/TCP_and_UDP_port

There are only only a certain number of ports available on an IP network (65k). Your problem isn't a port limit, but perhaps how those ports are being used.

Nissan Fan
no we have persisted connections, we actually need that many ports.
erotsppa
Not uncommon. Most web servers do the same thing hence the HTTP Keep Alives. Without knowing the application here it's hard to give you any direction. Please tell us how you're using this.
Nissan Fan
Incoming connections all connect to the same port -- and any stack that can't handle two clients connecting from the same port number on different IPs is broken.
cHao
+7  A: 

There is no limit of 60k tcp or udp sockets, you just think there is. The actual limit is much higher. There are 64k ports, but the same port may be used for more than one connection, as only the pair of addresses/ports needs to be unique.

Having said that, if you have 60k distinct clients concurrently connected, you may a have high availability requirement which means you'll need to have several machines anyway.

MarkR
+2  A: 

It's not Linux, it's TCP/IP design limitation - port number is a 16-bit unsigned integer, thus 64K limit. Assign multiple addresses - IP aliases - to an interface (or use multiple hardware interfaces), make different servers listen on different IPs. Each interface will give you a separate port range.

Nikolai N Fetissov
Incoming connections all connect to the same port -- and any stack that can't handle two clients connecting from the same port number on different IPs is broken.
cHao
Hmm, I'm talking about different linstening sockets on different IPs.
Nikolai N Fetissov
What i mean is, any self-respecting TCP/IP stack will keep the remote clients 10.0.0.1:1234 and 10.0.0.2:1234 separate, and will allow connections from the both of them at the same time to the same port on the server. So the 64k port limit doesn't apply, even if you use a single IP -- the local and remote socket addresses should be considered 48-bit values (32 bit address + 16 bit port).
cHao