Processing of too Many Open files in Linux system

Source: Internet
Author: User
Tags ack socket linux

Today, a Linux server has been reporting the exception of too Many Open files, causing the system to fail the network request, restart the application container and return to normal.

Found the server connection monitoring at that time, found that the close_wait state of the connection has been elevated, up to 10k after the application of the error. Because the maximum number of connections we set for Linux is 10240.

Stroll around the blog park and find the following description

If our server TCP connection is in the close_wait state, it means that the socket is closed passively!

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Because if the client side takes the initiative to disconnect the current connection, then both sides will need four packet to close the TCP connection:

Client---> FIN---> Server

Client <---ACK <---Server

The client side is in the fin_wait_2 state, and the server program is in the Close_wait state.

Client <---FIN <---Server

The Server sends the fin to the client,server to be placed in the Last_ack state.

Client---> ACK---> Server (This step is not done)

The client responds to the ACK, then the server's socket is actually placed in the closed state.

The Server program is in a close_wait state, not a last_ack state, indicating that the fin has not been sent to the client, so there may be a lot of data to send or something else to do before closing the connection, causing the fin packet to not be sent.

Usually, a close_wait will last for at least 2 hours.

Understand this situation, can be positioned to apply the reason why so many close_wait state, is because the receiver has been sent over the notice, is a partner in the notification after sending the ACK response to us, resulting in a close_wait state backlog, The maximum number of system settings is exceeded and no more connections can be established.

Shorten this time by modifying the parameters of TCP/IP: Modifying the tcp_keepalive_* series parameters helps solve this problem.

Author: Cnblogs Week tadpole

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.