---
id: "snowflake-id"
type: "component"
kind: "id-generator"
provider: "default"
category: "data"
docs: "https://en.wikipedia.org/wiki/Snowflake_ID"
url: "https://localhost:3000/catalogue/components/snowflake-id"
---

# Snowflake ID

Twitter-style 64-bit ids from timestamp, worker id and sequence.

| | |
|---|---|
| Provider | [default](https://localhost:3000/catalogue?provider=default) |
| Kind | [ID generator](https://localhost:3000/catalogue/kinds/id-generator) |
| Category | Data |
| Official docs | [https://en.wikipedia.org/wiki/Snowflake_ID](https://en.wikipedia.org/wiki/Snowflake_ID) |

## Properties

| property | type | values | required | kind default | this component |
|---|---|---|---|---|---|
| `batchSize` | integer | — | no | — | inherited |
| `central` | boolean | — | no | false | **false** |
| `clockRollbackGuard` (advanced) | boolean | — | no | false | **true** |
| `managed` | boolean | — | no | false | inherited |
| `replicated` | boolean | — | no | false | **false** |
| `sequenceBits` | integer | — | no | 12 | inherited |
| `strategy` | enum | `uuid`, `ulid`, `snowflake`, `counter`, `counter-batched`, `hash` | yes | — | **"snowflake"** |
| `timeSortable` | boolean | — | no | false | **true** |
| `workerIdBits` | integer | — | no | 10 | inherited |

Bold values are the ones this component pins.

## Rules that apply · 0

No rule selects this kind or its category.

## Other products of the same kind · 4

- [Generic ID generator](https://localhost:3000/catalogue/components/id-generator.md) `id-generator` — default
- [Ticket server](https://localhost:3000/catalogue/components/ticket-server.md) `ticket-server` — default
- [ULID service](https://localhost:3000/catalogue/components/ulid-service.md) `ulid-service` — default
- [UUID generator](https://localhost:3000/catalogue/components/uuid-generator.md) `uuid-generator` — default

## Use it in a design

```yaml
nodes:
  - { id: "snowflake-id", component: "snowflake-id" }
```

## Source (`component` YAML, verbatim)

```yaml
# yaml-language-server: $schema=../../schema/component.schema.json
# Twitter Snowflake-style id: timestamp, worker id and sequence packed into 64 bits, generated
# locally on each worker; refuses to issue ids when the clock moves backwards.
schemaVersion: "1"
type: "component"
id: "snowflake-id"
kind: "id-generator"
provider: "default"
docs: "https://en.wikipedia.org/wiki/Snowflake_ID"
defaults:
  strategy: "snowflake"
  central: false
  replicated: false
  timeSortable: true
  clockRollbackGuard: true
properties:
  workerIdBits:
    type: "integer"
    default: 10
  sequenceBits:
    type: "integer"
    default: 12
```

Human page: https://localhost:3000/catalogue/components/snowflake-id
