Add redis maxmemmory calculation and change the parameter in the redis.conf accordingly #308
Open
Madias2222 wants to merge 14 commits intoitential:devfrom
Open
Add redis maxmemmory calculation and change the parameter in the redis.conf accordingly #308Madias2222 wants to merge 14 commits intoitential:devfrom
Madias2222 wants to merge 14 commits intoitential:devfrom
Conversation
Contributor
Madias2222
commented
Feb 26, 2026
- Add redis maxmemmory calculation
- Add in redis.conf the maxmemmory accordingly with the base memory of the machine
Removed unnecessary 'become: true' directives from various tasks in the configure-mongodb-numa.yml file.
kvelarde-itential
requested changes
Feb 27, 2026
roles/redis/defaults/main/redis.yml
Outdated
|
|
||
| # Optional hard override (bytes) | ||
| # If set (>0), this value is used and auto-calculation is skipped | ||
| redis_maxmemory_bytes: 0 |
Contributor
There was a problem hiding this comment.
For consistency, can we change this to:
Suggested change
| redis_maxmemory_bytes: 0 | |
| redis_maxmemory_bytes: auto |
That is how we are doing it for the redis_replica_priority variable in v4.
| mode: "0644" | ||
|
|
||
| - name: Calculate Redis maxmemory (dedicated node) | ||
| when: (redis_maxmemory_bytes | default(0) | int) == 0 |
Contributor
There was a problem hiding this comment.
For consistency, move the when clause and put it under the set_fact call. The when clause should only be after the name for blocks.
…of the codebase. Also added a new variable for maxmemory in bytes to be used in the redis.conf template.
kvelarde-itential
requested changes
Mar 3, 2026
Comment on lines
+64
to
+73
|
|
||
| # Redis memory sizing defaults (dedicated Redis node) | ||
|
|
||
| # If set to "auto", maxmemory is calculated from system RAM. | ||
| # If set to a number (bytes), that value is used verbatim. | ||
| redis_maxmemory_bytes: auto | ||
|
|
||
| # Used only when redis_maxmemory_bytes == "auto" | ||
| redis_maxmemory_ratio: 0.60 | ||
| redis_maxmemory_min_mb: 512 |
Contributor
There was a problem hiding this comment.
These need to be added to the Redis guide.
Comment on lines
+12
to
+28
| - 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 | ||
|
|
Contributor
There was a problem hiding this comment.
We probably need to document the algorithm, either here or in the defaults file. And in the Redis guide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.