Bird
Raised Fist0

Distributed File System Design - Metadata Servers and Data Nodes

HLDmediumInterview freq: high
Choose your preparation mode4 modes available
▶
Request Trace
Step 1/6
Clients

Send file metadata request

Client sends HTTP request for file metadata

Protocol:HTTP
BeforeClient has file path but no metadata
AfterRequest sent to Load Balancer
Load Balancer

Forward request to Metadata Server

Load Balancer routes request to one Metadata Server

Protocol:RPC
BeforeLoad Balancer has incoming client request
AfterMetadata Server receives request
Metadata Servers

Query metadata store

Metadata Server queries Cassandra for file metadata

Protocol:CQL
BeforeMetadata Server has client request but no metadata
AfterMetadata Server receives metadata response
Metadata Store (Apache Cassandra)

Return metadata

Cassandra returns file metadata to Metadata Server

Protocol:CQL Response
BeforeCassandra has metadata stored for file
AfterMetadata Server has file metadata
Metadata Servers

Request data blocks from Data Nodes

Metadata Server sends RPC to Data Nodes to fetch file blocks

Protocol:RPC
BeforeMetadata Server has file metadata but no data blocks
AfterData Nodes start streaming data blocks
Data Nodes

Stream file data

Data Nodes stream requested file blocks back to Client

Protocol:Data Stream
BeforeData Nodes have file blocks stored
AfterClient receives file data blocks
🏗️
Architecture Diagram
Architecture Diagram
┌─────────────┐
│   Clients   │
└──────┬──────┘
       │ HTTP Request
       ▼
┌───────────────┐
│ Load Balancer │
└──────┬────────┘
       │ RPC Call
       ▼
┌───────────────────┐
│ Metadata Servers  │
│ (handles metadata)│
└──────┬────────────┘
       │ CQL Query
       ▼
┌───────────────────────────────┐
│ Metadata Store (Apache Cass.) │
│ (distributed metadata storage)│
└──────┬────────────────────────┘
       │ Metadata Response
       ▼
┌───────────────┐
│ Metadata Servers│
└──────┬────────┘
       │ RPC Call
       ▼
┌─────────────┐
│  Data Nodes │
│ (store file │
│  blocks)    │
└──────┬──────┘
       │ Data Stream
       ▼
┌─────────────┐
│   Clients   │
└─────────────┘

In this distributed file system, clients initiate file metadata requests via HTTP to a Load Balancer, which distributes requests to Metadata Servers. Metadata Servers query the Metadata Store, implemented with Apache Cassandra, using CQL to retrieve persistent metadata. After receiving metadata, Metadata Servers coordinate with Data Nodes via RPC to fetch actual file blocks. Data Nodes then stream the requested data back to clients. This vertical flow ensures separation of concerns: Metadata Servers handle metadata logic, Cassandra provides scalable storage, and Data Nodes serve file data. The Load Balancer prevents overload by distributing client requests evenly. This architecture supports scalability and fault tolerance by decoupling metadata and data storage.

Primary Focus

✓

Practice

(1/5)
1. In a time-series ingestion pipeline, at step 4 the Aggregation Worker reads raw event batches from Kafka and writes summarized metrics to the time-series database. What happens if the Aggregation Worker crashes after reading but before writing?
easy
A. The raw events remain in Kafka and will be reprocessed after worker restart
B. The Aggregation Worker automatically retries writing without re-reading events
C. The summarized metrics are partially written causing data corruption in the database
D. The raw events are lost because Kafka deletes them immediately after consumption

Solution

  1. Step 1: Understand Kafka's offset commit behavior

    Kafka retains messages until consumers commit offsets. If the worker crashes before committing, messages remain available for reprocessing.
  2. Step 2: Analyze crash timing

    Since the worker crashed before writing summaries and committing offsets, raw events remain in Kafka and will be reprocessed after restart.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Kafka retains uncommitted messages for reprocessing [check]
