Introduction
Welcome to our next lesson. In our previous session, we analyzed the trade-offs between local and global secondary indexes, concluding that the right choice is dictated by your application's access patterns and consistency requirements. We saw how a poorly chosen partition key can lead to inefficient scatter-gather queries. Today, we'll explore a more severe consequence of misaligned access patterns: hotspots.
This lesson directly addresses the learning outcome: Explain hot-spot detection and mitigation strategies for distributed workloads. A hotspot occurs when a disproportionate amount of traffic is directed to a small subset of your system's resources—be it a specific server, disk, or network link—creating a bottleneck that degrades performance for everyone. Understanding how to design systems that avoid hotspots, detect them when they inevitably occur, and mitigate them gracefully is a hallmark of a Principal Engineer. At Google's scale, where resource utilization is pushed to its limits, mastering these strategies is not just an optimization but a necessity for building reliable and efficient services.
What is a Hotspot and Why Does it Occur?
At its core, a hotspot is a severe load imbalance. While some degree of unevenness is normal, a hotspot represents a persistent state of overload on a component that becomes the critical path for a significant portion of user requests. This leads to increased latency, higher error rates, and potentially cascading failures.
The image below illustrates this concept. In the top-right panel, a single tablet in a Bigtable cluster is overloaded, receiving 25% of the read volume. This single component becomes a bottleneck for the entire system. The goal of mitigation, shown in the other panels, is to redistribute this load more evenly across the available nodes.

