Skip to main content

Avoiding Elasticsearch Memory Swapping

Hands-On Lab


Photo of Myles Young

Myles Young

BigData Training Architect II in Content





Most operating systems try to use as much memory as possible for file system caching. This causes application memory to be eagerly swapped out which can result in parts of the Java Virtual Machine (JVM) heap being swapped to disk. For Elasticsearch, swapping is catastrophic for node stability and performance. It is actually more effective for the cluster to let the operating system kill the node than to let it continue in the event of the heap being swapped out.

Disabling swap files or reducing the swappiness of the Linux systems can avoid Elasticsearch memory swapping, however there is a way to allow the system to swap all but Elasticsearch's heap using mlockall. This learning activity gives you the opportunity to bootstrap Elasticsearch with memory locking in order to avoid swapping Elasticsearch's heap, while still allowing the host to use swap for other things.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.