2

I have a java server (1 process) that spawns a thread for every incoming connection. I know there is a file descriptor limit of 1024 that's compiled into the kernel.

Is there a limit to how many socket connections 1 process can support?

2 Answers 2

4

On Linux have a look at /proc/sys/fs/file-max. You can echo your own value into it.

Also make sure you increase the user limits: ulimit -n

On BSD it would be sysctl kern.maxfiles and sysctl kern.maxfilesperproc

Sign up to request clarification or add additional context in comments.

Comments

1

Besides the OS file handle limits mentioned by hroptatyr, you may also want to make sure that you are using a raised value for the connection backlog on the listener socket. This will allow more connections to be queued up before the OS returns "Connection refused", should your server application become momentarily busy and unable to respond to incoming connections quickly enough.

If you're using ServerSocket in Java, you can specify the desired backlog as the argument to the constructor:

ServerSocket server = new ServerSocket(listenPort, 50);

1 Comment

See also a previous question: stackoverflow.com/questions/651665/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.