Hotspots primarily arise from two sources: the way data is organized and the dynamic nature of the workload itself.
1. Data and Access Pattern Imbalances
This cause is a direct consequence of the data modeling decisions we discussed in the last lesson. If data that is frequently accessed together is not partitioned effectively, hotspots will form.
A short video from Hello Interview provides excellent examples of how a poorly chosen shard key leads to hotspots.
Sharding in System Design Interviews w/ Meta Staff Engineer
This video covers the fundamentals of choosing a shard key and the consequences of getting it wrong, including the classic "celebrity problem."
First, watch the segment on choosing a shard key from good shard keys. This will reinforce the connection between partition keys and hotspots. Pay attention to the example of sharding by creation_date. Next, watch the segment on the celebrity problem. This is the canonical example of an access-pattern-driven hotspot, where a single entity (like a celebrity's profile) receives orders of magnitude more traffic than others.
As the video explains, there are two common scenarios:
- Temporal Hotspot: Sharding data by a timestamp (e.g.,
creation_date) often creates a hotspot on the most recent shard, as new data is typically accessed most frequently. All new writes and most reads will hammer a single server. - The "Celebrity" Problem: When sharding by an entity ID (like
UserID), some entities are vastly more popular than others. All traffic for that celebrity's data—profile views, posts, comments—is directed to the single shard where their data resides, overwhelming it.
2. Workload-Induced Imbalances
Even with a perfect sharding strategy, hotspots can emerge due to the dynamic and heterogeneous nature of workloads in a shared datacenter environment. A foundational Google Research paper, "Accelerating Datacenter Services with Hotspot-Aware Placement," provides deep insights into this phenomenon.
[PDF] Accelerating Datacenter Services with Hotspot-Aware Placement for ...
This paper is a key resource for understanding how Google detects and mitigates hotspots at the infrastructure level. It moves beyond data sharding to focus on scheduling and resource management.
Please read the Introduction (Section 1) and the section on What Causes ToR Hotspots (Section 3.3). Focus on these key concepts: Rack bandwidth demand-supply imbalance: This occurs when, over time, the compute/storage capacity of a rack outpaces its network uplink capacity. For instance, replacing old disks with newer, faster ones increases the potential I/O demand without a corresponding network upgrade. Bandwidth-independent task/data placement: Schedulers like Borg, in their initial design, focused on host-level resources (CPU, memory) and assumed the network was not a bottleneck. This could lead to co-locating many network-intensive tasks on a single rack, overwhelming its Top-of-Rack (ToR) switch.
The paper reveals that in Google's datacenters, most hotspots occur at the ToR switch uplinks, and they are not just transient spikes but can persist for hours or even days. This is a critical insight: hotspots are often an infrastructure-level problem, not just an application-level one.
Hotspot Detection
Before we can mitigate a hotspot, we must first detect it. This is fundamentally a measurement and monitoring problem. The same Google paper defines a hotspot as a network link with utilization persistently above 75%. This threshold is chosen to leave a 25% headroom for maintenance and failure mitigation.
Effective hotspot detection relies on monitoring a combination of metrics:
- Resource Utilization: High CPU utilization, memory pressure, or I/O wait on a specific node or set of nodes.
- Network Throughput: Monitoring traffic on ToR switch uplinks is crucial, as the paper highlights. A consistently high throughput on one link while others are idle is a clear sign of a hotspot.
- Request Latency: The most direct signal from an application's perspective. A sudden spike in tail latency (p95, p99) for requests associated with a particular key range or service instance strongly indicates a performance bottleneck.
- Error Rates: An overloaded service will start shedding load, leading to increased error rates for a subset of requests.
The paper quantifies the severe impact of these hotspots. For example, it notes that Colossus HDD write latencies can be inflated by 2x even at just 40% ToR utilization, and some database query latencies increase by 1.5x at 75% utilization. This underscores that even operations you might consider disk-bound or compute-bound are highly sensitive to network hotspots.
Mitigation Strategies
Mitigation strategies can be categorized into proactive (designing the system to prevent hotspots) and reactive (responding to hotspots once they are detected).
1. Mitigating Data-Driven Hotspots
These strategies address the "celebrity" and temporal hotspot problems we identified earlier. The Hello Interview video you watched covers two excellent solutions.
- Compound Shard Keys: Instead of sharding on
UserIDalone, you create a compound key. For a celebrity, you might append a suffix, likemessi-1,messi-2, ...,messi-N, and distribute their data across N shards. A write would go to a random suffix, and a read would require querying all N shards. This trades increased read complexity for massively improved write distribution for that single hot entity. - Dedicated Celebrity Shards: This involves reactively detecting a hot entity and migrating its data to a dedicated shard, perhaps one with more powerful hardware. The routing layer needs to be aware of this, consulting a lookup service to direct traffic for "celebrities" to the special shard, while all other traffic follows the standard hash-based routing.
2. Mitigating Workload-Driven Hotspots via Aware Scheduling
This is where infrastructure-level intelligence becomes powerful. The Google paper on hotspot-aware placement details two key modifications to Borg (Google's cluster scheduler) and Colossus (its distributed file system).
The core idea behind these modifications is a powerful load-balancing principle known as "The Power of Two Choices." A seminal survey paper on this topic explains the concept beautifully.
[PDF] The Power of Two Random Choices: A Survey of Techniques and ...
This paper provides the theoretical foundation for many modern load-balancing techniques. You don't need to delve into the mathematical proofs, but understanding the core principle is invaluable.
Please read the Introduction (Section 1) and the application to Load balancing with limited information (Section 1.1.3). The key takeaway is that when assigning a task, instead of picking one server at random, picking two at random and assigning the task to the least loaded of the two results in an exponentially better load distribution.
This simple but profound idea is exactly what Google's engineers applied to make their schedulers hotspot-aware.
[PDF] Accelerating Datacenter Services with Hotspot-Aware Placement for ...
This section describes the implementation and remarkable results of Google's hotspot-aware placement strategies.
Please read the section on Hotspot-Aware Placement (Section 5). Focus on the design of the two main strategies: UTP (ToR-utilization aware task placement): Borg was modified to proactively place tasks on servers connected to less-utilized ToRs. When choosing a server for a new task, it samples a few candidates and scores them, with ToR utilization now being a factor. This is a direct implementation of the "Power of Two Choices." It also reactively migrates tasks away from ToRs that become hot. CCP (ToR-capacity aware chunk placement): Colossus was modified to bias the placement of new data chunks away from racks with a known network/storage imbalance (i.e., those with "Low-Uplink" capacity).
The results were dramatic: a 90% reduction in the number of hot ToRs and significant reductions in storage access latency. This demonstrates that for large-scale systems, building network awareness directly into the central scheduler is a highly effective mitigation strategy.
3. Mitigating Transient Hotspots via Hedged Requests
Sometimes a server becomes slow for unpredictable reasons—a background compaction, network jitter, or interference from another task. While the scheduling strategies above handle long-term load, another technique is needed for these transient issues. This is where within-request adaptation comes in, a concept famously articulated by Jeff Dean.
Taming Latency Variability and Scaling Deep Learning, by Jeff Dean, Google, 20131016
In this classic talk, Jeff Dean discusses sources of latency variability and presents several mitigation techniques. We will focus on one of the most impactful: backup requests.
Please watch the following segments: First, he introduces the two classes of adaptation: cross-request (like the scheduling we just discussed) and within-request. Next, he details the "backup request" (or hedged request) technique. The client sends a request to one replica, waits for a very short delay (e.g., just past the 95th percentile latency), and if no response has arrived, it sends a second, identical request to another replica. Finally, he presents the results. This technique dramatically reduces tail latency, especially under heavy load, with a minimal overhead of only about 1% extra resource usage.
Hedged requests are a powerful tool for mitigating the impact of a temporary hotspot. Instead of waiting for a slow server to respond, the client proactively "bets" that another replica might be faster, effectively routing around the transient bottleneck at the request level.
Conclusion
In this lesson, we explored the causes, detection methods, and mitigation strategies for hotspots in distributed workloads. As a future Principal Engineer, your role is not only to solve these problems reactively but to design systems that are inherently resistant to them.
Here are your key takeaways:
- Hotspot Causes: Hotspots stem from both static data distribution imbalances (e.g., bad shard keys, the "celebrity" problem) and dynamic workload imbalances (e.g., network-unaware scheduling, hardware-refresh imbalances).
- Detection: Is achieved through diligent monitoring of resource utilization (CPU, network, I/O) and, most importantly, application-level latency metrics. A persistent imbalance is the key signal.
- Mitigation Strategies: Your toolkit includes a multi-layered defense:
- Data Layer: Employ better partitioning schemes like compound keys or isolate heavy hitters onto dedicated shards.
- Scheduling Layer: Implement hotspot-aware placement in your schedulers, leveraging principles like the "Power of Two Choices" to proactively balance load across the cluster.
- Client Layer: Use within-request techniques like hedged requests to tolerate transient slowness and route around temporary bottlenecks.
In our next lesson, we will broaden our focus from pure performance to overall efficiency. We will describe methods for analyzing and improving resource efficiency (CPU, memory, network) in large-scale systems. Having learned how to make systems fast and resilient, we will now turn our attention to making them cost-effective without compromising performance.