-
Notifications
You must be signed in to change notification settings - Fork 13
Add redis maxmemmory calculation and change the parameter in the redis.conf accordingly #308
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
base: dev
Are you sure you want to change the base?
Changes from all commits
f7e20c7
3853805
2d8537a
b76fcb0
9d98540
6d13f7b
fd97f31
bab7b35
f1e0b65
a9dc675
777494e
a24b031
20c19b2
71371f0
bc470e8
4e9034a
4a8a781
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,49 @@ | |
| group: root | ||
| mode: "0644" | ||
|
|
||
| # Calculate the Redis maxmemory value automatically when the parameter | ||
| # `redis_maxmemory_bytes` is set to "auto". | ||
| # | ||
| # The calculation uses the following formula: | ||
| # | ||
| # maxmemory = max(redis_maxmemory_min_mb, system_ram × redis_maxmemory_ratio) | ||
| # | ||
| # Where: | ||
| # system_ram -> Total system memory detected by Ansible (in MB) | ||
| # redis_maxmemory_ratio -> Percentage of system memory Redis is allowed to use | ||
| # redis_maxmemory_min_mb -> Minimum memory Redis should be assigned | ||
| # | ||
| # The `max()` function ensures Redis always receives at least the configured | ||
| # minimum memory, even on small systems. | ||
| # | ||
| # The final value is converted from MB to bytes because Redis expects the | ||
| # `maxmemory` configuration parameter to be expressed in bytes. | ||
| # | ||
| # Example (10 GB system): | ||
| # system_ram = 10240 MB | ||
| # ratio = 0.60 | ||
| # result = 6144 MB | ||
| # redis_maxmemory_bytes = 6442450944 | ||
| # | ||
| # If `redis_maxmemory_bytes` is set to a numeric value instead of "auto", | ||
| # this calculation is skipped and the provided value is used directly. | ||
| - name: Calculate Redis maxmemory automatically | ||
| ansible.builtin.set_fact: | ||
| redis_maxmemory_bytes: >- | ||
| {{ | ||
| ( | ||
| [ | ||
| redis_maxmemory_min_mb | int, | ||
| ( | ||
| (ansible_facts.memtotal_mb | int) | ||
| * (redis_maxmemory_ratio | float) | ||
| ) | int | ||
| ] | max | ||
| ) * 1024 * 1024 | ||
| }} | ||
| when: redis_maxmemory_bytes == "auto" | ||
| tags: configure_redis | ||
|
|
||
|
Comment on lines
+38
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need to document the algorithm, either here or in the defaults file. And in the Redis guide.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I documented in the configure-redis.yml take a look.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking we should put this in the redis_guide.md instead. That is a lot for a code comment. |
||
| - name: Use template to generate redis.conf | ||
| ansible.builtin.template: | ||
| src: redis.conf.j2 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.