Database / Apache Cassandra Intermediate and Advanced interview questions
What are counter columns in Cassandra and what are their limitations?
Counter columns are a special column type designed for distributed, atomic increment/decrement operations, such as tracking view counts or like counts, where many clients may update the same value concurrently.
CREATE TABLE page_views ( page_id text PRIMARY KEY, views counter ); UPDATE page_views SET views = views + 1 WHERE page_id = 'home';
- Unlike normal columns, counters cannot be set to an arbitrary value directly — only incremented or decremented relative to their current value.
- A table containing a counter column can only contain counter columns (besides the primary key) — you cannot mix counters and regular data columns in the same table.
- Counters have no TTL support, since a TTL'd partial increment would be ambiguous to reconcile.
- Because increments are applied as deltas rather than idempotent last-write-wins values, a client retry after a timeout can cause a double-counted increment if the original request actually succeeded server-side.
Counters are convenient for coarse-grained aggregate metrics, but for anything requiring exact correctness (billing, financial balances), most teams avoid relying on retry-prone counter increments and instead model the operation with idempotent writes or external reconciliation.
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...
