Finding bottlenecks in a system design: utilisation from capacity estimates, the single database, hot partitions, synchronous call chains, shared locks and serialisation points, and the fix for each.
I find bottlenecks by walking the request path with numbers: for each component I compare the expected load from the capacity estimate with what it can handle, and the highest utilisation breaks first. The usual suspects are the single primary database (writes can't scale out), hot partitions where one key gets most of the traffic, synchronous call chains where latencies add up and availabilities multiply, and serialisation points such as a shared lock, a global counter or a single worker. I use Little's Law to check pools: 2,000 req/s × 50 ms = 100 concurrent DB connections, which already exceeds a default pool of 100 at any latency spike. Fixes go in order: remove work, cache, move work off the request path with a queue, then partition. The trade-off is that every fix adds staleness or complexity, and the bottleneck simply moves to the next component.
"I don't look for bottlenecks by staring at boxes — I put numbers on the arrows. I take the capacity estimate, say 3,000 requests per second at peak with 10% writes, and walk one request through the diagram: the gateway, the API instances, the cache, the database, any downstream calls. For each component I ask what it can sustain and divide. If the API tier can do 1,500 req/s per instance and I have four, that's 50% utilisation and fine. If the single Azure SQL primary can take about 2,000 small writes a second at that tier and I'm asking for 300, that's fine today but it's the one thing I can't scale out by adding instances, so I flag it.
Then I check the four usual suspects. One: the single database — every stateless tier scales horizontally, but the primary doesn't, so it is usually where a design breaks first. Two: hot partitions — I've partitioned, but the key is skewed, so one tenant, one product on sale, or today's date takes 40% of the traffic and one partition melts while the others idle. Three: synchronous chains — if a checkout calls inventory, pricing and payment in series, latency adds up and availability multiplies down, and one slow dependency ties up threads everywhere. Four: serialisation points — a shared lock, a single-row counter, a singleton job, anything that forces requests through one at a time. Little's Law ties it together: concurrency equals throughput times latency, so when latency doubles, the connection pool you sized for normal days is suddenly exhausted.
The mistake I see is fixing the bottleneck that's easiest to talk about — adding API instances — when the database is the real limit, which just sends more load to it faster. My order is: remove work, cache, move work off the request path with a queue, and only then partition. And I always say what breaks next, because a bottleneck you fix just moves."
| Bottleneck | How you spot it in the design | Typical fix | What it costs |
|---|---|---|---|
| Single primary database | All writes and most reads hit one box; DTU/vCore or log-write rate near its limit | Cache reads, read replicas, CQRS read model, then partition writes | Staleness, replica lag, cross-partition queries |
| Hot partition / hot key | Key with skew: tenant, celebrity, date, a flash-sale SKU |
Better key, key salting, split hot tenants, a write-behind counter | Scatter-gather reads, more complex key logic |
| Synchronous call chain | Arrows that go A→B→C→D on the request path | Parallelise, cache, make it async with events, collapse the chain | Eventual consistency, harder debugging |
| Shared lock / serialisation point | Global counters, single-row balances, sp_getapplock, one leader |
Shard the counter, optimistic concurrency, partition the queue | More code, approximate values |
| Pool / port exhaustion | High concurrency × latency against a fixed pool (DB connections, SNAT ports, ThreadPool) | Reduce latency, size pools by Little's Law, connection reuse | Hidden until a latency spike |
| Fan-out | One request → N downstream calls (feeds, notifications) | Precompute (fan-out on write) or batch | Storage and write amplification |
| Component | Peak load | Capacity | Utilisation |
|---|---|---|---|
| API (4 × Container Apps replicas) | 3,000 req/s | 4 × 1,500 = 6,000 req/s | 50% |
| Redis (C2) | 2,400 reads/s (80% hit) | ~50,000 ops/s | 5% |
| Azure SQL primary | 600 reads/s (cache misses) + 300 writes/s | ~2,000 mixed/s at this tier (measured) | 45%, and it can't scale out |
| Payment provider | 30 req/s | 100 req/s contractual rate limit | 30%, but an external limit |
The interviewer wants the last column, and the comment that the database is the real ceiling even though it's under 50%.
| Situation | Do | Don't |
|---|---|---|
| Utilisation < 50% at 2× peak | Note it and move on | Partition 'just in case' |
| Read-heavy, DB is the limit | Cache + read replicas | Shard first |
| Write-heavy, single key | Fix the key or the model | Add API instances |
| Slow downstream on hot path | Timeout + async + fallback | Raise the timeout |
In a [retail] API, adding instances during a sale increased p99 latency from 300 ms to 4 s because each instance opened up to 100 connections against an Azure SQL tier capped at [400] concurrent workers. Caching the product catalogue cut database reads by 85%, and moving order confirmation emails onto Service Bus removed two synchronous calls; peak throughput doubled with the same database tier.
Checks whether the candidate can reason quantitatively about where a design fails under load, instead of listing generic scaling techniques.
Green flags
Red flags
A component with arrival rate λ and service rate μ has utilisation ρ = λ/μ. In a simple queue (M/M/1) the average time in the system is 1/(μ − λ), which means latency grows slowly up to about 70% utilisation and then explodes:
utilisation: 50% 70% 80% 90% 95%
latency (x): 2x 3.3x 5x 10x 20x (relative to service time)
That is why a design that runs "fine" at 80% falls over with a 10% traffic bump. Plan for peak at ≤ 60–70% on anything you can't scale quickly.
L = λ × W: concurrency equals throughput times latency. It sizes everything with a fixed number of slots:
2,000 req/s × 0.050 s = 100 concurrent DB calls
2,000 req/s × 0.500 s = 1,000 concurrent DB calls <- latency spike
In .NET, SqlConnection pooling defaults to Max Pool Size=100 per connection string per process. A latency spike turns into InvalidOperationException: Timeout expired... max pool size was reached, which looks like an app bug but is Little's Law.
[API x N] ---> [Azure SQL primary] <- every write lands here
\ |
\----> [read replica] (lag ms..s)
Stateless tiers scale horizontally; the primary scales only vertically (bigger SKU, Hyperscale for storage and read scale-out). Write throughput is bounded by log write rate and lock contention. The escalation ladder: index and query tuning → cache → read replicas (ApplicationIntent=ReadOnly) → CQRS read models → partition by tenant or key.
Partitioning only helps if load spreads evenly. Skew comes from:
2026-11-22) — all of today's writes on one partitionIn Cosmos DB a single logical partition is capped at 10,000 RU/s and 20 GB (as of November 2026), so a hot key throttles with 429s no matter how much total RU you provision.
client -> API -> pricing -> inventory -> payment
50ms +80ms +60ms +400ms = ~590ms p50
Latency adds; tail latency adds worse (the p99 of the chain is close to the sum of p99s). Availability multiplies: 99.9% × 99.9% × 99.9% = 99.7%. And a slow callee holds the caller's threads and connections, so failure cascades upstream unless you have timeouts and bulkheads.
Anything that forces one-at-a-time: an UPDATE Counters SET Value = Value + 1 WHERE Id = 1, a balance row updated on every transaction, a singleton scheduler, a distributed lock. Throughput is capped at 1 / (lock hold time). A 5 ms hold allows at most 200 operations per second, regardless of hardware.
dotnet-counters monitor --counters Microsoft.Data.SqlClient.EventSource to watch active pooled connections while you raise load.A sharded counter removes a classic serialisation point: instead of every request updating one row, writes spread across N rows and reads sum them.
namespace Shop.Counters;
using Microsoft.EntityFrameworkCore;
public sealed class CounterShard
{
public required string Name { get; init; }
public int Shard { get; init; }
public long Value { get; set; }
}
public sealed class CounterDbContext(DbContextOptions<CounterDbContext> options) : DbContext(options)
{
public DbSet<CounterShard> Counters => Set<CounterShard>();
protected override void OnModelCreating(ModelBuilder b) =>
b.Entity<CounterShard>().HasKey(c => new { c.Name, c.Shard });
}
public sealed class ShardedCounter(CounterDbContext db)
{
public const int Shards = 16; // 16 rows -> roughly 16x less contention on the hot row
// Run once when a counter is created, so every shard row exists before writes start.
public async Task CreateAsync(string name, CancellationToken ct)
{
db.Counters.AddRange(Enumerable.Range(0, Shards)
.Select(i => new CounterShard { Name = name, Shard = i }));
await db.SaveChangesAsync(ct);
}
public async Task IncrementAsync(string name, CancellationToken ct)
{
// Pick the shard outside the query so it becomes a plain SQL parameter.
var shard = Random.Shared.Next(Shards);
// A single UPDATE ... SET Value = Value + 1 is atomic: SQL Server takes a row lock,
// so two writers on the same shard are serialised, never lost. No read-modify-write race.
var rows = await db.Counters
.Where(c => c.Name == name && c.Shard == shard)
.ExecuteUpdateAsync(s => s.SetProperty(c => c.Value, c => c.Value + 1), ct);
if (rows == 0)
throw new InvalidOperationException($"Counter '{name}' has not been created.");
}
public Task<long> ReadAsync(string name, CancellationToken ct) =>
// Reads pay a small cost (sum of 16 rows) to make writes scale.
db.Counters.Where(c => c.Name == name).SumAsync(c => c.Value, ct);
}
Sizing a connection pool with Little's Law instead of guessing:
namespace Shop.Capacity;
public static class LittlesLaw
{
// concurrency = throughput (per second) x latency (seconds)
public static int RequiredSlots(double requestsPerSecond, TimeSpan latency, double headroom = 2.0) =>
(int)Math.Ceiling(requestsPerSecond * latency.TotalSeconds * headroom);
}
// Per instance: 500 req/s x 40 ms x 2 headroom = 40 connections, well under Max Pool Size=100.
// Across 10 instances that is 400 concurrent sessions: check it against the Azure SQL tier's worker limit.
Bottleneck analysis is the cheapest senior signal in a design interview: it shows you think in numbers, not boxes. The two habits that separate seniors are using utilisation (not raw throughput) and saying what breaks next. Pair every claim with how you'd verify it: a load test with a step profile, Application Insights dependency timings, Query Store top waits.
| Fix | When it fits | Cost | When not to |
|---|---|---|---|
| Cache | Read-heavy, tolerant of seconds of staleness | Invalidation, stampedes | Strongly consistent reads (balances) |
| Read replicas | Reads dominate, some lag OK | Replica lag, routing logic | Write-bound systems |
| Queue / async | Work not needed for the response | Eventual consistency, ops | User must see the result now |
| Partition / shard | Writes exceed one node | Cross-partition queries, resharding | Before cheaper fixes are exhausted |
| Bigger SKU | Short-term relief | Money, a ceiling | As the only plan for 10× growth |
Vertical scaling means a bigger machine — simple, but it has a ceiling and stays a single point of failure. Horizontal scaling means more instances, which requires stateless services: no in-memory sessions, a shared cache, and shared ASP.NET Core Data Protection keys.
My order, driven by where the bottleneck is:
Each step trades simplicity for capacity: caches and replicas bring staleness, queues bring eventual consistency, and sharding brings cross-shard queries and operational pain.
Throughput that plateaus with spare CPU points at threads waiting, not working. I confirm with dotnet-counters: monitor-lock-contention-count (the dotnet.monitor.lock_contentions metric) climbing with load. Then I find which lock with dotnet-trace using the contention events (--clrevents contention), which record the waiting stack and duration, or a dotnet-dump where clrstack -all shows dozens of threads in Monitor.Enter on the same object.
Fixes, in order: shrink the critical section and never hold a lock across I/O; replace it with ConcurrentDictionary, Interlocked or an immutable snapshot swapped atomically; or shard the lock per key. Then I verify with the same load test. The trade-off: lock-free designs are harder to get right, so I take the simplest one that removes the contention.
A capacity estimate turns user numbers into load. Start with daily active users × actions per user to get requests per day, divide by ~86,400 s (round to 10^5) for average requests/s, then multiply by a peak factor (2–10×, often 3×). For storage, multiply writes per day by record size and 365, then add indexes and replicas. For bandwidth, multiply requests/s by payload size.
Example: 10M DAU × 20 reads = 200M reads/day ≈ 2,300/s average, ~7,000/s peak.
The point is not precision — it's deciding whether one database and a cache are enough or you need partitioning. The trade-off is speed versus accuracy: round hard, but state every assumption.
How to tell it (STAR)
**S:** During a [Click Frenzy] sale our checkout API got slower the more we scaled it. **T:** I had to find the real bottleneck while the sale was live. **A:** I used the application map and Query Store to show the time was in SQL, and Little's Law to show our extra replicas were exhausting the database's workers. I capped replicas, scaled the database for the day, then cached the catalogue and moved emails to a queue. **R:** Database reads fell [85%], p99 returned to [~300 ms], and the next sale handled [2×] the traffic on the same tier.
Last updated 23 Nov 2026.