Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

high-load http requests cause hanging tcp connection in close wait state #414

Open
so-schen opened this issue Sep 5, 2024 · 10 comments
Open

Comments

@so-schen
Copy link

so-schen commented Sep 5, 2024

Hi,

I have http server running using ntex, and I can see high number of hanging tcp connection
there are hundreds of them..
Note that <ip> is from same ip that making the http requests, I just hide the actual ip with <ip>.

I wonder if there is issue in handling tcp connection close properly in ntex.

State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
CLOSE-WAIT 1 0 172.31.0.9:26000 <ip>:59050
CLOSE-WAIT 1 0 172.31.0.9:26000 <ip>:57932
CLOSE-WAIT 1 0 172.31.0.9:26000 <ip>:54710
CLOSE-WAIT 1 0 172.31.0.9:26000 <ip>:58766
CLOSE-WAIT 966 0 172.31.0.9:26000 <ip>:34230
.....

@fafhrd91
Copy link
Member

fafhrd91 commented Sep 5, 2024

ntex tries to close connection gracefully, it takes some time. also if your app processing request and does not ready/write anything, socket could be kept open.

is number of socket keep growing or is it steady?

@fafhrd91
Copy link
Member

fafhrd91 commented Sep 5, 2024

what runtime do you use?

@so-schen
Copy link
Author

so-schen commented Sep 6, 2024

@fafhrd91, it is growing along with time
I use ntex tokio runtime
in about 2h test, I see ~950 connection with CLOSE WAIT there

@so-schen
Copy link
Author

so-schen commented Sep 6, 2024

I can see from the output, the Recv queue mostly have 1 byte left

@fafhrd91
Copy link
Member

fafhrd91 commented Sep 7, 2024

could you try ntex-tokio v0.5.1

@gftea
Copy link

gftea commented Sep 8, 2024

OK I WILL do a cargo update.

@so-schen
Copy link
Author

so-schen commented Sep 9, 2024

upgrade to 0.5.1 does not help much, also once it gets into high load, it seems can not recover and take any requests

error return
Query transaction status failed: Request Error: reqwest::Error { kind: Request, url: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(27000), path: "/rpc/v1/transactions/19c62f80407af594bcd199d4b4a499f0fe9c8358d8ac4480658aa30daec45661", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 49, kind: AddrNotAvailable, message: "Can't assign requested address" })) } Query transaction status failed: Request Error: reqwest::Error { kind: Request, url: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("localhost")), port: Some(27000), path: "/rpc/v1/transactions/7ad47ffae0eca398bc954a5ba3d375846d4395997230a6da0e4e3877ed63a2f6", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 49, kind: AddrNotAvailable, message: "Can't assign requested address" })) }

@fafhrd91
Copy link
Member

how many concurrent requests do you run?

@so-schen
Copy link
Author

so-schen commented Sep 10, 2024

10K, with 20 workers on 10 core M2 machine

@fafhrd91
Copy link
Member

are you sure that your handler completes request processing? ntex holds socket while handler is in process.

you also beed to increase number of file descriptors on osx, it is not very high by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants