PLANNED MAINTENANCE

Hello, DataStax Community!

We want to make you aware of a few operational updates which will be carried out on the site. We are working hard to streamline the login process to integrate with other DataStax resources. As such, you will soon be prompted to update your password. Please note that your username will remain the same.

As we work to improve your user experience, please be aware that login to the DataStax Community will be unavailable for a few hours on:

  • Wednesday, July 15 16:00 PDT | 19:00 EDT | 20:00 BRT
  • Thursday, July 16 00:00 BST | 01:00 CEST | 04:30 IST | 07:00 CST | 09:00 AEST

For more info, check out the FAQ page. Thank you for being a valued member of our community.


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 · ·