Vertical scaling means changing the size of a single database instance by adding or removing compute resources like vCPU and memory. This approach is used with Cloud SQL, AlloyDB, and Bigtable to handle changes in workload. When you scale-up, you increase resources to improve performance during peak times. When you scale-down, you reduce resources to save costs, but you should do this less often because scaling down more than once in a three-hour window can cause Cloud SQL to have regular downtime instead of near-zero downtime. High availability configurations that use standby VMs help reduce the risk of downtime during scaling events.
For AlloyDB Omni, planning the right machine size is important for reliability and cost. A good starting point is to allocate 8 GB of RAM for every vCPU used by the instance. Matching the resources of your original database during migration helps keep performance steady. Storage performance depends on IOPS (input/output operations per second) and throughput. With Hyperdisk Balanced disk types, the maximum performance is limited by the number of vCPUs in the machine type, and changes to storage settings can only be made once every four hours. Over-provisioned resources cost money without helping performance. Tools like Gemini Cloud Assist analyze CPU and memory usage over time and recommend resizing instances to match actual workload needs.
Horizontal scaling adds more resources, such as read replicas or additional nodes, to handle increased concurrent read operations and data throughput. In Cloud SQL, you create read replicas that handle read-only traffic, leaving the primary instance free to process writes. This improves overall throughput. To decide when to add or remove replicas, monitor metrics like queries per second (QPS) and CPU utilization. For Cloud Spanner and Bigtable, horizontal scaling means adjusting the node count in the instance. Adding nodes gives a linear boost in processing power and storage throughput, which helps during peak traffic. Reducing nodes during quiet times optimizes costs.
Key metrics to watch include total QPS, CPU usage, disk IOPS, and running threads. Use tools like Metrics Explorer and Query Insights to find resource-intensive queries that may need optimization or scaling. Another important technique is connection pooling, which reuses existing database connections instead of creating new ones for each request. This reduces overhead and helps prevent out-of-memory (OOM) errors. When connections drop during scaling or maintenance, implement retry logic with exponential back-off so the system recovers gracefully.
Proactive monitoring uses real-time data from Cloud Monitoring and Cloud Logging to track database health and spot problems before they cause slowdowns. By analyzing historical workload trends, you can predict future resource needs and perform capacity planning for expected traffic spikes. This prevents over-provisioning—paying for resources you do not use—and ensures resources are ready when demand rises. For longer-term analysis, you can use BigQuery to examine usage patterns.
Automated scaling policies help database instances and application tiers adapt to changing workloads. For compute tiers, Managed Instance Groups (MIGs) can autoscale based on CPU utilization, load balancing serving capacity, or custom metrics from the application. For databases, capacity planning tools like the Capacity Planner show forecasted usage for virtual machines, GPUs, and disk volumes from historical data. The quota adjuster can automatically request more resources before peak events to avoid failures. To validate your plans, perform load testing and stress testing to find where resource limits become a problem, and reserve resources in specific zones to guarantee availability.
Database-specific resource monitoring is essential. In Cloud SQL, watch memory usage and total usage to catch potential out-of-memory errors. If an instance reaches its maximum size and still needs more power, you may need to shard the database across multiple instances. For analytical workloads in BigQuery, use slot reservations to allocate compute capacity to projects or teams. The slot estimator helps you figure out how many slots you need, and you can monitor utilization through administration dashboards. Set alerts for when query execution times exceed your limits to keep performance in check.
Fascinated by the world of cloud databases? Explore the methods for structuring, scaling, and securing database solutions on Google Cloud as you gear up for the Professional Cloud Database Engineer exam!
Prepare and test your skills
Prepare and test your skills
You should scale down a Cloud SQL instance to save costs, but scaling down more than once in a three-hour window can cause the instance to have regular downtime instead of near-zero downtime.
For AlloyDB Omni, a good starting point is to allocate 8 GB of RAM for every vCPU used by the instance to ensure reliability and cost-effectiveness.
Monitor metrics like queries per second (QPS) and CPU utilization to decide when to add or remove read replicas in Cloud SQL.
With Hyperdisk Balanced disk types, the maximum performance is limited by the number of vCPUs in the machine type, and changes to storage settings can only be made once every four hours.