Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to determine the OPTIMAL number of connections accepted by the server socket

Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Socket soc = null;
while((sock = serversocket.accept()) != null){
//create worker thread to handle job

if I simutaneously create 1000 client socket. I get connection refused exceptions on a few of them since the server can only hanlde a certain number of connections. Every time the server accept, it will create a new socket with different port number to communicate with the client socket. If the server running out of ports, the client will get connection refused. I guess the number of connections granted by the server is depended on the number of available ports and how long the server will take to fulfill a job (so that the unavailable socket can be available again to accept new client connection). Is there a way to determine the optimal number of connection a socket server can handle at a given time?
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trial & error is about all that comes to mind. Of course we call that Stress & Performance Testing when talking to the boss. Your OS may document some max number or even let you configure it. But there will be enough variables - other things running on the machine, how many threads the OS can manage before it thrashes, what other resources you use while servicing a request - that coming up with a number will be hard.
They weren't very bright, but they were very, very big. Ad contrast:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic