Skip to main content
In this lesson we’ll intentionally direct follower traffic to a shard cluster, observe a single shard become overloaded (a “hot shard”), and then apply operational fixes to rebalance traffic and restore even load across shards.
This hands-on exercise shows how to detect a hot-shard condition and apply targeted remediation. You’ll practice traffic routing, metric inspection, and corrective actions such as adjusting routing weights, scaling, or reassigning shard ranges.
What you’ll accomplish
  • Route follower traffic to the shard cluster to reproduce a hot-shard scenario.
  • Monitor shard metrics (request rate, latency, CPU/memory) to identify the hot shard.
  • Apply fixes to redistribute traffic and reduce overload on the hot shard.
  • Validate that the cluster returns to balanced traffic distribution.
Prerequisites Step-by-step guide
  1. Route follower traffic to the shard cluster
  • Purpose: Direct follower requests so they hit the shard layer. This lets you reproduce imbalanced traffic patterns.
  • How to do it:
    • Update your router / gateway to send follower traffic to the shard cluster. This is typically a configuration change in your control plane or ingress (e.g., altering weights, endpoint lists, or route rules).
    • Example (conceptual placeholder — adapt to your control plane):
      • Update route weight: POST /api/routes/<route-id>/weights with payload to set shard-cluster weight to 1.0.
    • If you use Kubernetes Services and want to target a specific shard for testing, update the Endpoints object or point a test client directly to http://<shard-ip>:<port>.
  1. Generate load to reproduce the hot shard
  • Purpose: Create traffic to cause one shard to become overloaded so you can observe symptoms.
  • Example commands:
    • Using a simple loop:
    • Using fortio (recommended for realistic load):
    • Replace <follower-endpoint> with your test endpoint.
  1. Observe and identify the hot shard
  • What to watch (Prometheus/Grafana queries):
    • Request rate by shard:
    • 95th percentile latency by shard:
    • CPU usage (per pod):
  • Quick kubectl checks:
    • List pods and status:
    • Resource usage (metrics-server):
  • Symptom mapping:
You will make live changes to routing or shard assignments. Validate changes in a staging environment first if possible. Roll back quickly if error rates increase or user impact grows.
  1. Apply fixes to rebalance traffic Choose one or more actions depending on diagnostics:
  • Adjust routing weights (preferred quick fix)
    • Reduce weight to the hot shard and increase weight to other shards.
    • Example conceptual API call:
    • Verify the new distribution quickly using request-rate metrics.
  • Scale the overloaded shard
    • If the shard is CPU-bound, scale replicas or increase resources:
  • Reassign shard ranges (reshard)
    • If the root cause is uneven key distribution, move some key ranges from the hot shard to others.
    • Reshard steps typically include:
      • Pause writes to affected ranges (if your system requires it).
      • Move key ranges or update shard metadata in the control plane.
      • Drain and re-route traffic for moved ranges.
    • Exact commands depend on your sharding system — follow your platform’s resharding procedure.
  • Evict or restart unhealthy instances
    • If a pod has degraded performance but is not resource-limited, restart it:
  1. Validate remediation
  • Confirm request rate and latency have evened out:
    • Re-run the Prometheus queries from step 3 and confirm no single shard dominates traffic.
  • Confirm resource usage normalized:
  • Check error rates dropped:
  • If you adjusted routing weights, validate routing config is persisted and that the control plane has applied the new weights.
Postmortem checklist (after fix)
  • Record the root cause (routing config, key distribution, insufficient capacity).
  • Capture the exact remediation steps and timestamps.
  • Consider long-term mitigations:
    • Improve hashing or shard key selection.
    • Add autoscaling rules for shard replicas.
    • Implement more granular routing or a circuit breaker for hot shards.
Useful references Proceed to the hands-on steps in your environment to reproduce a hot shard and practice the fixes described above.

Watch Video

Practice Lab