Infrastructure11 min read10 February 2026

Database Design for Scale: From Startup to Enterprise

A database design that works for 1,000 users fails at 100,000. Learn the principles to design databases that scale from startup to enterprise.

Your database is the foundation of your application. A well-designed database handles growth gracefully. A poorly designed one collapses under load.

The difference isn't academic: the cost of redesigning a database at scale is measured in months of engineering time and millions in infrastructure costs.

The principles that make databases scale are well understood. The challenge is applying them thoughtfully from the beginning, not bolting them on later.

Data Modelling: Start Here

Before writing queries, understand your data structure.

Good data modelling:

  • Normalise appropriately: avoid duplicating data across tables (reduces consistency issues), but avoid over-normalisation (excessive joins slow queries)
  • Identify primary entities: users, orders, products, etc. — the core concepts in your domain
  • Define relationships: how do entities relate? (one-to-many, many-to-many, etc.)
  • Plan for growth: how will your data grow? If users grow 10x, how does that affect queries?
  • Understand access patterns: how will you query the data? Shape your schema around these patterns.

Indexes: The Speed of Scaling

Indexes are how databases quickly find rows. Without indexes, every query scans the entire table.

Indexing principles:

  • Index on frequently queried columns: if you filter by user_id frequently, index it
  • Index on join columns: if you join user_id across tables, index it
  • Index on sort columns: if you ORDER BY a column, index it
  • Composite indexes: if you frequently filter by two columns together (user_id AND status), a composite index is faster than separate indexes
  • Not too many indexes: indexes slow writes (every INSERT/UPDATE must update indexes) and consume space. Index strategically.

A well-indexed query returns in milliseconds. The same query without indexes can take seconds or minutes.

Query Optimisation

Slow queries are the biggest database performance bottleneck.

Optimisation strategies:

  • Use EXPLAIN: understand how the database executes your query (does it use indexes? Does it do sequential scans?)
  • Avoid N+1 queries: instead of querying for a user, then querying for their orders, then querying for each order's items — query all at once with a join
  • Denormalise strategically: sometimes storing calculated values (like order_total) avoids expensive joins
  • Use appropriate data types: searching for a large text field is slower than searching for an indexed ID
  • Pagination: don't load 1,000,000 rows; load 20 at a time with pagination
  • Caching: frequently accessed data can be cached in memory (Redis) rather than queried every time

Transactions and Consistency

Transactions ensure data consistency: multiple operations complete together or not at all.

ACID guarantees:

  • Atomicity: a transaction either fully completes or is completely rolled back (no partial states)
  • Consistency: the database remains in a consistent state (no violated constraints)
  • Isolation: concurrent transactions don't interfere with each other
  • Durability: once a transaction commits, the data is permanently stored

Transaction design:

  • Keep transactions small: large transactions lock more data and fail more often
  • Understand isolation levels: different levels provide different consistency guarantees (from Read Uncommitted to Serializable)
  • Handle conflicts: if transactions conflict (trying to update the same row), how do you handle it? Retry? Fail?
  • Deadlocks: sometimes transactions wait on each other indefinitely. Design to avoid this (consistent ordering of resource acquisition).

Sharding and Horizontal Scaling

At some point, vertical scaling (bigger servers) has limits. Sharding distributes data across multiple databases.

Sharding strategies:

StrategyHow It WorksProsCons
Range-basedShard by user ID ranges (1-1M, 1M-2M, etc.)Simple to understandUneven distribution if ranges aren't right
Hash-basedHash the key; result determines shardEven distributionHard to add new shards without reshuffling
DirectoryLook up in a directory which shard contains this keyFlexibleThe directory itself is a bottleneck
Geo-basedShard by geographyLower latencyRequires geo-distributed infrastructure

Sharding is complex: you lose cross-shard transactions, joins become difficult, operations become complicated. Avoid if possible; use when truly necessary.

Replication: Availability and Read Scaling

Replication copies data across multiple servers for redundancy and read scaling.

Patterns:

  • Primary-replica: writes go to the primary; reads can use replicas (spreads read load)
  • Multi-primary: multiple primaries can accept writes (more complex, requires conflict resolution)
  • Read replicas: used for reporting/analytics; takes load off the primary but introduces replication lag

