Automatic Scaling of Cloud Spanner Nodes | Your Website

Automatic Scaling of Cloud Spanner Nodes

Question

You have an application that uses Cloud Spanner as a backend database.

The application has a very predictable traffic pattern.

You want to automatically scale up or down the number of Spanner nodes depending on traffic.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

D.

Option D is the correct answer. To automatically scale up or down the number of Cloud Spanner nodes depending on traffic, you need to create a Cloud Monitoring alerting policy that sends an alert to a webhook when the Cloud Spanner CPU is over or under your threshold. Then, you need to create a Cloud Function that listens to HTTP and resizes Spanner resources accordingly.

Cloud Spanner is a fully managed, horizontally scalable relational database service. It automatically scales up or down based on the amount of traffic it receives. By default, Cloud Spanner automatically resizes its nodes every 30 seconds based on CPU utilization. However, you can configure the resizing policy to meet your application's specific needs.

To configure automatic scaling of Cloud Spanner, you need to create a Cloud Monitoring alerting policy that monitors CPU utilization. This can be done by creating a new alerting policy in the Cloud Monitoring console. The alerting policy should be set up to trigger an alert when the Cloud Spanner CPU is over or under your threshold.

Once the alerting policy is set up, you need to create a Cloud Function that listens to HTTP and resizes Spanner resources accordingly. This can be done by creating a new Cloud Function in the Cloud Functions console. The Cloud Function should be set up to listen to the webhook that is triggered by the Cloud Monitoring alerting policy.

When the Cloud Function is triggered by the webhook, it should check the current CPU utilization of the Cloud Spanner instance and determine whether it needs to be resized. If the CPU utilization is too high, the Cloud Function should increase the number of Cloud Spanner nodes. If the CPU utilization is too low, the Cloud Function should decrease the number of Cloud Spanner nodes.

In summary, to automatically scale up or down the number of Cloud Spanner nodes depending on traffic, you need to create a Cloud Monitoring alerting policy that sends an alert to a webhook when the Cloud Spanner CPU is over or under your threshold. Then, you need to create a Cloud Function that listens to HTTP and resizes Spanner resources accordingly.