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

cowboy_http holds onto memory with long-lived connections #1664

Open
rlipscombe opened this issue Jan 21, 2025 · 2 comments
Open

cowboy_http holds onto memory with long-lived connections #1664

rlipscombe opened this issue Jan 21, 2025 · 2 comments
Milestone

Comments

@rlipscombe
Copy link

rlipscombe commented Jan 21, 2025

We noticed a problem last week when using long-lived client connections: The process running cowboy_http:loop/1 doesn't GC after sending the response body to the client.

In some cases, this can result in holding on to (e.g.) 10MiB or so of garbage before either the client sends another request, or reaching idle_timeout.

Would it be possible to trigger a GC after the response body has been sent? This would be similar to gen_server's hibernate, or the ssl application's hibernate_after option.

Obviously, we could set idle_timeout more aggressively, but that closes the connection, which seems to defeat the purpose of long-lived connections.

I can reproduce this against one of our internal cowboy-using applications by using some relatively simple gun client code. My example code uses HTTP/1.x, but we've seen this with (I think) a Go client using HTTP/2.

(cowboy 2.9.0, ranch 1.8.0)

@essen
Copy link
Member

essen commented Jan 21, 2025

We can introduce a way to hibernate by sending it a message (via cowboy_req:cast) or similar.

@essen
Copy link
Member

essen commented Jan 21, 2025

I guess it could hibernate automatically via an option as well after all messages if you don't expect much to happen. Option could be set both at startup and dynamically.

@essen essen added this to the 2.13.0 milestone Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants