ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/tracks/identifier/tasks/task-2-4-4-id-comparison
TASK

Implementation

Different ID schemes have different tradeoffs. Your task is to implement all three and return a comparison table.

Implement a compare_ids handler that generates one ID of each type and reports their properties:

Request:  {"type": "compare_ids", "msg_id": 1}
Response: {"type": "compare_ids_ok", "in_reply_to": 1, "comparison": [
    {"scheme": "uuid_v4", "id": "550e8400-e29b...", "bits": 128, "sortable": false, "causal": false},
    {"scheme": "snowflake", "id": "7041429939834880", "bits": 64, "sortable": true, "causal": false},
    {"scheme": "hlc", "id": "1234567-0-n1", "bits": 96, "sortable": true, "causal": true}
]}

Sample Test Cases

Compare IDs returns three schemesTimeout: 5000ms
Input
{"src":"c0","dest":"n1","body":{"type":"init","msg_id":1,"node_id":"n1","node_ids":["n1"]}}
{"src":"c1","dest":"n1","body":{"type":"compare_ids","msg_id":2}}
Expected Output
{"src": "n1", "dest": "c0", "body": {"type": "init_ok", "in_reply_to": 1, "msg_id": 0}}

Hints

Hint 1
UUID v4 is random: 128 bits, no ordering, no coordination needed
Hint 2
Snowflake is timestamped: 64 bits, sorted, needs machine_id assignment
Hint 3
HLC is timestamped + causal: variable size, captures causality, needs clock sync
Hint 4
Compare: storage size, generation speed, uniqueness guarantee, sortability
Hint 5
Each approach has different tradeoffs for different use cases
OVERVIEW

Theoretical Hub

Concept overview coming soon

Key Concepts

UUIDSnowflakeHLCID tradeoffsbenchmarking
main.py
python
Compare HLC, UUID v4, and Snowflake IDs - The Identifier | Build Distributed Systems