This page describes the storage utilization metrics that Cloud Spanner provides.
Cloud Spanner provides the following storage metrics:
- Total database storage: The amount of data that is stored in the database or the databases in the instance. This is subject to the storage limit.
- Total backup storage: The amount of data that is stored by the backups associated with the instance or database. Backup storage is stored and billed separately and there is no limit on the amount you can store.
Also, database storage utilization is shown in the Instances and Instance details pages in the Cloud Console.
You can create alerts on any metric in the Cloud Monitoring console. We also provide an easy way to create a database storage alert directly from the Cloud Console. The Create alerting policy link in the chart (see screenshot) takes you to the create alert page in Cloud Monitoring console and automatically prefills the relevant fields.
Recommendations for database storage utilization
We recommend keeping your total database storage below the storage limit. This ensures that Cloud Spanner has enough headroom to operate normally and perform routine maintenence on the data.
If you are approaching the limit, Cloud Spanner may prevent you from performing operations that put you over the limit, such as:
- restoring a database from a backup
- modifying the database's schema (for example, adding an index)
- reducing the compute capacity of your instance
If you are over the storage limit, Cloud Spanner will attempt to operate normally, but you may experience degraded performance or failure due to resource pressure. To help you stay below the limit, the Cloud Console displays the following warning if you are approaching or over the recommended maximum.
You can also create alerts in Cloud Monitoring to notify you.
Reducing database storage utilization
To reduce an instance's database storage utilization, you can:
- add more compute capacity
- delete a database
- delete data from a database. Note that even though data deletion takes effect immediately from a visibility perspective, it does not affect the storage utilization metric until Cloud Spanner compacts the data (typically within 12 hours, but can take longer in certain cases). Therefore, you may notice a delay from when data is deleted to when the changes appears in the metric.
In general, we recommend that you add compute capacity to your instance as a starting point. After you add compute capacity, you can investigate and address the root causes of high storage utilization.
If you want to automate this process, you can create an application
that monitors database storage utilization, then adds and removes compute
capacity as needed, using the
- Monitor your instance with the Cloud Console or the Cloud Monitoring console.
- Create alerts for Cloud Spanner.
- Find out how to change the compute capacity of a Cloud Spanner instance.