Suggestions for Optimizing Redis Memory Settings

15 views
Skip to first unread message

Mohammed Ismail

unread,
Jul 26, 2024, 5:55:14 AM7/26/24
to open...@googlegroups.com
Dear OpenWisp Community,

I hope this message finds you well.

I have been exploring ways to optimize the memory usage of Redis in our OpenWisp deployments. After seeking advice, it was suggested to me that adjusting the `maxmemory-policy` and `maxmemory` settings could help improve performance and stability.

### Suggested Settings

1. **Maxmemory Policy:**
   It was recommended to set the `maxmemory-policy` to `allkeys-lru`. This policy helps manage memory usage by evicting the least recently used (LRU) keys when the memory limit is reached.

   **Configuration:**
   ```plaintext
   maxmemory-policy allkeys-lru
   ```

2. **Maxmemory Size:**
   As for the `maxmemory` setting, it was suggested to configure it based on a percentage of the available RAM on the server. Allocating around 75% of the total RAM for Redis could be a good starting point, while leaving the remaining 25% for other processes and the operating system.

   **Configuration:**
   ```plaintext
   maxmemory <calculated value>
   ```

### Steps to Update Configuration

1. **Edit the Redis Configuration File:**
   Open the Redis configuration file (`/etc/redis/redis.conf`) in a text editor:
   ```bash
   sudo nano /etc/redis/redis.conf
   ```

2. **Update `maxmemory` and `maxmemory-policy`:**
   Add or update the following lines as per your server's RAM percentage allocation:
   ```plaintext
   maxmemory <calculated value>
   maxmemory-policy allkeys-lru
   ```

3. **Save and Exit:**
   Save the changes and exit the text editor. For `nano`, press `Ctrl+X`, then `Y`, and then `Enter`.

4. **Restart Redis Server:**
   Restart the Redis service to apply the changes:
   ```bash
   sudo systemctl restart redis-server
   ```

I hope these suggestions are helpful. If anyone has further insights or alternative recommendations, I would greatly appreciate your input.

Best regards, And thanks ChatGPT 😁

Muhammad

Federico Capoano (nemesisdesign)

unread,
Aug 6, 2024, 11:49:10 AM8/6/24
to OpenWISP
Thanks for the information Muhammad.

I want to add that similar optimizations can be done to pretty much any component used by the OpenWISP application, eg:

- Linux OS settings about networking, memory, swap usage
- Redis
- InfluxDB
- SQL DB (depending on which one you're using)
- Management VPN (depending on which one you're using)

The optimizations will likely depend on your particular case (how much memory, CPU, storage you have available, what latency you have with devices, whether you have multiple machines or just 1, etc).
Google and ChatGPT will help a lot to find more details about how to perform these optimizations.

I hope this helps!

Federico
Reply all
Reply to author
Forward
0 new messages