Bird
Raised Fist0

Zookeeper for Leader Election and Distributed Configuration

HLDmediumInterview freq: common
Choose your preparation mode4 modes available
▶
Request Trace
Step 1/6
Client Proxies / Session Managers

Send leader election request

Client requests to create ephemeral znode for leader election

Protocol:TCP
BeforeClient has no active leader election znode
AfterRequest forwarded to ZK Quorum
ZK Quorum

Process ephemeral node creation

Quorum coordinates creation of ephemeral znode for leader election

Protocol:Internal RPC
BeforeNo ephemeral node exists for this client session
AfterEphemeral Node Mech instructed to create znode
Ephemeral Node Mech

Create ephemeral znode

Creates ephemeral node tied to client session, triggers WAL write

Protocol:Write to Persistent Storage
BeforeNo ephemeral node present for this client
AfterEphemeral node created and durable write initiated
Persistent Storage (WAL + Snapshots)

Durably log ephemeral node creation

Write-ahead log records ephemeral node creation for recovery

Protocol:Internal storage write
BeforeNo WAL entry for this ephemeral node
AfterWAL entry and snapshot updated with new ephemeral node
Watch Notification Sys

Notify watchers of znode change

Clients watching leader election path receive notification

Protocol:Notify via TCP
BeforeClients unaware of new ephemeral node
AfterClients receive watch event about leader election change
Client Proxies / Session Managers

Receive watch notification

Client updates leader election state based on watch event

Protocol:TCP
BeforeClient unaware of leader election outcome
AfterClient updates local state with new leader info
🏗️
Architecture Diagram
Architecture Diagram
┌───────────────────────────────┐
│ Client Proxies / Session Mgrs │
└───────────────┬───────────────┘
                │ TCP
                ▼
      ┌───────────────────────┐
      │       ZK Quorum       │
      └─────────────┬─────────┘
                    │ Internal RPC
                    ▼
      ┌───────────────────────────────┐
      │    Ephemeral Node Mech        │
      └─────────────┬─────────────────┘
                    │ Write to
                    ▼
      ┌───────────────────────────────┐
      │ Persistent Storage (WAL + Snap)│
      └─────────────┬─────────────────┘
                    │ Notify
                    ▼
      ┌───────────────────────────────┐
      │   Watch Notification Sys      │
      └─────────────┬─────────────────┘
                    │ Notify via TCP
                    ▼
┌───────────────────────────────┐
│ Client Proxies / Session Mgrs │
└───────────────────────────────┘

Zookeeper uses a quorum of servers to coordinate leader election and distributed configuration. Clients connect via proxies that manage sessions and forward requests to the quorum. The quorum uses an ephemeral node mechanism to create ephemeral znodes representing client sessions or leader candidates. These ephemeral nodes are durably logged in persistent storage using write-ahead logs and snapshots to ensure recovery after failures. The watch notification system sends event notifications to clients watching znodes, enabling them to react to leader changes or config updates. This architecture ensures strong consistency and fault tolerance by combining ephemeral nodes tied to sessions, durable storage, and watch-based event propagation.

Primary Focus

✓

Practice

(1/5)
1. In the route leak mitigation system, at Step 4 the Route Validation Worker receives a BGP update. What does it do when the update contains a prefix not matching the configured filters?
easy
A. It immediately propagates the prefix to all peers to maintain connectivity
B. It marks the prefix as invalid and prevents it from being advertised further
C. It queues the prefix for manual review before any action is taken
D. It modifies the prefix to a default route to avoid blackholing traffic

Solution

  1. Step 1: Trace Route Validation Worker behavior at Step 4

    The worker checks prefixes against filters and, in some cases, queues suspicious prefixes for manual review, delaying propagation.
  2. Step 2: Eliminate other options

    Propagating invalid prefixes (A) causes leaks; marking invalid and blocking (B) is ideal but not always immediate; modifying prefixes (D) risks routing errors.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Suspicious prefixes queued for manual review, delaying propagation [check]
Hint: Suspicious prefixes queued before propagation [check]
Common Mistakes:
2. In an asynchronous messaging system, what exactly breaks if the message queue component is removed?
medium
A. Senders block until recipients acknowledge, causing high latency
B. Messages are duplicated due to lack of deduplication in the queue
C. Messages are delivered immediately but with no ordering guarantees
D. The system silently drops messages without notifying senders

Solution

  1. Step 1: Understand queue's role in message deduplication and buffering

    Queues often provide deduplication and buffering to ensure exactly-once or at-least-once delivery.
  2. Step 2: Consequence of removing the queue

    Without the queue, messages may be duplicated due to lack of deduplication and buffering mechanisms.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Removing queue causes message duplication due to missing deduplication [check]
Hint: No queue means no deduplication, causing duplicates [check]
Common Mistakes:
3. At 10x scale, which component in a WebRTC video calling system is most likely to become the bottleneck first, and why?
hard
A. Media Servers, because transcoding CPU load grows linearly with concurrent calls
B. Signaling Servers, because they maintain stateful WebSocket connections and cannot easily shard sessions
C. STUN/TURN Servers, because NAT traversal requests increase exponentially with users
D. Client devices, because battery and CPU limits prevent scaling user concurrency

Solution

  1. Step 1: Analyze component scalability at 10x load

    Media Servers scale with CPU but can be horizontally scaled; STUN/TURN scale well with stateless UDP; clients are outside system control.
  2. Step 2: Identify Signaling Server bottleneck

    Signaling Servers hold stateful WebSocket connections per user, making sharding and scaling challenging.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Stateful WebSocket connections limit Signaling Server horizontal scaling [check]
Hint: Stateful WebSocket limits Signaling Server scaling first [check]
Common Mistakes:
4. At 10x scale, which component in the Google Search architecture is most likely to become the first bottleneck, and why?
hard
A. The distributed file system storing raw crawled pages, because storage bandwidth saturates before compute
B. The crawler's URL Frontier, because it must maintain global URL ordering and politeness state, which is hard to shard
C. The query serving layer, because caching effectiveness drops and latency-sensitive lookups increase exponentially
D. The PageRank computation cluster, because the graph size grows superlinearly, increasing memory and CPU demands drastically

Solution

  1. Step 1: Analyze scaling challenges per component

    The PageRank cluster faces superlinear growth in graph edges, causing memory and CPU bottlenecks.
  2. Step 2: Compare other components

    URL Frontier can shard with heuristics; query serving scales with caching; storage bandwidth scales better than PageRank compute.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    PageRank graph growth causes first bottleneck at 10x scale [check]
Hint: PageRank graph grows superlinearly -> first bottleneck [check]
Common Mistakes:
5. At 10x scale, which component in a distributed lock system using ZooKeeper is most likely to fail first and why?
hard
A. ZooKeeper ensemble leader, due to increased write load and session management overhead
B. Clients, because they cannot handle the increased lock acquisition requests
C. Network routers, because of increased traffic causing packet loss
D. Storage backend, because ephemeral nodes consume excessive disk space

Solution

  1. Step 1: Identify ZooKeeper leader role

    The leader handles all write requests and session heartbeats, becoming a bottleneck under high scale.
  2. Step 2: Evaluate other components

    Clients (A) can be scaled horizontally; network routers (C) are less likely the first bottleneck; ephemeral nodes (D) are lightweight and cleaned up automatically.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Leader bottleneck due to write and session overhead [check]
Hint: ZooKeeper leader handles all writes -> first bottleneck [check]
Common Mistakes:
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard