A: Just use a timestamp
Q: what is I have 2 different computers and 2 requests come in at the same time?
A: Just add a computer id + timestamp. Cool?
Q: What if I send 2 requests at the same microsecond from the same computer?
A: Add a counter! computer id + timestamp + counter.
Q: Wait a minute. I can set computer time to old timestamp what then?
A: Ok fine! Just use the computer id + counter.
Q: What if I run out of counter? Or my computer restarts and so does my counter?
A: Write our counter to disk or flash!
Q: But then our reads are slow!
A: Wait! My computer gives a UUID! We can use that
Q: Yeah it’s unique but I also wanna use these identifiers to resolve conflicts. Like whichever transaction comes first wins and other loses. So I want a monotonically increasing distributed unique id.
A: how about we use timestamp + machine id
Q: But what if I call 2 computers at the same time? They might not be monotonically increasing id.
A: Ok Let’s stick to a SQL DB! Curious how does twitter snowflake work?
A: timestamp + worked id + process id + sequence