-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
High WebSocket memory usage in Jetty 10 #6696
Comments
I'm a bit confused. Are you using 10.0.6 (public release)? or 10.0.7-SNAPSHOT (from snapshots repo)? or are you building and testing the |
Hi, @joakime! As far as I can tell, the issue affects all versions on the |
Interestingly enough the test at https://github.com/SerCeMan/jetty10-memory-test fails on Either way we can cleanup the |
…fter upgrade Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
…adeRequest Issue #6696 - don't keep Request object in the WebSocketNegotiation after upgrade
Closing as this seems to be fixed in |
Jetty version(s)
10.0.6
Java version/vendor
(use: java -version)
OS type/version
Mac/Ubuntu
Description
Hi, Jetty maintainers!
I got back to trying to reproduce #6328. While I wasn't able to reproduce the referenced issue yet, I seem to have found the main issue that we experienced with the upgrade to Jetty 10, which was related to memory usage.
Compared to Jetty 9, the memory usage per open WebSocket connection has increased significantly, making it problematic for using when servers maintain a large number of connections. I've put together a minimal reproducer project here: jetty10-memory-test, which implements two minimal WebSocket echo servers on Jetty 9, and Jetty 10, both run with
Xmx1G
and a test that opens 10k connections.When running the tests against a bare-bones jetty 9 server, the memory usage does not increase much.
However, when running the tests against Jetty 10, the memory usage grows significantly, and the server dies with an out of memory error after reaching ~9k connections.
The OOM heapdump seems to match the heapdump from the load tests which discovered the issue, and it hints at
org.eclipse.jetty.websocket.core.server.internal.RFC6455Negotiation
.A heap dump can also be taken by uncommenting a line in
start.sh
. The heapdump points at the fact thatRFC6455Negotiation
is referenced from a number of places throughupgradeRequest
andupgradeResponse
.When looking at a single instance of
RFC6455Negotiation
, one can notice that the biggest memory consumer is thebaseRequest
.One potential fix would be to set
baseRequest
tonull
after the request upgrade, for instance at the end oforg.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker#upgradeRequest
. As far as I can tell, it's the only reference. However, I haven't tested the hypothesis. I'm not sure if that's the best solution, but happy to raise a PR if it sounds good to you. Thanks!How to reproduce?
I've put together a README that describes running the tests here: https://github.com/SerCeMan/jetty10-memory-test.
The text was updated successfully, but these errors were encountered: