Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Identify Bottlenecks
HLD

Identify Bottlenecks

Finding where the system chokes before load finds it — queueing intuition, the usual suspects, and evidence-based confirmation.

The Definition That Matters

A bottleneck is the component that limits total system throughput — traffic piles up in front of it while neighbors idle. Like highway congestion, widening anywhere else changes nothing:

        5k rps          1k rps ceiling        5k rps
 Client ─────► App tier ─────► Single DB ─────► Cache
               (fine, N nodes)  ▲
                                │ THE bottleneck:
                                everything queues here;
                                app nodes sit idle waiting

Throughput of the chain = throughput of its narrowest pipe. Finding and widening that pipe is the entire exercise.

The Usual Suspects

Bottleneck classTypical formFirst symptom
Single-writer databaseAll writes serialize on one primaryWrite latency climbs with load; replicas idle
Hot key/hot partitionOne cache node or shard gets 10% of keysUneven CPU across symmetric fleet
Connection exhaustionApp pools × nodes exceed DB limit”too many connections”; pool waits
Synchronous fan-outOne request blocks on 10 downstream callsp99 explodes with any dependency hiccup
Chatty internalsN+1 query patternsDB QPS 10x user QPS
Lock contentionRow/counter hot updatesThreads stack on one row

Notice most are data-layer or coordination bottlenecks — stateless tiers scale trivially; shared state is where systems choke.

Queueing Intuition

Latency degrades non-linearly as utilization rises — this is why the 70% rule exists:

 utilization → latency multiplier (M/M/1 intuition)

 50%   ≈ 2x service time     calm
 70%   ≈ 3.3x                noticeable
 85%   ≈ 6.7x                SLOs breaking
 95%   ≈ 20x                 outage-shaped

 a component at 50% capacity is not half-wasted;
 it is the headroom that keeps p99 alive at peaks

Bottleneck analysis therefore targets components whose peak utilization approaches 70–80%, not averages.

Finding Them: Prediction, Then Evidence

Predict by walking the request flow asking “what saturates first at 10x?” — usually one of: primary DB writes, hottest cache, fan-out aggregator.

Confirm with evidence, never assumption:

Signal sourceWhat shows
Latency percentiles per dependencyWhich leg owns the tail
Utilization per component at peakWho approaches the cliff
Queue depths / pool wait timesWhere demand exceeds service rate
Load test at 2x current peakThe failure you’d meet next quarter

The load test is the honest oracle: it converts theory into observed collapse points.

Fixing Follows a Ladder

Once confirmed, widen in cost order:

 1. reduce demand      cache hits, batching, trimming chatty calls
 2. split the work     read replicas, functional partitioning
 3. add parallelism    more nodes behind LB (stateless only)
 4. divide the data    sharding — the expensive, last-resort widening
 5. shed load          deliberate degradation when all else lags spikes

Jumping to step 4 before exhausting 1–3 is how premature complexity happens.

Interview Framing

“Where’s your bottleneck?” is a standing interview question from the moment a diagram exists. Scoring reflex: point at the single-writer DB or the fan-out path immediately, justify with the numbers already estimated (“600 matches/sec against one Postgres writer puts us near the cliff”), and name the fix ladder rung. Bottleneck talk is where estimation pays rent.

My Private Notes

Notes are auto-saved locally to this device.