SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
  • Scalability
  • Availability
  • Reliability
  • Single Point of Failure (SPOF)
  • Latency vs Throughput vs Bandwidth
  • Consistent Hashing
  • CAP Theorem
  • Fault Tolerance and Redundancy
  • Failover
  • Stateless vs Stateful
  • Concurrency vs Parallelism
  • Capacity Planning
  • Back Pressure
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Foundations/Core Concepts

Capacity Planning

Work out how much hardware you will need before the traffic arrives.

โฑ 12 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Capacity planning means working out how much hardware you will need (servers, disk, network, database power) before the traffic arrives, so users never meet a system that is full.

  • You start with today's traffic and a guess for how fast it will grow.
  • You measure what one server can really handle (a load test), and plan to run it well below its limit, to keep some headroom.
  • You add spare servers for failures, and you order early, because new capacity takes time to arrive.

02Concept: What is it?

Every system has a limit: the most requests per second it can handle before it gets slow or starts to fail. Capacity planning is the habit of knowing that limit, knowing how far today's traffic is from it, and acting before the two meet.

The basic recipe is short. Forecast the future traffic. Measure how much one machine can do. Divide to get a number of machines. Then add safety: headroom for spikes, and spares for failures.

The capacity planning recipe
๐Ÿ“ˆForecasttraffic in 6-12 months
โ†’โ†“
๐ŸงชLoad testwhat one server handles
โ†’โ†“
โž—Dividetraffic รท safe capacity
โ†’โ†“
๐Ÿ›ก๏ธAdd safetyheadroom + spares
โ†’โ†“
๐Ÿ›’Order earlylead time
Each step turns a guess into a number you can act on.

A simple example (round numbers): the site gets 2,000 requests per second. A load test shows one server handles 200 before it slows down. You want servers to run at about 60% busy, so the safe capacity is 120 per server. 2,000 รท 120 = 16.7, so you need 17 servers, plus 1 spare (N+1) = 18.

๐Ÿง Never plan for 100%
A server that is 100% busy has no room for a spike, a deploy, or a failed neighbour. Queues grow fast near the limit, so delays jump long before the machine is fully used. Plan for a comfortable target, often well below the limit.

03Real-Life Example

๐ŸตThe Restaurant Before the Holiday Season
A restaurant knows that December is busy. The owner counts how many guests one waiter can serve in an evening (say 20), and does not plan for waiters to run flat out all night, because one big group would break the evening. The owner expects 30% more guests this December, hires extra waiters in November (hiring and training take weeks), and keeps one extra waiter on call in case someone is sick. Hiring on December 24th would be far too late.
Restaurant
Capacity planning
Guests per evening
Requests per second
Guests one waiter can serve
What one server handles (from a load test)
Not running waiters flat out
Headroom: a target load such as 60%
30% more guests than last year
Growth forecast
A spare waiter on call
N+1 spare server
Hiring takes weeks
Lead time to get new capacity
A sudden coach party arrives
A traffic spike
What 'running out' looks like
๐ŸŸขPlenty of roommonth 1-4
โ†’โ†“
๐ŸŸกGetting closeorder now
โ†’โ†“
๐Ÿ”ดFullslow, then errors
The fleet is fine for months, then growth crosses the line. The gap between 'ordered' and 'arrived' is the lead time.

04Why Do We Need It?

๐ŸšฆAvoid outages
A system that hits its limit gets slow, then fails. Planning keeps you away from that edge.
๐Ÿ’ฐAvoid waste
Buying ten times too much costs real money every month. Planning gives you the right size.
โณRespect lead time
Servers, licences, cloud quotas and database moves take days or weeks. You need to start early.
๐Ÿ›ก๏ธSurvive failures
Spare capacity lets you lose a machine or a whole zone without users noticing.
๐Ÿ“†Prepare for events
Sales, launches and holidays are known in advance. You can plan for them.
๐ŸงพMake good budgets
A forecast turns 'we might need more' into a number that finance can approve.
Capacity planning is cheap insurance: a little maths now, instead of a crisis when the traffic arrives.

05Where Do We Use It?

๐Ÿ–ฅ๏ธWeb and app servers
How many instances do we need behind the load balancer for the expected requests per second?
๐Ÿ—„๏ธDatabases
CPU, memory, disk space, disk speed and connection limits. Databases are the hardest to grow quickly.
๐Ÿ’พStorage
Disk grows every day. Estimate the growth, so you add disks before the volume fills up.
๐ŸŒNetwork
Bandwidth, load balancer limits and connection counts can run out before CPU does.
๐Ÿ“จQueues and caches
Queue size, cache memory and hit rates all need room to grow.
โ˜๏ธCloud accounts
Quotas and limits per account or region can block you, even when money is not the problem.

