ulid / spec

The canonical spec for ulid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

would ulid be better then snowflake id?

VincentRPS opened this issue · comments

would ulid be better/more unique than a twitter snowflake and why?

I don't really know anything about this (as I'm just discovering ULIDs myself) but it seems to me that snowflakes require a machine ID, which has the same problems as UUID v1 and v2. If the machine ID isn't universally unique, then the resulting snowflake won't be either.

A little late to the party, but...

  • A snowflake indeed requires some sort of machine/node id for each generator, while ULID doesn't.
  • A snowflake id is 8 bytes (a long datatype in most languages), which can be convenient. ULID is 16 bytes, or 26 chars, so it can store many more values while still offering the same general promise of monotonicity, albeit not always 100% accurate if two ids are generated within the same millisecond of each other, but that usually doesn't matter in practice.

A little late to the party, but...

  • A snowflake indeed requires some sort of machine/node id for each generator, while ULID doesn't.
  • A snowflake id is 8 bytes (a long datatype in most languages), which can be convenient. ULID is 16 bytes, or 26 chars, so it can store many more values while still offering the same general promise of monotonicity, albeit not always 100% accurate if two ids are generated within the same millisecond of each other, but that usually doesn't matter in practice.

It seems that snowflake id may be more ideal then, even if it requires some sort of machine/node id that could always just be set to the name of the thread your using in your language or something. Or well as long as you don't care about having to use BigInts or Longs everywhere instead of normal integers