Database / Apache Cassandra Intermediate and Advanced interview questions
What is the difference between SimpleStrategy and NetworkTopologyStrategy?
These are Cassandra's two main replication strategies, and they answer the same question — "where should replicas go?" — very differently.
| SimpleStrategy | NetworkTopologyStrategy |
| Places replicas on the next nodes clockwise on the ring, ignoring topology. | Places replicas per-datacenter, respecting rack awareness within each DC. |
| Single replication factor for the whole cluster. | Separate replication factor configured per datacenter. |
| Suitable only for single-datacenter test/dev clusters. | Required for any multi-datacenter production deployment. |
-- SimpleStrategy CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; -- NetworkTopologyStrategy CREATE KEYSPACE prod WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1': 3, 'dc2': 3};
Because SimpleStrategy has no concept of racks or datacenters, it can accidentally place every replica of a partition in the same rack, defeating the purpose of replication when that rack fails. Almost every real production keyspace should use NetworkTopologyStrategy, even on a single datacenter, since it's rack-aware and makes future multi-DC expansion straightforward.
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...
