tikv/raft-engine

How to control the memory usage

DataDreamer01 opened this issue · 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?

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.

/// Maximum memory bytes allowed for the in-memory index.
/// Effective under the `swap` feature only.
///
/// Default: None
pub memory_limit: Option<ReadableSize>,