elixir-plug / plug_cowboy

Plug adapter for the Cowboy web server
Other
243 stars 48 forks source link

Connection draining is not working 100% as expected #84

Closed hauleth closed 1 year ago

hauleth commented 2 years ago

Current implementation of connection draining works in a way that make it stop creating new connections, but that do not prevent existing connections from accepting and processing new requests. That mean that single client that is connected to the node will prevent it from going down (potentially disrupting any other client that tries to connect to the given node).

I do not know the solution (maybe this issue should be forwarded to Ranch or Cowboy) but maybe there already exists some solution in these deps that would allow handling such problem.

josevalim commented 2 years ago

I cannot reproduce this behaviour. We check for draining every second and we have a shutdown of 5 seconds. After 5 seconds, the draining process is immediately killed and the rest of the shutdown continues. Cowboy/Ranch then propagates exit signals and terminates all children.

Even if that was not the case, I don't think there is a single-rule we can follow here. For example, Phoenix channels could likely be cleanly shutdown by sending a message to all active channels, which is probably a benefit we could add today.

josevalim commented 1 year ago

Closing. Please let us know if there is a way to reproduce it. :)