After Hours Academic

Question 12: Accurate count

Marie has built app for garage parking spaces. Whenever a car enters the garage, a process running on a server at the garage gate puts an ENTER message in a queue. Similarly, whene a car exits the garage, the process puts an EXIT message in the queue. A consumer of the queue reads messages from the queue and maintains a count of the number of cars in the garage.

Unfortunately, the queue only provides an at-least once guarantee. That is, it guarantees that any message sent will not be lost, but it does not guarantee that there will only be a single copy of the message in the queue.

She wants to ensure that she does not double count (or double subtract) any of the cars entry (or exit, respectively). Can you suggest a mechanism to ensure this?

Solution coming up in the next post.


Solution for diverging replicas:

Anjali's replication design can lead to divergent replicas if any of the queries have a non-deterministic input. For example, a query that stores time in the database using the server's clock could lead to divergent replicas because clocks are not guaranteed to be synchronized between two servers. Similarly, a query that stores a random value generated on the server could lead to divergent copies.

#idempotency #qna