Skip to content

Use SSD as a cheaper memory

feiben edited this page Jun 16, 2016 · 7 revisions

LunarMax has its own virtual memory system, using extra disk space as virtual memory in case the physical memory of a server is not sufficient, or user just want to limit the memory usage of LunarBase. It exposes its interface of alloc/free to LunarMMU just as a standard malloc/free of what glibc does.

There are two modes we support:

Turning rt_virtual_mem_enabled = off, then LunarMax acquires memory directly from OS. The OS takes the responsibility to swap in-and-out hot and cold pages between main memory and system swap space. In this mode, LunarMax has no control of how many memory will be used, and will race memory resource with other services running on the same server.

If your site has a high traffic and your server has many services consuming memories, we may suggest you turn on rt_virtual_mem_enabled = on.

In this mode, user can specify the maximum physical memory shall be allocated, and if the data increasing needs more, LunarMax swaps cold pages to its own swap space (e.g. rt_vm_swap = /home/feiben/DBTest/Swap). The maximum physical memory is well managed in this mode.

Set rt_max_memory = 28, then at most 256MB = 1 << 28 physical memory for every column can be allocated. Which means LunarBase has no resource race against other services.

We strongly suggest user to locate the swap space on a SSD device for quick virtual memory data exchange.

Clone this wiki locally