caddy: Memory leaks
I have a minimal config, and I constantly observe leaking memory. I used version 2.5.0 and later upgrated to 2.7, but this didn’t help
{$GRAFANA_DOMAIN} {
reverse_proxy grafana:3000
}
{$COLLECTOR_DOMAIN} {
reverse_proxy myapp:8080
}
Caddy is deployed via docker compose, here’s a snippet:
caddy:
restart: unless-stopped
image: caddy:2.7
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./ssl:/myapp/ssl
- caddy_data:/data
ports:
- 80:80
- 443:443
networks:
default:
aliases:
- ${GRAFANA_DOMAIN}
- ${COLLECTOR_DOMAIN}
environment:
GRAFANA_DOMAIN: ${GRAFANA_DOMAIN}
COLLECTOR_DOMAIN: ${COLLECTOR_DOMAIN}
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17 (8 by maintainers)
Jetty follows the HTTP/1.0 (RFC1945) and HTTP/1.1 (RFC9112) specs.
If the client says HTTP/1.0 in its request header …
Connection: keep-aliverequest header.Connection: closewith a HTTP/1.0 request is a no-op as the valuecloseis not recognized by the HTTP/1.0 spec.If the client says HTTP/1.1 in its request header …
Connection: closerequest header.Connection: keep-alivewith a HTTP/1.1 request is a no-op as the valuekeep-aliveis not recognized by the HTTP/1.1 spec.If you want to see a more comprehensive set of tests related to the
Connectionheader in Jetty (not limited to justcloseandkeep-alivevalues), see the testcases.https://github.com/jetty/jetty.project/blob/661546ecffbd2f2d8f1cf7b5ebebec8e4f06549e/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java#L1593-L1689
That shows the 4 piece of information Jetty uses to determine connection behavior. (the user-agent request HTTP spec version, the user-agent request Connection header value, the application specified response Connection header value, and the user-agent seen response Connection header value)
Has anyone been able to replicate this problem? Does it happen with 2.8.4?
What are your clients / traffic patterns like?
Try setting some timeouts: https://caddyserver.com/docs/caddyfile/options#timeouts
The majority of the (few) goroutines that show up in the profiles are waiting for reads.
Is it possible that the backend isn’t closing connections? What is
myapp:8080serving? How can we reproduce it?If you could please collect a memory and goroutine profile that would help answer some questions: https://caddyserver.com/docs/profiling
Thank you