┌────────────────────────────────────────────────────────────────────┐
        │    ____                                                            │
        │   |  _ \ __ _ _ __ ___                                             │
        │   | |_) / _` | '_ ` _ \                                            │
        │   |  _ < (_| | | | | | |                                           │
        │   |_| \_\__,_|_| |_| |_|                                           │
        │                                                                    │
        │                _   _           _          _   _                    │
        │     ___  _ __ | |_(_)_ __ ___ (_)______ _| |_(_) ___  _ __  ___    │
        │    / _ \| '_ \| __| | '_ ` _ \| |_  / _` | __| |/ _ \| '_ \/ __|   │
        │   | (_) | |_) | |_| | | | | | | |/ / (_| | |_| | (_) | | | \__ \   │
        │    \___/| .__/ \__|_|_| |_| |_|_/___\__,_|\__|_|\___/|_| |_|___/   │
        │         |_|                                                        │
        └────────────────────────────────────────────────────────────────────┘
            

Most of the inmemeory DB utilize ram, meaning optimizing ram utilizations is probably going to decide a lot on what actual behaviour and how things would work. It also decides on how each of the things algorithmically going to affect the performance. (source: https://discuss.aerospike.com/t/how-to-tune-the-linux-kernel-for-memory-performance/4195)

  1. In memory caches

Linux kernel optimizes unused ram by filling it up with caches, this way we ensure that no ram is an unused ram. Overtime kernel fills the ram wit5h caches, as more memory is required by applications and buffers, the kernel goes through the cache memory pages and finds a block large enough to fit the requested malloc, it then frees the memory and allocates it to calling application.

this can improve the performance as deallocation is costly process in comparison to accessing unused memory. Higher latency could be henceforth observed.

The kernel memory cache contains the following:

While not much can be done with dirty cache, the other cached objects can be cleared. This has potentially 2 outcomes. Latency in high-malloc applications, such as Aerospike when storing data in memory, will be reduced. On the other hand, disk access may slow down, as all data will have to be read from disk.

Clearing slab cache on a server can potentially introduce a temporary speed penalty (spike). For this reason, it is not advised to clear caches. Instead, it is preferred to inform the system that a certain amount of RAM should never be occupied by cache.

# clear page cache (above type 2 and 3)
$ echo 1 > /proc/sys/vm/drop_caches

# clear slab cache (above type 4)
$ echo 2 > /proc/sys/vm/drop_caches

# clear page and slab cache (types 2,3,4)
$ echo 3 > /proc/sys/vm/drop_caches