I ran c1000k on my CentOS 7.2 machine and it told me

connections: 921
error: Too many open files

Because of this I changed my /etc/sysctl.conf to contain this:

fs.file-max = 2097152

But even after a reboot I still run into the same limit. ulimit -Sn and ulimit -Hn print 1024 respectively 4096.


The effective (soft) 1024 descriptor ulimit is a total for the process, including descriptors that are used for non-connection purposes. Apparently that process is using about 100 descriptors for other things, leaving only 921 for connections. lsof -p <process-id> will show you how the descriptors are being used.

To allow more descriptors, raise the soft limit before launching the process. If you're running it from bash, that would be:

    ulimit -Sn 2048

to raise it to 2048 for future commands. To raise the soft limit to whatever the allowed maximum (the hard limit, in this case 4096) is you can do:

    ulimit -Sn unlimited

If you only want the elevated limit to apply to one command, and not to other future commands, raise the limit in a subshell:

    (ulimit -Sn 2048 ; c1000k)

If you want to go beyond your current hard limit of 4096 descriptors then you can run your test from a user account that has sufficient privilege to raise the hard limit, or you can change the initial hard and soft ulimit values set at login time for your user account by modifying /etc/security/limits.conf or (better) by adding files in /etc/security.d. See the comments in the limits.conf file or run man limits.conf for details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.