Skip to main contentSkip to user menuSkip to navigation

Scalability Basics

Master scalability fundamentals: vertical vs horizontal scaling, bottleneck identification, and scaling strategies with real examples.

15 min readBeginner
Not Started
Loading...

What is Scalability?

Scalability is a system's ability to maintain or improve performance as workload increases. It means handling growth in users, data, and requests without breaking, slowing down, or becoming prohibitively expensive.

Why Scalability Matters

ReasonWhy it matters
Business impactInstagram supported millions of users with 13 employees, and WhatsApp supported 2B users with 55 engineers. Good scalability enables lean teams.
Growth enablerA scalable system can go viral, survive Black Friday traffic, and grow from 100 to 100M users without a complete rewrite.
Cost efficiencyThe system can pay for what it uses, scale out during peaks, and scale down at night.
  • The scalability test: A truly scalable system maintains or improves performance as load increases. If doubling users doubles response time or cost, the system is growing linearly rather than scaling well. True scalability aims for sub-linear cost growth and stable or better performance.

Core invariant

scale the resource that a measured workload is exhausting while preserving correctness and operability. User count alone does not justify a distributed architecture; request shape, data growth, and service targets do.

The Scalability Challenge

Your startup launches on Monday with 100 users. By Friday, a celebrity tweet sends you to 100,000 users. Does the system survive or crash? This is the scalability challenge every successful product faces.

What Happens Without Scalability

  • Pokemon GO (2016): Crashed on launch day and could not handle viral success.
  • HealthCare.gov (2013): Cost $2B and failed under load on day one.
  • Knight Capital (2012): Lost $440M in 45 minutes because of poor deployment scaling.
  • Common pattern: Slow pages lead to frustrated users, lost revenue, and damaged reputation.

What Good Scalability Enables

  • Netflix: Moved from DVDs to 230M+ global streaming users.
  • Zoom: Handled a 10x traffic spike during COVID-19 without major issues.
  • Discord: Grew from gaming chat to 150M+ users across many communities.
  • Common pattern: Stable performance leads to happy users, sustainable growth, and market strength.

Two Approaches to Scaling

When a system reaches capacity, there are two choices: make existing machines more powerful, called vertical scaling, or add more machines, called horizontal scaling. Each choice changes cost, complexity, and maximum capacity.

The original visual comparison used these relative values:

DimensionVertical scalingHorizontal scaling
Maximum capacity100 units1,000 units
Initial cost$100$300
Complexity20/10080/100

Vertical Scaling (Scale Up)

Vertical scaling adds more power to an existing machine: more CPU, RAM, disk, or network bandwidth.

Advantages

  • Simple, with no architecture changes required.
  • Low complexity because the same code runs on a larger machine.
  • Avoids many distributed-system challenges.
  • Easy to implement and maintain.

Disadvantages

  • Hardware limits prevent infinite growth.

  • High-end hardware becomes disproportionately expensive.

  • One machine remains a single point of failure.

  • Upgrades can require downtime.

  • Example: Upgrade an AWS EC2 instance from t3.medium with 2 vCPU and 4 GB RAM to m5.4xlarge with 16 vCPU and 64 GB RAM, increasing cost from about $34/month to $560/month.

Horizontal Scaling (Scale Out)

Horizontal scaling adds machines to a resource pool and distributes load across them.

Advantages

  • Nearly unlimited scaling potential.
  • Linear cost growth as capacity is added.
  • Redundant machines improve availability.
  • Scaling can happen without downtime.

Disadvantages

  • Load balancing and state management increase complexity.

  • Applications often need stateless design and code changes.

  • Consistency and network latency become distributed-system concerns.

  • More machines create more operational overhead.

  • Example: Move from one server to ten servers behind a load balancer. At $34/month per server, capacity grows roughly 10x while unit cost stays constant.

When to Use Which

Choose vertical scaling when:

  • The product is in its early stages with hundreds or a few thousand users.
  • The application is not designed for distribution.
  • A quick capacity gain is needed without code changes.
  • Database performance is the current bottleneck.

Choose horizontal scaling when:

  • The system is planning for more than 100K users.
  • High availability and fault tolerance are required.
  • Cost-effective growth at large scale matters.
  • The workload is stateless and parallelizable.

Zero to Millions: The Complete Journey

Alex Xu's framework shows how systems evolve from a single user to millions, with each stage introducing specific challenges and architectural solutions.

Stage 1: Single Server (1-1,000 Users)

Architecture

  • Web app, database, and cache on one server.
  • DNS points to one IP address.
  • Users connect directly to the server.

What breaks first

  • CPU or memory limits at roughly 500-1,000 users.
  • Database connection-pool exhaustion.
  • The server is a single point of failure.

Stage 2: Database Separation (1K-10K Users)

Architecture changes

  • Separate web and database servers.
  • Scale both servers vertically.
  • Connect the tiers over the network.

Benefits

  • Web and database tiers can scale independently.
  • Resource utilization improves.
  • The system supports roughly 5-10x more users.

Stage 3: Load Balancer and Cache (10K-100K Users)

