This page describes the storage utilization metrics that Cloud Spanner provides.
Storage metrics
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 2 TB per node 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.
You can view charts for these metrics in the Cloud Console or in the Cloud Monitoring console.
Also, database storage utilization is shown in the Instances and Instance details pages in the Cloud Console.
Creating alerts
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 2 TB per node limit. This ensure 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 number of nodes in your instance
If you are over the 2 TB per node 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 nodes
- 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 nodes to your instance as a starting point. After you add nodes, 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 nodes as
needed, using the UpdateInstance
method.
What's next
- Monitor your instance with the Cloud Console or the Cloud Monitoring console.
- Create alerts for Cloud Spanner.
- Find out how to change the number of nodes in a Cloud Spanner instance.