Skip to content

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

Open
Madias2222 wants to merge 17 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 17 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

…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 +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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I documented in the configure-redis.yml take a look.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Look how I did it for the replica priority.

| `redis_tls_enabled` | Boolean | Flag to enable TLS connections. | `false` |
| `redis_maxmemory_bytes` | Integer | Maximum memory Redis can use (maxmemory). When set to auto, the installer calculates the value from the system RAM using: `maxmemory = max(redis_maxmemory_min_mb, system_ram × redis_maxmemory_ratio)`. If a numeric value is provided, that value (in bytes) is used directly and the automatic calculation is skipped. | `auto` |
| `redis_maxmemory_ratio` | Float | Define how much memory the system will use. Only work if `redis_maxmemory_bytes` is configured as auto. Default value 0.6 means 60%. | `0.60` |
| `redis_maxmemory_bytes` | Integer | This parameter defines the minimum amount of memory Redis is allowed to use, even if the automatic calculation would result in a smaller value. It acts as a safety floor for the maxmemory calculation. | `512` |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be redis_maxmemory_min_mb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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.

I'm thinking we should put this in the redis_guide.md instead. That is a lot for a code comment.
Look how I did it for the replica priority.

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