Thursday
Sep102009
How to handle so many socket connection

In my application, we receive request from many clients through socket.Client can connect to this socket and send data. this connection has to be maintained for indefinite hours. Client are continously sending data . There are so many clients simultaneously to server. I am using java to make application which listen on port and do processing on data. How can i scale this socket overhead. Is there any product which helps in maintening socket .
Reader Comments (3)
I I' I'm thinking you want the comet feature, so here if you use Java may JBoss_Netty is your solutions.
Shall we assume TCP here? Can you rather employ a queue with an HTTP callback? Conversely, have you considered UDP?
First, you should use a 64-bit platform. Second, if there are many idle connections you might be better off separating the TCP processing part into a separate C program, which may handle TCP connections on one side and push the data using one socket to the Java program. I have seen dedicated daemons written in C handling many hundred thousands TCP connections on 64-bit Linux. Send me an e-mail if you'd like to talk more about this solution.