Considerations:

  • Replication lag: updates on the primary take time to reach replicas; what if you read from a replica immediately after writing?
  • Failover: if the primary fails, can replicas take over automatically?
  • Consistency: do all replicas need to be up-to-date? Or is it acceptable for some users to see stale data?

Caching: The Speed Layer

Databases are slow compared to memory. Caching (typically Redis or Memcached) dramatically improves performance.

Caching patterns:

  • Aside/Look-aside: check cache first; if miss, query database and populate cache
  • Write-through: on write, update cache and database
  • Write-behind: on write, update cache; asynchronously update database (risky if cache is lost)
  • Time-based expiration: cache entries expire after a time period
  • Tag-based invalidation: when related data changes, invalidate all related cache entries

Caching risks:

  • Cache misses: cache miss on frequently accessed data is expensive (slow)
  • Staleness: cache may be out of sync with the database
  • Complexity: cache introduces another system to manage; code becomes more complex

SQL vs NoSQL

The choice between SQL and NoSQL is contextual, not ideological.

AspectSQLNoSQL
StructureRigid schemaFlexible/dynamic
QueryingPowerful queries across dataQuery-pattern-specific
TransactionsACID across tablesOften limited transactions
ScalingVertical easier; horizontal hardHorizontal easier
JoinsEfficientRare; requires denormalisation
MaturityDecades of best practicesNewer; evolving patterns

Use SQL for transactional data with complex relationships (financial, e-commerce). Use NoSQL for high-volume, flexible-schema data (user profiles, time-series, logs).

Many systems use both: SQL for transactional data, NoSQL for caching and analytics.

Monitoring and Observability

You can't optimise what you don't measure.

Database monitoring:

  • Query performance: log slow queries (typically >100ms or configurable)
  • CPU/Memory: understand resource utilisation
  • Connections: too many open connections indicates problems
  • Replication lag: if you have replicas, how far behind are they?
  • Lock contention: are transactions waiting on locks?
  • Disk space: are you running out of space?

Evolution: From Startup to Scale

Database needs change as you grow:

  • Stage 1 (Startup): Single database, good indexing, basic replication. Focus on features, not scale.
  • Stage 2 (Growth): Read replicas for analytics, caching for frequently accessed data, query optimisation.
  • Stage 3 (Scale): Sharding for horizontal scaling, advanced replication topologies, separate databases for different data types (CQRS).
  • Stage 4 (Enterprise): Multiple database technologies, advanced replication, distributed transactions, sophisticated monitoring.

Common Database Mistakes

  • No indexes: leaving important queries unindexed until performance is a crisis
  • N+1 queries: querying for every item in a list instead of batching
  • Unbounded queries: queries that load unlimited rows (no pagination)
  • Premature denormalisation: denormalising before it's necessary, adding complexity
  • No monitoring: discovering database problems only when users complain
  • Ignoring replication lag: assuming data is immediately consistent across replicas
  • No backup strategy: losing data because backups weren't tested

Design Principles for Scale

  • Model your access patterns first: design schema around how data will be queried
  • Index strategically: indexes are the difference between milliseconds and seconds
  • Keep transactions small: minimise lock contention and failure rates
  • Denormalise deliberately: only when it solves a real performance problem
  • Cache aggressively: memory is orders of magnitude faster than disk
  • Monitor obsessively: understand performance before it's a problem
  • Plan for growth: design for 10x growth; when you need 100x, redesign

The Bottom Line

Database design is one of the highest-impact technical decisions in your system. A good schema enables rapid feature development. A poor schema creates bottlenecks.

Start simple: proper indexing and query design handle surprising scale. Sharding and exotic patterns are rarely necessary early.

Measure before optimising: slow queries are obvious with monitoring; fix the slowest queries first.

Plan for growth: understand how your data will grow and design accordingly. Redesigning a database at scale is painful.

#database design#scalability#SQL#NoSQL#performance#architecture
P
Prodevel Team
Database Architects at Prodevel Limited

Prodevel is a London-based software development agency with 15+ years of experience building AI solutions, custom software, and mobile apps for UK businesses and universities.

Ready to Start Your Project?

Free initial consultation. No commitment. Let's discuss your requirements.

Get Free Consultation