Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

satvantsingh_190085 avatar image
satvantsingh_190085 asked ·

How many memtables exist in Cassandra?

How new memtables create in cassandra node ? Are the created for every write basis's ? is there any max number we defined for cassandra memtablse in memory ?

cassandramemtables
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

There are as many memtables as there are tables. That is the total number of tables in all keyspaces, regardless of how many keyspaces there are.

The total memory allocated for memtables are determined by the 2 parameters in cassandra.yaml:

  • memtable_heap_space_in_mb

  • memtable_offheap_space_in_mb

Cassandra uses the total of these 2 to determine the threshold for triggering memtable flushes to disk.

For more info, see the common memtable settings in cassandra.yaml.

UPDATE - The new writes (mutations) are temporarily stored in memtables but are also persisted to disk in the commitlog. When the a memtable is flushed to disk (written to an SSTable), the corresponding commitlog segment gets truncated since the mutations in it have already been persisted to disk.

But when a node goes down, the memtables are lost but the mutations they held are on disk. On startup, Cassandra checks if there are uncommitted mutations and replays the commitlog.

You can find out more about it in the Cassandra write path. Cheers!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks @Erick Ramirezfor quick response :) .

So I f I have 100 tables in my all keyspace , then 100 memtables will be in memory ? If yes then the structure of memtable will remain always in memory ?

What happen when a node goes down , does it load all memtables structure again ? Kindly help to understand !




0 Likes 0 ·

Let me edit my answer with the details. Cheers!

0 Likes 0 ·