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

Consider an option to set UNICORN_SIDEKIQ_MAX_RSS environment variable #306

Closed
kot0dama opened this issue Dec 5, 2024 · 5 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@kot0dama
Copy link
Contributor

kot0dama commented Dec 5, 2024

Enhancement Proposal

Hi,

Our Discourse instances are frequently failing health checks. After digging up the root cause, it would seem Sidekiq memory usage would be (at least one of) the culprit:

Sidekiq is consuming too much memory (using: 597.82M) for 'discourse.ubuntu.com', restarting
Booting Sidekiq 6.5.12 with Sidekiq::RedisConnection::RedisAdapter options {:host=>"REDACTED", :port=>6379, :namespace=>"sidekiq"}
[...]
Detected rogue Sidekiq pid 418761 mem 588632064, killing
Booting Sidekiq 6.5.12 with Sidekiq::RedisConnection::RedisAdapter options {:host=>"REDACTED", :port=>6379, :namespace=>"sidekiq"}

This is a well-known issue in the community:
https://meta.discourse.org/t/sidekiq-is-consuming-too-much-memory/280933
https://meta.discourse.org/t/sidekiq-is-consuming-too-much-memory-restarting/48395/36

The workaround is to up the maximum memory through setting the UNICORN_SIDEKIQ_MAX_RSS environment variable to 1000, thus allowing 1GB instead of 500MB default per:

config/unicorn.conf.rb:
        [ENV["UNICORN_SIDEKIQ_MAX_RSS"].to_i, 500].max.megabytes

A workaround this issue is to manually set the environment variable in the deployment, by updating the statefulset with:

--- discourse-k8s.ss.yaml.orig  2024-12-05 02:45:56.429989147 +0000
+++ discourse-k8s.ss.yaml       2024-12-05 02:38:31.271628120 +0000
@@ -115,6 +115,8 @@
           value: discourse
         - name: PEBBLE_SOCKET
           value: /charm/container/pebble.socket
+        - name: UNICORN_SIDEKIQ_MAX_RSS
+          value: "1000"
         image: registry.jujucharms.com/charm/1do4bht9nkx2kuk2thi94lw9kzlgiytu42u4r/discourse-image@sha256:454c0dcf2ab0707869ef1f59bf3692668af0b45b9e10fbfe35cfd89554ba6c88
         imagePullPolicy: IfNotPresent
         livenessProbe:

Would it be possible to add a charm option to achieve this behavior?
Thank you!

@alithethird alithethird self-assigned this Dec 5, 2024
@alithethird alithethird added the enhancement New feature or request label Dec 5, 2024
@hloeung
Copy link

hloeung commented Dec 9, 2024

@alithethird, can we land a quick fix to bump this to 1000 per @kot0dama's post for now? Then think about how to make it tunable at a later stage.

@alithethird
Copy link
Collaborator

Created the PR. It is configurable and set to 1000 in default.

@hloeung
Copy link

hloeung commented Dec 9, 2024

Nice one!

@alithethird
Copy link
Collaborator

Merged the feature.

@kot0dama
Copy link
Contributor Author

kot0dama commented Dec 9, 2024

Wonderful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants