Skip to content

Add redis maxmemmory calculation and change the parameter in the redis.conf accordingly #308

Open
Madias2222 wants to merge 14 commits intoitential:devfrom
Madias2222:redis-maxmemmory
Open

Add redis maxmemmory calculation and change the parameter in the redis.conf accordingly #308
Madias2222 wants to merge 14 commits intoitential:devfrom
Madias2222:redis-maxmemmory

Conversation

@Madias2222
Copy link
Contributor

  • Add redis maxmemmory calculation
  • Add in redis.conf the maxmemmory accordingly with the base memory of the machine


# Optional hard override (bytes)
# If set (>0), this value is used and auto-calculation is skipped
redis_maxmemory_bytes: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

mode: "0644"

- name: Calculate Redis maxmemory (dedicated node)
when: (redis_maxmemory_bytes | default(0) | int) == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

…of the codebase. Also added a new variable for maxmemory in bytes to be used in the redis.conf template.
Copy link
Contributor Author

@Madias2222 Madias2222 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants