[infinispan-dev] Distributed Counter Discussion
Tristan Tarrant
ttarrant at redhat.com
Tue Mar 29 05:16:25 EDT 2016
On 29/03/2016 10:12, Galder Zamarreño wrote:
> Good start but rather than coming out with a general design for a counter, I'd try to start coming out with functionality needed for the most commonly use cases for counters, e.g.
>
> e.g. if you're counting number of visits to your website, you only need an incrementing counter (and maybe a reset to be called at the end of the day/week/month/year?) but you'll never decrement, precision not hugely important? Could you assume you always increment by 1? It might be more efficient to increment by N...
> e.g. if you're counting number of users logged in at one point to your website, then you need a counter that both increments and decrements, precision not hugely important? You probably don't want reset operation? Moreover, could you assume you always increment/decrement by 1?
You want an "Adder" for both of these cases [1].
> e.g. if using a counter to generate a unique identifier that always increases, you need only increment but precision must be guaranteed, so after increasing and retrieving an old value can't be retrieved. You probably don't want reset operation? You can probably assume that increment is only by 1.
This is a sequence, and, even in this case, there are two possible variants:
- one where you just need uniqueness but monotonic increment is not
essential (nodes can retrieve preallocated ranges of ids on demand).
- one which is fully monotonic
Tristan
[1]
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAdder.html
--
Tristan Tarrant
Infinispan Lead
JBoss, a division of Red Hat
More information about the infinispan-dev
mailing list