New components

  • A load balancer distributes traffic across web servers.
  • Redis or Memcached provides a cache layer.
  • A CDN serves static assets.
  • Redis or the database stores sessions.

Performance gains

  • An 80-90% cache hit ratio.
  • Static assets can load 10x faster.
  • The application can scale horizontally.

Stage 4: Database Scaling (100K-1M Users)

Database strategy

  • Primary-replica replication.
  • Read replicas to scale read traffic.
  • Write-through caching for consistency.
  • Connection pooling.

Key decisions

  • Split read and write traffic, often around a 90/10 ratio.
  • Choose SQL or NoSQL according to access patterns.
  • Plan explicitly for eventual consistency.

Stage 5: Microservices (1M+ Users)

Service decomposition

  • Break the monolith into services.
  • Use a service mesh for communication.
  • Process asynchronous work with message queues.
  • Give each service ownership of its database.

New challenges

  • Distributed-system complexity.
  • Service discovery and configuration.
  • Monitoring and logging across services.
  • Data consistency across service boundaries.

Key Takeaways

  • Scale incrementally: Do not build for 1M users when the product has 1K.
  • The database is usually the bottleneck: Plan the data layer carefully.
  • Caching wins: As much as 80% of requests can often be served from cache.
  • Stateless design: Enables horizontal scaling.
  • Monitor everything: You cannot optimize what you cannot measure.

Real-world Scaling Examples

Netflix

  • Challenge: 230M+ subscribers, 15,000+ titles, and global streaming.

  • Solution: More than 700 microservices, AWS auto-scaling, and the Netflix Open Connect CDN.

WhatsApp

  • Challenge: 2B+ users and 100B+ messages per day with 55 engineers.

  • Solution: Erlang for massive concurrency, a deliberately narrow feature set, and FreeBSD optimization.

Discord

  • Challenge: Real-time messaging, voice chat, and 150M+ active users.

  • Solution: Elixir clusters, Rust for performance-critical paths, and global edge nodes.

Identifying Bottlenecks

Before scaling, identify what limits the system's performance.

ComponentWarning signTypical solution
CPUUsage above 80%More cores or better algorithms
MemoryHigh RAM use or swappingMore RAM or optimized data structures
StorageSlow disk I/O or high latencySSDs, caching, or database optimization
NetworkHigh bandwidth use or packet lossCDN, compression, or load balancing
DatabaseSlow queries or connection limitsIndexing, read replicas, or sharding

Load Testing and Metrics

Key Metrics to Monitor

  • Response time: How long requests take.
  • Throughput: Requests handled per second.
  • Error rate: Percentage of failed requests.
  • Resource usage: CPU, memory, disk, and network use.
  • Concurrent users: Users active at the same time.

Load Testing Types

  • Load test: Expected normal traffic.
  • Stress test: Traffic beyond normal capacity.
  • Spike test: Sudden traffic increases.
  • Endurance test: Sustained traffic over an extended period.
  • Volume test: Very large amounts of data.

Scaling Timeline

AudienceArchitecture stepWhat changes
1-1K usersSingle serverMonolith, one database, and simple deployment
1K-10K usersAdd cachingRedis or Memcached and a CDN for static assets
10K-100K usersDatabase scalingRead replicas and connection pooling
100K-1M usersLoad balancingMultiple app servers and session management
1M+ usersMicroservicesService decomposition and message queues

Common Scaling Mistakes

Premature Optimization

Building for 1M users when the product has 100. Start simple and scale when measurements show the need.

Not Measuring

Guessing at bottlenecks instead of using monitoring and profiling tools.

Only Vertical Scaling

Continuing to buy larger servers instead of designing for horizontal scale when the workload requires it.

🧮 Scaling Cost Calculator

Compare the costs of vertical vs horizontal scaling strategies

Inputs

users
users
$/month

Scaling Comparison

Vertical Scaling
3162 $/month

Vertical scaling becomes 31.6x more expensive due to premium hardware costs

Scale Factor:10x
Cost Multiplier:31.6x
Total Servers:1 (bigger)
Horizontal Scaling
1000 $/month

Horizontal scaling requires 10 servers but costs scale linearly

Scale Factor:10x
Number of Servers:10
Cost per Server:$100
💡 Quick Comparison: Horizontal scaling is 3.2x cheaper for this scenario

🎯 Real-world Scaling Scenarios

Explore how different companies handle scaling challenges

E-commerce Flash Sale
Black Friday traffic spike: 10x normal load in 1 hour
Metrics
Normal Traffic
1K RPS
Peak Traffic
10K RPS
Response Time
2.5s
Error Rate
15%
Outcome

Without auto-scaling, servers crashed. Lost $2M in sales during 3-hour outage.

Lessons Learned
  • Pre-scale infrastructure before known traffic spikes
  • Implement auto-scaling with aggressive scaling policies
  • Use CDN and caching to reduce server load
  • Load test with 10x expected traffic
No quiz questions available
Could not load questions file
Spotted an issue or have a better explanation? This page is open source.Edit on GitHub·Suggest an improvement