06Types / Parts / How It Works

Ways to provide the capacity

Three common approaches
Reserved / own hardware
๐ŸขFixed fleetbought ahead
Cost per serverlowest
Flexibilitylow
Autoscaling
๐Ÿ“ถAdd and remove on demandby a rule
Cost per servermedium
Flexibilityhigh
Manual / scheduled
๐Ÿ—“๏ธAdd before known eventsa person decides
Cost per servermedium
Flexibilitymedium
Reserved Autoscaling Scheduled
Most real systems mix them: a steady base plus flexible capacity for peaks.

The bars are only a rough, illustrative comparison.

The numbers you need

NumberWhat it meansWhere it comes from
Current loadRequests per second now (average and peak)Monitoring and dashboards
Growth rateHow fast the load rises, per month or yearPast trend plus business plans
Per-server capacityRequests one server handles before it slows downA load test, not a guess
Target utilisationHow busy you allow servers to be, such as 60%Your tolerance for spikes
RedundancySpare servers: N+1 or N+2How many failures you must survive
Lead timeTime from deciding to having the capacityYour cloud, vendor or procurement process
๐Ÿ“Autoscaling is not magic
Autoscaling needs time to start new servers, so a very sharp spike can still hurt. It also cannot grow things that do not scale out easily, such as a single database primary. Use it together with headroom, not instead of it.
VisualizerWhen does my fleet run out?Raise the growth rate and watch the red bars appear. Then lower the target load to leave more headroom, switch between N, N+1 and N+2, and set a lead time to see the order date.
Spare servers for failures

N+1: one extra server, so the system survives losing any one machine.

Servers needed each month (cyan = your fleet is enough, red = too small). The dashed line is the fleet you own.
M0
10
M1
11
M2
12
M3
13
M4
14
M5
15
M6
16
M7
18
M8
19
M9
21
M10
23
M11
25
M12
28
Needed today
10
for 1000 req/s
Needed at month 12
28
for 3138 req/s
Fleet too small from
month 1
you own 10
Order by
now
2 month lead time
Extra to buy
18
by month 12
At month 1 you need 11 servers but have 10. New servers take 2 months to arrive, so the order date was already in the past. This is the late-purchase trap.

A simplified, illustrative model with round numbers. Servers needed = traffic รท (server speed ร— target load) + spares, rounded up. Real plans also check memory, disk, network and database limits, and they mix steady growth with spikes.

07How to Use It / Steps / Implementation

A simple capacity planning routine

  1. 1
    Measure today
    Collect the average and the peak load (requests per second), plus CPU, memory, disk and network. Peaks matter more than averages.
  2. 2
    Find the real limit
    Run a load test and note the load where delays start to rise. This is the true capacity of one server for your code.
  3. 3
    Choose a target load
    Decide how busy servers may be in normal times (for example 50-70%). The rest is headroom for spikes, deploys and failures.
  4. 4
    Forecast growth
    Use the past trend and known events: a launch, a sale, a new country. Make a low, expected and high case.
  5. 5
    Calculate
    Servers = peak traffic รท (server capacity ร— target load), rounded up.
  6. 6
    Add redundancy
    Add N+1 (or N+2 for important systems), so losing a machine, or a zone, does not overload the rest.
  7. 7
    Subtract lead time
    If new capacity takes 6 weeks, you must decide 6 weeks before you need it, not on the day.
  8. 8
    Review often
    Compare forecast with reality every month or quarter and update the plan. Set alerts for 'capacity used' (for example at 70%).
๐Ÿ’กFind the bottleneck first
Capacity is set by the smallest limit: CPU, memory, disk, network, connections, or a dependency such as the database. Adding web servers does nothing if the database is the part that is full.
โš ๏ธPlan for failure too
If you have 4 servers each at 80% busy and one fails, the other 3 must carry 107% of a normal load. Plan for the load after a failure, not only when everything is healthy.

08Key Terms to Know

TermMeaning in easy words
CapacityThe most work a system can do while still meeting its goals, such as requests per second
HeadroomThe unused part of capacity kept as a safety margin
UtilisationHow much of the capacity is in use right now, as a percentage
Load testA test that sends a lot of traffic on purpose, to find the limit
Peak loadThe highest traffic over a period (the busiest minute of the day)
Growth forecastA guess of how traffic will increase over time
N+1 / N+2N servers needed for the load, plus 1 or 2 spares for failures
Lead timeHow long it takes from asking for capacity to having it ready
AutoscalingAdding or removing servers automatically, based on load
BottleneckThe part that hits its limit first and holds back everything else
Over-provisioningHaving far more capacity than needed, which wastes money

