Home > Back-end > Project HttpClient adjust trilateral interface deplete fd problems caused by the timeout
Project HttpClient adjust trilateral interface deplete fd problems caused by the timeout
Time:12-02
I have a Java web project, because some requirements on business, must provide interface to external and internal is through a third-party service to satisfy demand, overall is a transit query, can, of course, from the project I review the log, convenient statistics, such as
But the problem is coming, the third party service because of various reasons, there are a few slow interface, often more than 1 s, sometimes even a few seconds to return, on-line has happened a few times after the accident, the reason is the client a large number of requests to the service, I again to passthrough the past, because the return is too slow, I have run out of fd and lead to feign death, although process is still there, but the request was not to go, a problem, check the network connection, CLOSE_WAIT up to tens of thousands, only restart the application rescue, but it is a ticking time bomb, who also don't know which day is hanged,
Currently use network tools is old kao of HttpClient encapsulation based project, after the normal request releases resources, take the initiative to close off abroad several times after the accident, each time, set the timeout time shorter, the original is 10 seconds, and now has been changed to 3 seconds,
But feel so always take temporary solution not effect a permanent cure, if the three interfaces is really slow, even a successful request each block in a few seconds, the client request if increases, can also lead to handle to Linux system running out, have any good solution? Alternative to HttpClient call?
CodePudding user response:
Whether can use HttpClient tools and use of the tools to business information code posted, speculation is HttpClient is not properly release the FD Linux server connection deduced
CodePudding user response:
And HttpClient version said
CodePudding user response:
1. If the call interface is iterative invocation pattern, you provide the batch interface, it can be each other's repeated requests to control access to a third party by oneself, benefit is completely controllable, can according to the actual situation of this pile of data calls or into small batch multi-thread calls, 2. Add machines, distributed deployment, 3. An asynchronous callback mode, this is just a way of thinking, character does not meet your business is not clear,
CodePudding user response:
And don't know how to use your httpclient, and didn't add the connection pool