views:

137

answers:

4

I am about build a server on linux (I get to pick programming language) that accepts many TCP/IP socket persistent connections from a desktop software. How can this be done cheaply and efficiently? A machine cannot have more than 60000 ports, so if I have to support 600k connections then I will need 10 linux boxes?

Since the computation needed for each connection is extremely small (idle 95% of the time) one linux box can already handle 600k I don't want to waste money and resource running 10 boxes just to get around port limitations.

Any ideas?

+6  A: 

A connection is identified by the following tuple: [Server IP;Server Port; Client IP; Client Port], hence, more than 60,000 ports are available per machine.

Erlang effectively handles 10's of 1000s of connections. Have a look at this comparison between Apache and Erlang Yaws.

jldupont
So according to that tuple, there isn't really a limit on the server side outside of memory limitations? I got it wrong then.
erotsppa
@erotsppa: that's what I like about SO: you can always learn new things! Have fun!
jldupont
+1  A: 

You do NOT need a port for each connection. An HTTP server will just use one port (typically 80).

Mark Thornton
Port 80 is a *great* example of this; +1.
Dean J
+1  A: 

Since any relatively widely used language has a reasonably efficient socket library I would go for a language that:

  1. Is efficient in whatever the processing you need to do with the data from the desktops
  2. You are familiar enough (read; most familiar) with to avoid the most common pitfalls / design patterns
Kimvais
A: 

You should be able to do this easily with any framework which is decent. We use Twisted which is good (Assuming you understand python and asynchronous programming), if a little weird to understand.

Asynchronous programming is pretty much a given, because you will probably NOT want to start 600k threads.

MarkR