Skip to main content
InterviewHubPRO
Section Overview
Q28

Question 28 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

56%
Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Mitigating Hot Partitions and Data Skew.

senior LevelSystem Design

In Simple Words: If 1 partition receives 100,000 messages/sec while 9 other partitions receive 1,000 messages/sec, the broker hosting that partition experiences disk and CPU saturation, and the assigned consumer falls behind.

Architecture Solutions:

  1. Key Salting (Compound Keys): Instead of using just userId, append a randomized suffix: userId + "_" + random(1, 5). Spreads the user's records across 5 partitions.
  2. Custom Partitioner: Implement Kafka's Partitioner interface in the producer to route high-volume tenants to dedicated isolated topics or partitions, while pooling smaller tenants.