java server's ability to accept a huge number of simultaneous connections

S

shanky001

I would appreciate some suggestions or pointers as to where to look
for, to increase a java server's ability to accept a huge number of
simultaneous connections.

Using the backlog feature in java's ServerSocket or NIO hasn't solved
my problem.

Details:
I have java socket server which accepts connections from clients. These
are persistent connections. I also have a thread pool in the server to
read/write to the clients
I did a performance test. I created 100 connections from 8 machines and
continuously read/write data using the connections.
I have problems creating lot of connections. even though the client
retries 50 times before it gives up.
Out of the attempted 800 client connections 300 seem to fail.

I am using the backlog feature in java's ServerSocket. It is set to
400.

My server is Windows 2000. Is there a setting to increase the number of
sockets for an application? Am I hitting some OS socket limit?

I have tried using NIO too. It doesn't seem to work.
 
S

Steve W. Jackson

I would appreciate some suggestions or pointers as to where to look
for, to increase a java server's ability to accept a huge number of
simultaneous connections.

Using the backlog feature in java's ServerSocket or NIO hasn't solved
my problem.

Details:
I have java socket server which accepts connections from clients. These
are persistent connections. I also have a thread pool in the server to
read/write to the clients
I did a performance test. I created 100 connections from 8 machines and
continuously read/write data using the connections.
I have problems creating lot of connections. even though the client
retries 50 times before it gives up.
Out of the attempted 800 client connections 300 seem to fail.

I am using the backlog feature in java's ServerSocket. It is set to
400.

My server is Windows 2000. Is there a setting to increase the number of
sockets for an application? Am I hitting some OS socket limit?

I have tried using NIO too. It doesn't seem to work.

The backlog indicates the size of the queue of waiting connections. I'd
think that 400 should be more than large enough for most uses. But the
real question is probably what you're doing with the connections when
they arrive. Are you handing them off *immediately* to some other
thread, thereby allowing the thread with the ServerSocket to check for
the next one, etc? The longer it takes to hand it off and come back to
the accept() call, the more connection requests will get dumped.

= Steve =
 
S

shanky001

Steve,

Thanks a lot. That suggestion helped. Though the connections were being
handled by a different thread (eg. SocketHandler), the whole process
was taking a few milliseconds. I just changed it so that, the
connection is immediately dumped into a queue and there is a separate
thread that takes connections of the queue and creates the actual
socket handling thread (SocketHandler).

Thanks once again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top