Database / Apache Cassandra Intermediate and Advanced interview questions
Explain the write path in Cassandra?
A write in Cassandra is optimized to be fast and durable without doing any disk seeks or read-before-write checks.
flowchart LR A[Client sends write] --> B[Coordinator node] B --> C[Commit Log - append only, durability] B --> D[Memtable - in-memory, per table] D -->|threshold reached| E[Flush to SSTable on disk] C -.-> F[Replayed on crash recovery]
- The client sends the write to any node, which becomes the coordinator for that request.
- The coordinator forwards the write to all replicas that own the partition, based on the token ring.
- Each replica appends the mutation to its local commit log first, purely for crash recovery.
- The same mutation is applied to an in-memory memtable, sorted by clustering key.
- The coordinator waits only for the number of acknowledgements required by the requested consistency level before replying to the client.
- Later, once the memtable fills up, it is flushed to an immutable SSTable on disk, and the corresponding commit log segment can be discarded.
Because writes are just an append plus a sorted in-memory insert, Cassandra can sustain very high write throughput compared to databases that read existing rows first or update in place.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
