A large number of CLOSE_WAIT problems on the server side

A large number of CLOSE_WAIT problems on the server.md

### Phenomenon description:

After the server uses the quartz framework, when the jetty container is first started, the request is normal. After a few requests are completed, the client keeps making requests on some Mac machines, but The information returned to the client is abnormal, the server does not receive the request at all, or the execution of the code received is very slow
. Use the command lsof -i:8080 to check the number of processes, and find that a large number of processes exist, and the status is CLOSE_WAIT; The number of processes increases while executing client requests, but then shuts down.

CLOSE_WAIT: The client closes the socket connection, sends a FIN message, and the server also sends an ACK message. At this time, the client is in the FIN_WAIT_2 state, and the server is in the CLOSE_WAIT state. The reason for the problem is that the server did not send the second FIN. caused by the message.

Possible reasons for TCP requests:

- mongo
- redis
- mq
- mysql

Because quartz introduces a new mysql connection, it is estimated that the connection exceeds the upper limit

#### Solution

- the processList table of the msyql database, set the global timeout to 100ms , Get verified, problem solved
- set connection pool, and idle connection release time

### Reference website

[Solution of a large number of CLOSE_WAIT problems on the server](http://www.liuhaihua.cn/archives/45802.html)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326664276&siteId=291194637