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

Websocket with compression enabled causes high memory usage #5553

Open
andrein opened this issue Jun 17, 2024 · 7 comments
Open

Websocket with compression enabled causes high memory usage #5553

andrein opened this issue Jun 17, 2024 · 7 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@andrein
Copy link

andrein commented Jun 17, 2024

Observed behavior

When upgrading from nats 2.9.20 (using helm chart 0.19.17) to 2.10.16 (using helm chart 1.1.12) we noticed a 10x memory usage increase on our cluster.

We tracked this down to the new chart enabling websocket compression by default.

The cluster has ~60k clients, most of them connecting over websockets. Memory usage increased from ~3GB/node to 30+GB/node.

Expected behavior

Not sure how to answer this, I would've expected some impact, but 10x memory usage caught us by surprise.

Server and client version

2.9.20 and 2.10.16 are affected, probably others too.

Host environment

Cluster running on Kubernetes using containerd.

Steps to reproduce

  1. Enable websocket compression on a busy nats cluster
  2. Watch memory usage explode
@andrein andrein added the defect Suspected defect such as a bug or regression label Jun 17, 2024
@andrein
Copy link
Author

andrein commented Jun 17, 2024

Adding the profiles that helped us track down this issue: profiles.zip

Seems this is a know issue golang/go#32371

@derekcollison
Copy link
Member

What server version was used for the profiles?

@andrein
Copy link
Author

andrein commented Jun 17, 2024

Hi @derekcollison, the profiles were done on the nats:2.10.16-alpine image.

@derekcollison
Copy link
Member

The server does not default to compression on for websockets but the helm chart does. We are going to change that, compression should be opt-in. /cc @caleblloyd

@caleblloyd
Copy link
Contributor

PR was opened yesterday: nats-io/k8s#912

@andrein
Copy link
Author

andrein commented Jun 18, 2024

I see that https://github.com/klauspost/compress is mentioned as an alternative in the upstream ticket, and it's already a dependency of nats-server. Would it be worth changing the implementation for the websocket compression?

@caleblloyd
Copy link
Contributor

Released: https://github.com/nats-io/k8s/releases/tag/nats-1.2.0

Anything else to do here or we can close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
3 participants