Lesson 3 of 4 Relational Data Solutions

Scaling Relational Databases

This lesson explains vertical scaling, read scale-out, elastic pools and sharding.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish vertical from horizontal scaling.
  • Explain read scale-out and named replicas.
  • Identify workloads that suit an elastic pool.
  • Explain when sharding is justified.

Vertical and horizontal scaling

Vertical scaling, or scaling up, gives a database more resources, such as more vCores or a higher tier. It is simple because the application does not change, and it is usually the first step. However, it has an upper limit, and a brief disconnection accompanies the change, so applications need retry logic. Horizontal scaling, or scaling out, spreads load across several databases or replicas. It has less of a ceiling, but the application or the data model must support it.

An architect should determine which kind of load is growing. Reads can often be scaled with replicas, leaving the primary to handle writes. Writes are harder, because every write must reach the one primary unless the data is partitioned.

Read scale-out

Read scale-out sends read-only work to a secondary replica, so that reporting does not compete with transactions. An application requests this by adding ApplicationIntent=ReadOnly to its connection string. The feature is enabled by default in the Premium, Business Critical and Hyperscale tiers. Premium and Business Critical include the readable replica at no extra charge. Hyperscale uses its high-availability secondary replicas, which are billed, so a Hyperscale database needs at least one. Read scale-out is not available in Basic, Standard or General Purpose.

Hyperscale goes further, with up to 30 named replicas. Each named replica can have its own compute size and connection endpoint, so a separate analytics workload can receive isolated resources. Replicas are asynchronous, so a reader might see data that lags slightly behind the primary, which must be acceptable to the application.

Scenario questions

Scaling the reads

Exam skills 2.1.3

Apply read scale-out and named replicas.

Log in to try this activity Interactive activities are free with an account.

Elastic pools

An elastic pool lets many databases share a set of resources. The pattern addresses a common problem: a software vendor may have hundreds of customers with a database each, and usage peaks at different times. Sizing each database for its own peak is expensive, while pooling allows databases to borrow capacity when they need it. Billing applies to the pool at its configured size, with no charge for each database.

A pool is cost-effective when the average use across databases is low compared with the individual peaks. If all databases peak together, or one consumes most of the capacity, the pool will not help, and that database may need to move out. Per-database settings can guarantee a minimum or limit the maximum, reducing the noisy neighbour effect. Pools are available in DTU, vCore and Hyperscale models.

Sharding

Sharding splits one logical dataset across several databases, each holding a subset of rows, usually determined by a shard key such as a tenant ID. It is the approach for write-heavy or very large datasets that cannot fit one database, as each shard receives only part of the load. A second benefit is tenant isolation: a large customer's data can be placed in its own database.

Sharding adds complexity, because the application must route requests, and queries across shards are more difficult. Elastic Database tools help: a client library maintains the shard map, and elastic jobs run tasks across databases. A split-merge tool moves data between shards, and it is a service that the customer hosts. Hyperscale has removed much of the need to shard simply for size, so sharding should be recommended only when a real requirement exists. Elastic query with a shard map is reaching end of support on 31 March 2027, so a new design should not rely on it.

True or false

When to shard

Exam skills 2.1.3

Check when sharding is justified and what it costs.

Log in to try this activity Interactive activities are free with an account.

Scaling PostgreSQL and MySQL

The open-source services follow the same principles. Compute can be scaled vertically, with a brief restart, and storage can grow automatically. Read replicas offload reads: Azure Database for MySQL flexible server supports up to 10 asynchronous replicas. An application must connect to replicas explicitly unless a proxy or a virtual endpoint manages the routing.

Comparing the approaches

The following table recaps the scaling options by the problem each one solves.

ApproachProblem solvedApplication change
Scale upMore total capacity for one databaseNone, apart from retry handling
Read scale-outReports competing with transactionsA connection string setting
Named replicasMany isolated read workloads on HyperscaleA separate connection endpoint
Elastic poolMany databases with varied peaksNone
ShardingWrites or data beyond a single databaseSignificant: routing and data model

The following diagram shows the answer to each of two database scaling problems: many small databases with different peaks, and one large database.

Two scaling problems, two answers. Three hundred small customer databases with peaks at different times waste money sized individually for peak, so an elastic pool shares resources among them with no application change. The large Business Critical customer's month-end reports move to the read-only replica through read scale-out, away from order entry.
Only some of the 300 databases are drawn.
Match the pairs

Scaling problem and answer

Exam skills 2.1.3

Match each scaling problem with the approach that solves it.

Log in to try this activity Interactive activities are free with an account.
Worked example

Selecting a scaling strategy

A vendor hosts 300 customer databases in the General Purpose tier. Most are small, and customers are active at different times of day. Costs are high because each database is sized for its peak. Separately, one large customer runs month-end reports that slow its order entry system, which is in Business Critical. What should you recommend?

The 300 databases with unsynchronized peaks and low averages are the textbook case for an elastic pool, which removes the need to size each database for its own peak. No application change is needed.

The reporting problem suits read scale-out. Because the database is already Business Critical, a free readable replica exists, and the reporting tool needs only ApplicationIntent=ReadOnly. Sharding either workload would add much complexity without need, and scaling the order database up would cost more while leaving reports on the same replica as transactions.

Check yourself

When will an elastic pool fail to save money?

Show answer

When databases peak together, or when one consumes most of the capacity, because the pool's value comes from peaks at different times.

Exam Tips

Remember for the exam

  • Scale up first; scale out when a limit or workload shape requires it.
  • Read scale-out uses ApplicationIntent=ReadOnly. Premium and Business Critical include the replica; Hyperscale secondaries are billed.
  • Elastic pools suit many databases with low averages and unsynchronized peaks.
  • Hyperscale named replicas give isolated read compute; up to 30.
  • Sharding is for write-heavy data beyond one database, and needs application changes.