I really like ULID for this problem (e.g:
https://github.com/ahawker/ulid)
- similar characteristics to UUID: same number of bytes, equivalent collision resistance, hard to guess, etc.
- start with a date, is monotonic, and is lexicographically sortable: not only it has great locality but sorting is super easy and most code get it right by default.
- can be created from an existing date or uuid, and exported to a uuid, so there is a migration path.
- you get the creation date for free, which is always nice. As a bonus, you can now use the uuid as a base for dispatching, bracketing, sharding, etc.
- similar characteristics to UUID: same number of bytes, equivalent collision resistance, hard to guess, etc.
- start with a date, is monotonic, and is lexicographically sortable: not only it has great locality but sorting is super easy and most code get it right by default.
- can be created from an existing date or uuid, and exported to a uuid, so there is a migration path.
- you get the creation date for free, which is always nice. As a bonus, you can now use the uuid as a base for dispatching, bracketing, sharding, etc.