Skip to content

ybt195/flake

Repository files navigation

flake logo

Flake

Generate k-sortable 64-bit unique flake ids.

Issues · Documentation

GoDoc Reference Build Status Go Report Status Apache License, Version 2.0

Table of contents

Overview

Flake ids are represented in 64-bit unsigned integers. Ids can be broken down into three components:

  • Bucket: A 10-bit bucket id for sharding ids over 1024 different buckets.
  • Timestamp: A 42-bit millisecond encoded timestamp of when the id was generated.
  • Sequence: A 12-bit incrementing sequence number that is reset at each timestamp increment.

With this formation, flake can generate 4096 unique ids per millisecond per bucket, or in other words, 4 billion unique ids per second. For reference, YouTube gets about 75 thousand unique views per second.

Contributing

Contributions are very much welcomed. Please read the Contribution Guide for how to get started.

Note that all contributors are expected to follow the Code of Conduct.

License

Flake is licensed under the Apache License, Version 2.0. For more information, see the License file.