Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why swap needs to be turned off in Datastax Cassandra?

I am new to Datastax cassandra. While going through the installation procedure of cassandra. It is recommended that the swap area of OS should be turned off. Does anyone provide the reason for that? Will it affect any OS level operations ?

like image 335
Sathishkumar Avatar asked Apr 10 '14 13:04

Sathishkumar


2 Answers

In production, if your database is using swap you will have very bad performance. In a ring of Cassandra nodes, you are better off having one node go completely down than allowing it to limp along in swap.

The easiest way to ensure that you never go into swap is to simply disable it.

like image 61
psanford Avatar answered Oct 15 '22 11:10

psanford


If you dont disable swap space, when there is an Out of Memory(when the address space is used up by cassandra mmap) problem at OS level, the OS will try to take a slice of the JVM which is in turn actually trying to clear it via JNI by default. Now , your JVM is slowed down as a slice of its heap memory is lost. Now GC will be happening along with the cassandra write operation with lesser heap memory. This brings the overall performance of the cassandra node down and gradually kills it one point of time where there is no more memory left at OS level.

Thats why they suggest you two things.

  1. Bundle jna.jar. When there is a GC operation for mmap of cassandra, it is all done by java code and not JNI portion that is shipped by default in cassandra. So, it avoids a portion of address space that JNI tries to store in case of native operations.
  2. Disable swap space . A low performing cassandra node will slow down all the operations at its client end. Even the replication to this node will be slowed down and hence you read/write will appear slower than you think. A node shall die and restart when such an Out of Memory occurs instead of taking a portion of JVM that slows down the entire process.
like image 25
Ananth Avatar answered Oct 15 '22 10:10

Ananth