Hint: Kafka commits offsets after processing to avoid data loss [check]
Common Mistakes:
2. If the Redis Cluster's slot-to-node mapping cache on the client is stale and not updated after a node failure, what is the most likely failure observed by the client?
medium
A. Client requests succeed but with increased latency due to retries
B. Client receives MOVED errors and automatically updates mapping without failure
C. Client silently writes data to wrong nodes, causing data inconsistency
D. Client requests are sent to a failed node, causing timeouts and request failures

Solution

  1. Step 1: Understand stale slot cache impact

    Stale cache causes client to send requests to nodes no longer responsible or down.
  2. Step 2: Trace failure consequences

    Requests to failed nodes time out or fail; client does not receive MOVED errors because node is down (Client requests are sent to a failed node, causing timeouts and request failures).
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Stale cache -> requests to failed nodes -> timeouts/failures [check]
Hint: Stale slot cache -> requests to dead nodes -> timeouts, no auto-fix [OK]
Common Mistakes:
3. If the Kafka cluster that buffers user rating events goes down, what exact failure occurs in the recommendation system's embedding update pipeline?
medium
A. User rating events are lost immediately with no retry, causing embedding updates to stop
B. The system switches to a fallback database for buffering, causing increased latency but no data loss
C. The embedding service blocks processing new ratings until Kafka recovers, causing user request delays
D. User rating events queue up in the embedding service memory, eventually causing out-of-memory errors

Solution

  1. Step 1: Understand Kafka's role

    Kafka buffers rating events asynchronously, decoupling ingestion from embedding updates.
  2. Step 2: Trace failure impact

    If Kafka is down, producers cannot send events; embedding service may buffer events in memory temporarily but lacks durable queue, leading to memory exhaustion (C). Immediate loss (A) is incorrect because producers typically retry; blocking (B) is unlikely as embedding service consumes asynchronously; fallback DB (D) is not part of design.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Kafka down -> embedding service buffers in memory -> OOM risk [check]
Hint: Kafka down -> embedding service memory buffers overflow [check]
Common Mistakes:
4. If the Duplicate Detection component fails silently and stops filtering URLs, what is the most immediate failure observed in the crawler system?
medium
A. The URL Frontier crashes because it cannot handle duplicate URLs
B. The Politeness Policy Manager blocks all requests due to unexpected URL patterns
C. The Scheduler rejects all URLs due to overload and stops scheduling new crawls
D. The crawler repeatedly fetches the same URLs, wasting bandwidth and storage

Solution

  1. Step 1: Trace failure impact of Duplicate Detection silent failure

    Without filtering, duplicate URLs flood the system causing repeated fetches.
  2. Step 2: Eliminate other options

    Scheduler overload is secondary; Politeness Policy unaffected by duplicates; URL Frontier typically handles duplicates gracefully.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Duplicate Detection failure causes repeated URL fetches [check]
Hint: No duplicate filtering -> repeated URL fetches waste resources [OK]
Common Mistakes:
5. At 10x traffic scale, which component in a system using a Reverse Proxy, API Gateway, and Load Balancer is most likely to become the bottleneck first, and why?
hard
A. API Gateway, because it performs CPU-intensive tasks like authentication and request transformation on every request
B. Load Balancer, because it maintains stateful TCP connections that cannot be easily sharded
C. Reverse Proxy, because it caches responses and runs out of memory under high load
D. DNS load balancing, because it cannot dynamically adjust to rapid traffic changes

Solution

  1. Step 1: Analyze component scaling characteristics

    Load Balancers typically handle stateless TCP connections and can be scaled horizontally; Reverse Proxies cache but can be scaled with eviction policies; DNS load balancing is not a runtime bottleneck.
  2. Step 2: Identify CPU-intensive bottleneck

    API Gateway performs authentication, rate limiting, and transformations per request, which are CPU and memory intensive and harder to scale linearly.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    API Gateway CPU load scales with request complexity, causing bottleneck [check]
Hint: API Gateway CPU-heavy tasks cause first bottleneck at scale [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