Swap Disk on Standalone Redis server

97 views
Skip to first unread message

sibzz

unread,
Dec 10, 2022, 12:12:20 PM12/10/22
to Redis DB
Hi,
I have a standalone opensrouce redis setup on a 4 core VM with 50GB. Im trying to optimize the OS as per redis guidelines and I am confused about swap space. Redis Enterprise asks to disable swap and Opensource asks to enable swap and size should be equal to ram. So is Redis Enterprise doing something different and should i just make a swap partition the size of my RAM for my Redis?


Greg Andrews

unread,
Dec 11, 2022, 2:54:26 AM12/11/22
to Redis DB
The open source Redis administration page that recommends swap space explains why:  If you let the host with Redis server run out of memory, your Redis server process will be suddenly killed by the OOM (out-of-memory) handler in the Linux kernel.  This will likely lose some recently written data.  With swap, the process won't be killed, it will only slow down.  This is still a significant issue, but less likely to lose data, and you (the maintainer of the host and the Redis server process) have a chance to fix the issue.

I haven't seen the Enterprise documentation, so I don't know the reasons it recommends no swap.

In both cases, they are recommendations rather than requirements, so you still have control over the configuration of the host you put your Redis server process on.  No matter what your configuration, understanding the behavior of your Redis through testing scenarios (different persistence methods, small amounts of data, medium amounts of data, large amounts of data, a replica loses connection then re-connects and synchronizes the missed writes, etc.), and detailed monitoring of cpu usage, RAM usage, disk usage, and network i/o are crucial.  If you decide to configure swap, also monitor swap i/o.  Employ fault thresholds in order to send alerts but also graph the metrics in order to see trends.

sibzz

unread,
Dec 12, 2022, 3:47:16 PM12/12/22
to Redis DB
Thanks for the response. We actually have data coming in from a pipeline of mongo, kafka, redis so in the worst case of data getting lost we can replay it. I am just trying to optimize the OS settings as much as possible.
here's the link for Redis Enterprise, if you are interested in reading it
Reply all
Reply to author
Forward
0 new messages