MemKeyDB documentation


MemKeyDB requires Linux kernel 5.1 or higher. This version introduces KMEM DAX feature which is used to expose PMem device as a system-ram.

Information how to configure KMEM DAX are available on this blog post.

Building from sources

For automatic recognition of KMEM DAX NUMA node libdaxctl-devel (v66 or later) is necessary to be installed in your system.

MemKeyDB sources are available on github.

Libmemkind is used as a submodule so it need to initialized with:

% git submodule init
% git submodule update

Building with Memkind as an allocator is done by:

% make MALLOC=memkind

Configuration parameters

The application has additional configuration parameters related to the handling of two types of memories.

The main one is the ability to define Memory Allocation Policy. It allow modifying mechanism how heap memory is allocated via zmalloc() function calls. It can target DRAM, Persistent Memory or both. In general, bigger allocations should be stored in Persistent Memory which provides a higher capacity, while smaller and more frequently used should be stored in DRAM.

Memory Allocation Policy is defined in redis.conf or via command line argument:


  • only-dram: use only DRAM – do not use Persistent Memory
  • only-pmem: use only Persistent Memory – do not use DRAM
  • threshold: use both Persistent Memory and DRAM – use threshold described by static-threshold
  • ratio: use both Persistent Memory and DRAM – use ratio described by dram-pmem-ratio

Parameters used when THRESHOLD policy is selected:

When Threshold policy is selected, application will check static-threshold parameter. Allocation of the size smaller than this threshold goes to DRAM. Allocation of the size equal or bigger than this threshold goes to Persistent Memory. Parameter can be modified when application is running using CONFIG SET.


Minimum allocation size measured in bytes which goes to Persistent Memory
static-threshold 64

Parameters used when RATIO policy is selected:

Application allocates part of data in DRAM and part in Persistent Memory based on value of internal dynamic threshold and dram-pmem-ratio. Application monitors DRAM and Persistent Memory utilization and modifies value of internal dynamic threshold by increasing or decreasing it to achieve expected dram-pmem-ratio.

The syntax of dram-pmem-ratio directive is the following:

dram-pmem-ratio <dram_value> <pmem_value>

Expected proportion of memory placement between DRAM and Persistent Memory. Real DRAM:PMEM ratio depends on workload and its variability. dram_value and pmem_value are values from range <1,INT_MAX>


Place 25% of all memory in DRAM and 75% in Persistent Memory
dram-pmem-ratio 1 3

Internal dynamic threshold have minimum possible limit defined by dynamic-threshold-min and maximum possible limit defined by dynamic-threshold-max. They should be adapted to the size of the objects handled by the database.

Initial value of dynamic threshold
initial-dynamic-threshold 64

Minimum value of dynamic threshold. The use of lower values for this parameter may be required when the database handles a large number of objects of small size and the target ratio is set to allocate mainly from PMem, e.g. when the majority of objects will be smaller than 64 bytes a dram-pmem-ratio is set to 1-8.
dynamic-threshold-min 24

Maximum value of dynamic threshold
dynamic-threshold-max 10000

An additional parameter determines how often the application should monitor the current ratio and adjust the internal dynamic threshold.

DRAM/PMem ratio period measured in miliseconds
memory-ratio-check-period 100

Common parameters :

The main hashtable may be one large allocation. In a situation where the base consists mainly of a large number of small keys and values, the allocation of the main hashtable affects significantly the PMem/DRAM ratio. On the other hand, as it is very often used for writing and reading, so it should be placed in DRAM. The following option allows you to choose where you want to allocate the hashtable to depending on your needs.

hashtable-on-dram yes/no – Keep hashtable structure on DRAM or on PMem

Additional INFO statistics

With the INFO MEMORY command it is possible to monitor the parameters used by application to maintain DRAM/PMem ratio. The following parameters have been added:> info memory