raft-engine icon indicating copy to clipboard operation
raft-engine copied to clipboard

How to control the memory usage

Open DataDreamer01 opened this issue 2 years ago • 1 comments

From the design of Raft Engine, all keys and corresponding file locations will be cached in memory, so what happens if there are too many keys or insufficient memory to cache all keys?

DataDreamer01 avatar May 09 '23 16:05 DataDreamer01

Raft Engine is designed to hold a moderate amount of Raft logs (around 10GB). The index size for 10GB data set is quite small (around 100MB), so it shouldn't be a problem in most cases.

Certainly it is still possible that index grows too large. We have a memory-limit configuration for that. When the used memory exceeds the config, Raft Engine will start swapping out in-memory data to disk. Unfortunately the swapping will cause a severe drop in performance. It should only be a last resort when user application fails to control log size.

https://github.com/tikv/raft-engine/blob/39f4db451295dbd8b30db4f94f220182c2c65be9/src/config.rs#L91-L95

tabokie avatar May 10 '23 03:05 tabokie