Alternatives to UUIDs as network identifiers

Introduction

To shorten the user/network identifier (beekeeper id) currently based on a 36 character UUID, we might choose the ULID, an universally-unique lexicographically-sortable identifier encoded as a 26 character string. On top of that, ULIDs have some other nice properties, enjoy reading its specification.

Example

01AN4Z07BY79KA1307SR9X4MV3

Anatomy

 01AN4Z07BY      79KA1307SR9X4MV3
|----------|    |----------------|
 Timestamp           Entropy
  10 chars           16 chars
   48bits             80bits
   base32             base32

References


There are definitively other ways to create good unique identifiers. From that list, we found ULIDs to have the most convenient properties, followed by sonyflake.

Package Id Format
github.com/segmentio/ksuid 0pPKHjWprnVxGH7dEsAoXX2YQvU 4 bytes of time (seconds) + 16 random bytes
github.com/rs/xid b50vl5e54p1000fo3gh0 4 bytes of time (seconds) + 3 byte machine id + 2 byte process id + 3 bytes random
github.com/kjk/betterguid -Kmdih_fs4ZZccpx2Hl1 8 bytes of time (milliseconds) + 9 random bytes
github.com/sony/sonyflake 20f8707d6000108 ~6 bytes of time (10 ms) + 1 byte sequence + 2 bytes machine id
github.com/oklog/ulid 01BJMVNPBBZC3E36FJTGVF0C4S 6 bytes of time (milliseconds) + 8 bytes random
github.com/chilts/sid 1JADkqpWxPx-4qaWY47~FqI 8 bytes of time (ns) + 8 random bytes
github.com/satori/go.uuid 5b52d72c-82b3-4f8e-beb5-437a974842c UUIDv4 from RFC 4112 for comparison

– via: Generating good unique ids in Go

To produce even shorter and more convenient unique identifiers, i started leaning towards sonyflake. A Sonyflake ID is composed of

39 bits for time in units of 10 msec
16 bits for a machine id
 8 bits for a sequence number

This will reduce the space required for addressing a network of telemetry nodes (aka. network owner / beekeepers id) down to a 15 character string. Things like 20f8707d6000108 don’t spell bad either.

What’s your opinion about that?

1 Like