Redis Memory Optimization
Redis Memory Optimization for rConfig V8
Section titled “Redis Memory Optimization for rConfig V8”After reading this page you can interpret the Redis Settings card on the System Optimization page and set a Redis maxmemory limit that protects the rConfig host. From V8.4.0, rConfig reports Redis memory use and flags an unlimited or undersized limit.
When to use this page
Section titled “When to use this page”Use this page when the Redis Settings card shows Needs Optimization, or when the host runs low on memory during large backup or report runs. Redis holds the job queue, the cache, sessions, and Horizon’s own records, so a large queue backlog shows up here first.
Prerequisites
Section titled “Prerequisites”- rConfig V8.4.0 or later
- Root or sudo access to the server running Redis
- Access to System Settings >> System Optimization in rConfig
- The host’s total RAM, so you can choose a limit from the guidelines below
What does the Redis Settings card show? (V8.4.0+)
Section titled “What does the Redis Settings card show? (V8.4.0+)”Navigate to System Settings >> System Optimization. The Redis Settings card sits below Horizon Settings and contains three rows.
| Setting | What it reports | When it is optimal |
|---|---|---|
redis | Connection status and Redis server version | rConfig can connect to Redis |
used_memory | Memory Redis is using now. The Information column also shows the peak since Redis started and the resident (RSS) size | Usage is under 80% of maxmemory, or under 80% of a quarter of host RAM when no limit is set |
maxmemory | The configured Redis memory limit, or 0 (unlimited) | A limit is set and it is at or above the peak already seen |
The suggested maxmemory value is a quarter of host RAM, rounded to the nearest GB, with a minimum of 512MB. On a 16GB host the card suggests 4GB or more.
If the redis row shows error, rConfig could not read Redis server information. The error message appears in the Information column. Check that Redis is running and that the REDIS_HOST, REDIS_PORT, and REDIS_PASSWORD values in .env are correct.
Why does an unlimited maxmemory need optimization?
Section titled “Why does an unlimited maxmemory need optimization?”With maxmemory set to 0, Redis grows until the host itself runs out of memory. The kernel then kills processes to recover, and the victim is often MariaDB or a Horizon worker rather than Redis. A limit above the observed peak means a runaway queue fails loudly with Redis write errors, while the rest of the host stays up.
Why is my limit flagged when it is already set?
Section titled “Why is my limit flagged when it is already set?”The card flags a limit that is below the used_memory peak since Redis started. A workload of the same size would hit the limit and Redis would refuse writes, so queued jobs would fail. Raise the limit above the peak shown in the Information column.
How to set the Redis maxmemory limit
Section titled “How to set the Redis maxmemory limit”- Note the Suggested Value and the peak memory shown on the Redis Settings card.
- Choose a limit that is at or above the suggested value and comfortably above the peak.
- Open the Redis configuration file:
# RHEL 9 family. On RHEL 8 the file is /etc/redis.confsudo cp /etc/redis/redis.conf /etc/redis/redis.conf.baksudo vi /etc/redis/redis.confsudo cp /etc/redis/redis.conf /etc/redis/redis.conf.baksudo nano /etc/redis/redis.conf-
Find the
maxmemorydirective, uncomment it, and set your chosen limit:maxmemory 4gbmaxmemory-policy noeviction -
Save the file and restart Redis:
sudo systemctl restart redissudo systemctl restart redis-server-
Confirm Redis picked up the new limit:
Terminal window redis-cli CONFIG GET maxmemoryAdd
-a <password>ifREDIS_PASSWORDis set in.env. The value is returned in bytes. -
Return to System Settings >> System Optimization and click Refresh. The
maxmemoryrow shows Optimal once the limit is at or above the peak.
What’s next
Section titled “What’s next”- Horizon Queue Manager: tune worker counts, timeouts, and worker recycling
- PHP Settings: size PHP memory limits alongside Redis
- Database Optimization: size the database buffer pool from the remaining host RAM