Repository navigation
[Triage] reuse_port cause connection error on worker reload #3677
methane
started this conversation in
Issue Triage
Replies: 2 comments 1 reply
A little out of topic, but if you implement this feature, it will also be easy to implement separating the ports that each worker process listens to. This is a load balancing technique used in uWSGI. This method, like SO_REUSEPORT, solves both the thundering herd problem of epoll and the load balancing problem at the same time. The difference from SO_REUSEPORT is that load balancing is performed by the reverse proxy rather than the OS kernel. Compared to load balancing using Linux's addr/port 4-tuple, nginx's round robin or least conn algorithm provides a better load balancing and significantly improves 99%-tile latency. |
1 reply
|
This is draft PR via Codex. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Type
Bug Report
Description
In the current implementation, when
reuse_portis enabled, each worker process creates its own new socket.The backlog exists independently for each socket, and connections in the backlog have completed the TCP handshake, so the client may have already sent an (unretryable) HTTP request.
Therefore, when reloading a worker due to a HUP signal or max_requests, connections remaining in the backlog will return "Connection reset by peer" to the client. This is not the expected behavior for a graceful reload.
To avoid this problem, the following methods can be considered:
TTOUsignal.)reuse_port: In sync workers,reuse_porthas no benefits at all. It reduces load balancing performance and makes graceful reload incomplete. For other worker classes, it achieves better load balancing at the cost of incomplete graceful reload.ref: https://lwn.net/Articles/853637/
Steps to Reproduce (for bugs)
client and app code to reproduce: https://gist.github.com/methane/81c517feb5bd5aad59c2fefd31eff6e5
Configuration
Logs / Error Output
All reactions