Course contentsShow
← System Design
Lesson 54 of 1,9192. Scaling FoundationsFree lesson

Scaling Databases: Special Considerations

Databases are harder to scale horizontally due to consistency needs; vertical often comes first.

Scaling Databases: Special Considerations

What you'll learn: Why databases require different scaling strategies than stateless application servers.

The Database Scaling Challenge

When you scaled your application servers horizontally, you simply added more identical machines behind a load balancer. Easy! But databases don't work the same way.

The fundamental problem: Databases must maintain data consistency. If User A updates their profile on Database Server 1, User B querying Database Server 2 must see that same update. This coordination is complex and expensive.

Why Vertical Scaling Comes First

With databases, you'll typically scale vertically before attempting horizontal scaling:

  • Adding RAM improves caching (more data in memory = faster queries)
  • Faster CPUs handle complex queries more efficiently
  • Better storage (SSDs) reduces disk I/O bottlenecks

This buys you significant headroom without the coordination headaches of multiple database instances.

The Coordination Tax

Think of a single database like one librarian managing a catalog. They always know exactly which books are checked out. Now imagine ten librarians each with their own catalog — they must constantly communicate to stay synchronized. Every update means messages between all librarians. This coordination overhead is why horizontal database scaling is harder.

Stateless app servers don't have this problem because they don't "remember" anything between requests. Each handles a request independently. Databases, by definition, must remember and stay consistent.

Starting Point

When your database becomes a bottleneck, your progression typically looks like:

  1. Optimize queries and add indexes
  2. Scale vertically (bigger machine)
  3. Only then consider horizontal strategies (which we'll cover later)

Key Takeaway: Databases resist horizontal scaling because maintaining consistency across multiple database nodes requires complex coordination that stateless application servers don't face, making vertical scaling the natural first choice.