-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Higher memory usage in pre-0.12 version using HTTP2 compared to h2 branch #1491
Comments
Is this http1 or 2 connections? |
Http2. I checked what was updated after the deployment: hyper from h2 branch to 0.12.0-pre.0 (HEAD), tokio-core 0.1.16 replaced with tokio 0.1.5. So there's quite minimal changes in the deployment, that's why the main culprit I can think of is hyper's new Pool implementation. We'll monitor how it looks like after couple of days, will it settle into some memory usage or keep growing. |
If at all possible, logs from |
Ok, so I'm having this running and logging with tee some hours with production traffic on a test machine. |
First logs, if you need more trace points, please let me know. I could run this longer, but right now the production instances freed some memory, about 10% drop, so at least they're not going to OOM. Just something seems to use more RAM than before... With long keep-alive timeout, reusing connections:
With short keep-alive timeout, creating new connections:
|
The only thing I can think of is that something is holding on a reference to the h2 streams type, and perhaps being stuck in a future that doesn't poll as finished. And then eventually, Apple closes the connection and that triggers the internal h2 streams type to clean itself up. I've pushed some minor clean up to master, along with some clearer logs, if you want to take a look. |
So some notes on the systems we're running with Hyper:
I can try Hyper 0.12 in our h1 system, but I really doubt I see bigger memory usage. |
Oh, one more observation: When we get a jump in RAM usage, it happens when a dead connection gets a big spike of requests. The memory leak is about 60-100M, meaning it's much more than a couple of dead connections (should be about 6 per customer). I'd say something is not cleaned when we race the new connection in the pool, but I'm not sure. |
What determines it is dead? The remote has closed the connection, but the pool hadn't yet cleared out the handle? Or it's reached its expiration and was waiting for the idle interval to clean it up? |
No, I mean I have a keep-alive timeout of 10 minutes, and we have some customers that don't use their connection for the night and then just blast a massive amount of requests, so the pools open new connections and we have like hundreds of thousands of concurrent requests polling for new connections. But like I said in IRC, I don't think this is an issue now really to block 0.12. We don't OOM, the memory is freed eventually and the difference to h2 0.11 branch is just doubled RAM usage, which is maybe not nice but we're talking about some hundreds of megabytes in our case. |
The RAM usage was reduced by several commits before, but this being the best deal and now the usage actually even gets lower when running the system longer. I consider this fixed now. |
For reference, it was noticed that I've open a PR to libstd to fix this easy to miss issue. |
We've been using the h2 branch since the early stages, a couple of days ago upgrading to the master pre-0.12. Something in the master branch uses more RAM than the old version, possibly the new pool. Our use case is many concurrent open connections, keeping them alive and using http2.
Here's an image showing the regression:
The deployment was 16.4.2018 around 11am local time. Also the noticeable growth happens when we hit the keep-alive timeout and get lots of requests through a new connection. So the culprit might be how we dispose the dead connections in the pool.
The text was updated successfully, but these errors were encountered: