Redis BGSAVE fork fails with 'fork: Cannot allocate memory' on 512MB cloud VM during snapshot
Environment
Redis 6.2.13 running on a 512 MB single-vCPU cloud VM (Ubuntu 20.04), dataset ~350 MB of keys, RDB snapshots configured (save 900 1), swap disabled by default, vm.overcommit_memory=0.
Symptoms
Periodic RDB snapshots trigger a server pause; clients get slow responses and eventually Redis is killed by OOM killer with kernel log showing 'oom_reaper' and 'Killed process <redis-server> (forked)'. BGSAVE fails with 'fork: Cannot allocate memory' in redis log.
Observations
free -m shows <20 MB free before BGSAVE; top shows Redis rss ~360 MB; no swap configured; redis-cli INFO persistence shows last_bgsave_status = err. Attempts to run BGSAVE manually fail with same error. System logs show kernel out-of-memory events at time of BGSAVE attempts.
Already attempted
Increased save interval to reduce frequency (didn't help for immediate BGSAVE attempts), set vm.overcommit_memory=1 temporarily, enabled appendonly yes (made memory worse), restarted Redis to clear memory but dataset size remained large. Created a 1GB swap file and observed BGSAVE completes occasionally but at cost of extreme I/O and long pause.
Question
How can I get reliable persistence from Redis on a constrained 512 MB VM without risking the server being OOM-killed every time BGSAVE runs, and what configuration changes or architecture changes avoid this fork-memory doubling problem?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags