The need to generate a globally unique identifier comes up often.
The way described in
RFC 4122 is popular but it can be done better.
A unique id generated this way:
- is a 20 character string, safe to include in urls (no need for escaping)
- consist of 8 bytes of timestamp (millisecond precision) and 9 bytes of random data
- sorts lexicographically
- 72-bits of random data ensures IDs won’t collide with IDs generated by other clients
- are monotonically increasing even within the same timestamp
Related: comparison of
Go libraries for unique id generation.