Nginx--nginx:accept failed 24:too many open files

Source: Internet
Author: User
Reprint Please specify source: http://blog.csdn.net/l1028386804/article/details/51425325

There is a very high number of server access, using Nginx, the error log keeps reporting the following error:

2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)
2016/05/16 08:53:49 [alert] 13576#0:accept () failed (24:too many open files)

Workaround:

Ulimit-n in centos5.3 is 1024, 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 will solve the problem of too many nginx connections, nginx can support high concurrency. < also modify Nginx>

In addition, Ulimit-n also affects the number of concurrent connections to MySQL. Raise him up, and it will improve MySQL concurrency.

Note: The ulimit-n 2048 modification is valid only for the current shell, and fails after exiting.

Modify method

To make the value of the modified Ulimits permanent, you must modify the configuration document, you can put the Ulimit Modify command into the/etc/profile inside, this method is really inconvenient,

One more way is to modify /etc/security/limits.conf

/etc/security/limits.conf format, the file contains very detailed comments, such as

* Soft Nofile 655360

* Hard Nofile 655360

The asterisk represents the global, soft is software, hard is hardware, nofile refers to the number of open files here.

Add the above two lines of content to the limits.conf file.

Also, to make the limits.conf file configuration effective, you must make sure that the pam_limits.so file is added to the startup file. The view/etc/pam.d/login file has:

Session required/lib/security/pam_limits.so

You can see the effect by logging in again, and you can see it through ulimit-n.

The above describes the Nginx--nginx:accept failed 24:too Many open files, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.