Autoscaling overview

This page explains how autoscaling works in Spanner, and introduces the two types of autoscaling you can use in Spanner.

Scaling Spanner

When you create a Spanner instance, you choose the number of compute capacity nodes or processing units to use when serving your data. However, there are times when the workload might increase or decrease. Scaling an instance is the process of adding or removing compute capacity in response to changes in the instance's workload or data storage needs.

It can be useful to scale your Spanner instance based on metrics such as the instance's CPU usage. For example, if your instance is under a heavy load and its CPU utilization is high, you can temporarily add compute capacity and remove it again when its CPU usage drops. Removing compute capacity from the instance when it doesn't have heavy usage lowers costs.

You can't resolve all Spanner performance issues by adding compute capacity. For example, scaling up an instance can't solve problems that occur that are unrelated to the instance size, such as lock contention and hotspotting.

There are two ways that you can scale your Spanner instance to meet workload changes:

  • Configure your instance manually to add or remove compute capacity.
  • Configure autoscaling on your instance so that compute capacity automatically scales up or down to meet workload levels.

For autoscaling, you have the following options:

Requirements on this page apply to both the managed autoscaling feature and the open source Autoscaler tool.

When to use autoscaling

The benefits of autoscaling include the following:

  • Costs: Autoscaling reduces the compute capacity in your instance. This can help you avoid over-provisioning.
  • Performance: Autoscaling lets Spanner automatically add compute capacity to an instance when a workload changes or there is an increase in data storage requirements. This helps maintain workload performance objectives by ensuring that the instance has enough compute capacity to meet the target CPU utilization and storage requirements.
  • Automation: Autoscaling reduces management complexity. You don't need to monitor and scale the instance size manually. With managed autoscaling, you don't write an application to do these tasks, because the Spanner service handles them for you.

Autoscaling is often the best choice for the following situations:

  • Steady diurnal or cyclical traffic patterns, such as those generated by online banking systems.
  • New applications expecting organic growth.
  • Workloads that are new to Spanner.

Although Spanner quickly adds compute capacity when traffic increases, it can take time to balance the additional capacity.

What's next