Probabilistic domain service idempotency with HyperLogLog

121 Views Asked by At

I'm evaluating an approach to domain service idempotency using HyperLogLog [HLL].

Aim of this approach would be to provide generic way of ensuring idempotency without storing large amounts of useless information. Only requirement being tolerance for occasional duplication (send 2 email instead of one).

In my scenario every service request is a message object with toHashCode function. The algorithm looks like this:

  1. Upon receiving request domain service calculates HLL[S1] cardinality and stores it as C1.
  2. Request hash[H] is added to the copy of HLL[S2] and the cardinality is stored as C2.
  3. If C1 == C2 then request is duplicated and S2 should be discarded.
  4. Otherwise request will be handled and hash[H] will be added to HLL[S1].

Did anybody encounter similar solution ? (like bloom filter)
What would be the downsides of this kind of solution ?

0

There are 0 best solutions below