Data Modeling hard
Twitter's Snowflake ID format generates unique 64-bit IDs in a distributed system without coordination. How are the bits structured?
- A A strictly random 64-bit cryptographic seed that ensures absolute uniqueness across every node in the cluster without the need for an internal clock.
- B A simplified auto-incrementing integer that is globally synchronized across all data centers using a high-latency consensus protocol like Paxos or Raft.
- C A variable-length hash that is derived from a combination of the user's public IP address, their MAC address, and a high-precision salt to ensure zero collisions.
- D A structured bit-sequence containing a Timestamp (41 bits), a Machine ID (10 bits), and a Sequence Number (12 bits) to provide sortable, distributed IDs.
Answer: D. A structured bit-sequence containing a Timestamp (41 bits), a Machine ID (10 bits), and a Sequence Number (12 bits) to provide sortable, distributed IDs.
Twitter's Snowflake format provides the best of both worlds: IDs are globally unique across a distributed system without needing a central bottleneck (like an SQL auto-increment), and they are roughly time-sortable (k-ordered). This sortability is critical for performance, as it ensures that new record inserts remain 'close' to each other in the database's primary index (B-Tree), avoiding the fragmentation common with random UUIDs.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?