The ulimit-n in centos5.3 is 1024, and when the number of nginx connections exceeds 1024, the following error occurs in Error.log:
[Alert] 12766#0:accept () failed (24:too many open files)
Use Ulimit-n 655350 to set the number of open files large enough, while modifying nginx.conf, add Worker_rlimit_nofile 655350; (same level as Error_log)
This solves the problem of too many nginx connections, and nginx can support high concurrency.
In addition, Ulimit-n will also affect the number of concurrent connections to MySQL. Raise him up, also improve the MySQL concurrency.
Note: The ulimit-n 2048 modification is only valid for the current shell and expires after exiting.
Modify Method
To make the value of a modified ulimits permanent, you must modify the configuration document, and you can put the Ulimit modification command into/etc/profile, which is inconvenient.
Another way is to modify the/etc/sysctl.conf.
/etc/security/limits.conf format, there are very detailed comments in the file, such as
* Soft Nofile 655360
* Hard Nofile 655360
The asterisk represents the global, soft for software, hard for hardware, nofile for <type> This refers to the number of open files.
Add the above two lines of content to the limits.conf file.
In addition, to make the limits.conf file configuration effective , you must ensure that the pam_limits.so file is added to the startup file. See the/etc/pam.d/login file for:
Session required/lib/security/pam_limits.so
You can see the effect after you have modified the login, you can see it through ulimit-n.
Reference:
http://gfllove.blog.163.com/blog/static/1515027200923010653628/
http://loamy.javaeye.com/blog/380150