Akavall
Akavall

Reputation: 86306

Writing to two cassandra tables with time overlap

I am writing to two cassandra tables, the tables have different keyspaces. I am wondering about how the write actually happens.

I see this explanation at: https://academy.datastax.com/demos/brief-introduction-apache-cassandra

Cassandra is well known for its impressive performance in both reading and writing data. Data is written to Cassandra in a way that provides both full data durability and high performance. Data written to a Cassandra node is first recorded in an on-disk commit log and then written to a memory-based structure called a memtable. When a memtable’s size exceeds a configurable threshold, the data is written to an immutable file on disk called an SSTable. Buffering writes in memory in this way allows writes always to be a fully sequential operation, with many megabytes of disk I/O happening at the same time, rather than one at a time over a long period. This architecture gives Cassandra its legendary write performance

But this does not explain what happens if I write to two tables in overlapping time period.

Let's say I am writing to Table 1 and Table 2 at the same time. The entries that I want to write would still be stored in the same memtable, correct? They would essentially be mixed, right?

Let's say I am writing 100,000,000 entries for Table 1 and 10 minutes later I started to write entries 100 for Table 2. The 100 for Table 2 would still have to wait for entries for Table 1 to be processed, since they are sharing the same memtable right?

Is my understanding about how memtable is shared correct? Is there a way for different keyspaces to have their own memtable. For example, if I really want to make sure that entries for Table 2 get written without a delay, is that possible?

.

Upvotes: 0

Views: 148

Answers (1)

Adrien Piquerez
Adrien Piquerez

Reputation: 1044

Each table have its own memtable. Cassandra does not mix things. That is why it can easily and efficiently flush data on the disk when memtables total space is full.

This Datastax document is a good summary of how writing in Cassandra is performed from commitlog to sstable and compaction.

Upvotes: 1

Related Questions