1 minute read

Motivation

In a scaled system, debug is inevitable, and the basis of debugging is event, while there are tons of events generated per seconds, we need a mechanism to distinguish them from each other.

Then, we need a unique key generator for each events, where the sequencer come into play.

Design

There are several ways we can generate unique identifier for events, let’s discuss each of them

ID generator

UUID

UUID means “universal unique IDs”, each server can generate its own ID and assign the ID to its respective events. There is not coordination needed across the servers, since it’s dependent of server.

Range Handler

We can use ranges in a central servers, then any servers can claim a range when it need to.

Then each server keep the range in local until it’s run out.

One cons of this solution is SPOF, so we can introduce a failover server as a savior in this case.

Causality

We are not only interested in the event itself, more important thing is the causality between the events, so that we ca n know the overall flow of system and understand which part doesn’t work as expected.

Using a logical clock to mark the order of events is a reasonable solution

All of the system nodes are equipped with a numeric counter that begins at zero when first activated, before generating any events, this counter will increment by 1.

The message sent from this event to another node has the counter value.

We should note that this logical clock don’t allow us to infer causality at the global level.