Distributed Counter pattern

Whenever there is a need to maintain counters in applications that need to be persisted and distributed, use the Cassandra Counter data type in the column families. The distributed counter value is 64-bit long, supporting only two operations, namely increment and decrement. This is much better than storing the counter values in RDBMS tables, caches, log files, text files, and so on. In the latest version of Cassandra, the performance of the Counter data type has been improved a lot, and many issues have been fixed to allow it to support very powerful use cases.


The need to use counters exists in most applications. If the application and the database lives in just one node, there is no issue and everything ...

Get Cassandra Design Patterns - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.