Describe the bug
KeyDB hang and was not responsive for a few seconds when it enabled flash and memory utilization grew to reach maxmemory.
It hang for a few seconds, client read/write were almost blocked and saw 1000+ ms latency. KeyDB flushed multi hundreds of MBs of data at once. maxmemory_policy = allkeys_random
I was testing keydb 6.3.3, on AWS r7gd.xlarge instance, 1 primary 0 replica.
To reproduce
- Spin up a keydb cluster with
flash enabled.
- Write data into the cluster until memory utilization reaches maxmemory limit.
- KeyDB will enter evictions and spend several seconds busy evicting and almost not responsive.
redis-cli commands took seconds to return, client throughput dropped to almost zero.
Expected behavior
Evictions should happen real-time and incrementally and keydb should not spend much time evicting hundreds of MBs of data in a blocking way.
Additional information
I think the problem is from 2 places in the code:
- KeyDB decides to free 5% of memory at once if storage is enabled. Code pointer, and it was from this commit. It means if
maxmemory=10G, keydb will evict 500MB of data all in once which takes 5+ seconds to finish. @JohnSully Any reasons why we want to evict aggressively if storage is enabled? If evictions only involves removing data from memory and not deleting them from rocksdb, I think it should be ok to evict in the same way as non-storage mode?
- Redis has a mechanism to limit the max time spent in a single eviction attempt, controlled by the
maxmemory-eviction-tenacity config. However this exit-early mechanism is disabled when storage is enabled, see code. What will be bad if we chose to exit evictions earlier and have storage enabled?
Describe the bug
KeyDB hang and was not responsive for a few seconds when it enabled flash and memory utilization grew to reach
maxmemory.It hang for a few seconds, client read/write were almost blocked and saw 1000+ ms latency. KeyDB flushed multi hundreds of MBs of data at once.
maxmemory_policy = allkeys_randomI was testing keydb 6.3.3, on AWS r7gd.xlarge instance, 1 primary 0 replica.
To reproduce
flashenabled.redis-clicommands took seconds to return, client throughput dropped to almost zero.Expected behavior
Evictions should happen real-time and incrementally and keydb should not spend much time evicting hundreds of MBs of data in a blocking way.
Additional information
I think the problem is from 2 places in the code:
maxmemory=10G, keydb will evict 500MB of data all in once which takes 5+ seconds to finish. @JohnSully Any reasons why we want to evict aggressively if storage is enabled? If evictions only involves removing data from memory and not deleting them from rocksdb, I think it should be ok to evict in the same way as non-storage mode?maxmemory-eviction-tenacityconfig. However this exit-early mechanism is disabled when storage is enabled, see code. What will be bad if we chose to exit evictions earlier and have storage enabled?