09Pros, Cons and Trade-offs

โœ… Pros
  • Fewer outages caused by running out of room
  • Money spent on what you need, not on guesses
  • Time to react, because you see problems coming
  • Better answers for budgets and managers
  • Safe handling of known events such as sales
โš ๏ธ Cons
  • Forecasts are guesses, and can be wrong
  • Needs good data and regular reviews
  • Load tests take effort and should match real traffic
  • Too much safety wastes money
  • Hard to be exact for new products with no history

Trade-offs

ChoiceWe gainWe lose
Lower target load (more headroom)Safe against spikes and failuresMore servers and a higher bill
Higher target loadLower cost per requestLittle room, so delays jump during a spike
Reserved capacityCheaper per server over timeCannot shrink quickly, and a wrong guess is a waste
AutoscalingPay for what you use, handles changing loadNew servers need time, and it needs tuning
More redundancy (N+2)Survives more failuresIdle capacity most of the time
Plan far aheadSmooth, calm purchasesA longer forecast is a less accurate forecast

10Common Problems and Mistakes

Common mistakes

  1. Planning for the average. Users arrive in peaks, so average traffic hides the real need.
  2. Planning for 100% use. A fully busy system has no room for a spike or a failure.
  3. Guessing the server limit. Without a load test, the "per-server capacity" may be far off.
  4. Ignoring the bottleneck. Adding web servers while the database is full does not help.
  5. Forgetting lead time. Deciding on the day you need the capacity is too late.
  6. Forgetting failures. The plan works only when every server is healthy.
  7. Never reviewing. A plan from last year is a guess about a year that is already over.

Things to watch

๐ŸงจSurprise spikes
A viral post or a news mention can multiply traffic in minutes. Use autoscaling, caching, rate limits and load shedding as a safety net.
๐ŸงฑHidden limits
File handles, ports, connection limits and cloud quotas can stop you before CPU does.
๐Ÿ“‰Efficiency changes
A new release can make each request cost more (or less). Re-run the load test after big changes.
๐ŸงฎCompounding growth
10% per month looks small, but it is about 3x in a year. Always compound it.

11Real-World Examples

๐Ÿ›๏ธShopping events
Retailers add capacity ahead of big sale days, and test it with load tests beforehand.
๐ŸŽฌStreaming launches
A popular show release brings a huge peak at one moment. Teams prepare capacity and caches in advance.
๐Ÿ›๏ธTax and ticket sites
Deadlines and ticket sales create sharp peaks. Some use waiting rooms to keep demand within capacity.
โ˜๏ธCloud teams
Mix reserved capacity for the steady base with autoscaling for peaks, and watch account quotas.
๐Ÿ“ฑApp launches
A new feature or an app-store feature can bring a sudden jump, and staged rollouts help control it.
๐ŸฆMonth-end batch jobs
Banks and payroll systems know that the end of the month is heavy and plan for it.
๐Ÿ“Note
All numbers on this page are round, illustrative values. Real capacity depends on your code, your hardware and your traffic mix.
Mini case: a fleet before and after a failure
๐Ÿ–ฅ๏ธ4 serverseach 80% busy
โ†’โ†“one fails
๐Ÿ–ฅ๏ธ3 serverseach about 107% needed
โ†’โ†“with a spare
๐Ÿ–ฅ๏ธ5 serversone fails, 4 left at 80%
Capacity must be enough after a failure, not only before it.

12Related Topics to Read Next

Back-of-the-Envelope Estimationโ†’

The quick maths you use to get the first capacity numbers.

Scalabilityโ†’

Capacity planning is how you decide how much to scale and when.

Fault Tolerance and Redundancyโ†’

The spare capacity (N+1) comes from redundancy.

Back Pressureโ†’

What to do when demand is higher than the capacity you have.

What are Load Balancers?โ†’

They spread traffic over the fleet you planned.

SLA, SLO and SLIโ†’

Your reliability goals decide how much headroom you need.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”What: plan the hardware you need before the traffic arrives.
  • โœ”Formula: servers = peak รท (server limit ร— target load), rounded up, plus spares.
  • โœ”Target: keep servers well under 100% (for example 50-70%) for spikes and failures.
  • โœ”Measure: load test one server. Never guess its limit.
  • โœ”Spares: N+1 or N+2, and check the load after a failure.
  • โœ”Lead time: decide early. Order date = needed date minus lead time.
  • โœ”Bottleneck: the smallest limit wins. Check database, network and quotas too.
  • โœ”One line: โ€œKnow your limit, watch the growth, and buy the room before you need it.โ€
โ† Previous
Concurrency vs Parallelism
Next โ†’
Back Pressure