Cassandra's Write Path
Cassandra's Write Path
As Cassandra is designed for heavy writes, writing in Cassandra is a piece of cake. In Cassandra any input is taken as write. Insert, Update, Delete, Alter all these operations are considered as writes in Cassandra.
Components of Write Path
There are only three main elements in Cassandra. They are:
- Commitlog
- Memtable
- SStable
Commit Log: It is the disk component. It is the append only storage in the disk. When a write operation is going on, the data will be reaching the commit log first and gets appended.
Mem Table: It is the memory component. After the write is written in the commit log it will immediately write the data in the mem table in a sorted order.
SS Table: It is also a disk component. The full form of SS Table is "Sorted Strings Table". SS tables are immutable.
WRITE PATH:
The best thing in Cassandra is any node in the Cassandra cluster can respond to the client's request. That node is called as Coordinator node. Coordinator node sends the request to replica nodes based on Consistency Level.
When a replica node receives a write request,
- Data which is sent will be appended to the commitlog first.
- Then it will be written to memtable in a sorted order.
- Whenever certain threshold reaches on either mem table or commitlog, the memtable data will get flushed into a immutable SS table and it clears the commitlog.
- Commitlog is like a failover mechanism, whenever a node gets crashes, commit log will get replayed into memtable. Hence there can be one or more SS Tables for one table of data.
In this way writes in Cassandra are fast and will be completed within just three steps. The write timeout in Cassandra is 5 seconds. Which means each write should not take more than 5 seconds to complete the write operation.
Comments
Post a Comment