To size your database storage correctly, you must understand IOPS and throughput, which measure how fast your storage can read and write data. Larger disks, typically 4TB or greater, provide significantly better performance for enterprise-level workloads. Increasing the number of vCPUs also boosts storage performance, though it may increase wait times for parallel tasks. Issuing I/O in parallel helps reach a higher I/O queue depth, which is essential for maximizing the capabilities of the storage subsystem.
Managing memory is critical to prevent out-of-memory errors, which can crash your database instance. You should monitor the usage metric and ensure it stays under 90% to maintain stability and avoid performance drops. If an instance reaches its maximum memory or CPU limits, you must perform sharding, which involves splitting the database across multiple instances. Note that scaling resources like RAM or vCPU usually requires an instance restart, so you must plan for brief downtime.
Proper capacity planning involves more than just current data size; you must account for maintenance operations. It is a best practice to reserve at least 20% of your storage space for critical background tasks and updates. You should also monitor specific variables to ensure long-term health, including table counts (aim for under 10,000 tables per instance), log space for binary log retention during high write activity, and growth buffer for future data projections.
When performance issues arise, you can choose between vertical scaling and horizontal scaling. Vertical scaling involves adding more power to a single machine, such as increasing disk throughput or adding more vCPU. If vertical scaling is not enough to meet demand, horizontal scaling allows you to distribute read traffic to read replicas. This strategy improves overall performance by offloading heavy query loads from the primary database instance.
Continuous monitoring is necessary to ensure storage performance aligns with application requirements. Tools like Cloud Monitoring and Query Insights help track latency and identify slow-running queries that may be straining resources. You should regularly perform database tuning, such as index defragmentation and statistics updates, to keep the I/O subsystem running smoothly.
When sizing a database, you must choose the right amount of vCPU and memory to handle your specific tasks. Compute sizing is the process of matching your hardware resources to the performance needs of your applications. You can use custom machine types to independently adjust CPU and memory if a standard setup does not fit your needs.
Monitoring system performance is vital for understanding if your database is the right size. You should watch several key metrics to see if the system is struggling, including CPU utilization, memory usage, and disk I/O. For most instances, you should aim to keep memory usage below 90% to prevent errors. If these numbers stay high, it is a clear sign that your instance is underprovisioned.
The complexity of your queries and the number of concurrent connections directly impact how much compute power you need. Query complexity refers to how much work the database must do to process data for a single request. High numbers of active users can lead to CPU contention, where tasks have to wait for a turn to run and slow down the entire system.
If your workload changes over time, you can use scaling to adjust your resources. Scale-up involves adding more vCPUs or memory to a single instance to handle more work. If an instance is already at its maximum size, you may need to shard your database across multiple instances to spread out the load. Using machine type recommendations can help you find the most cost-effective size for your predictable workloads.
Different database engines use specific metrics to show they are overloaded. For example, in BigQuery, resources are measured in slots, which are units of computation that include CPU and RAM. Tracking these specialized metrics ensures that your throughput remains high and your users do not experience slow response times.
In distributed systems, scalability is the ability to handle more work by adding resources to the environment. Horizontal scaling involves adding more nodes to a cluster, while vertical scaling means increasing the power of existing machines by adding more CPU or memory. For services like Cloud Spanner and Cloud Bigtable, performance often scales linearly, meaning doubling the number of nodes roughly doubles the total throughput.
Cloud Spanner uses nodes or processing units as the primary scaling units for compute power. Each node currently supports up to 10 TiB of storage and provides specific throughput based on whether it is a regional or multi-region setup. Key Spanner scaling factors include compute capacity measured in nodes or processing units (1,000 units equals one node), storage limits where each node provides a fixed amount of storage capacity, and autoscaling which automatically adjusts the instance size based on real-time CPU and storage needs.
Cloud Bigtable performance is highly dependent on the number of nodes and the type of storage used, such as SSD or HDD. To maintain low latency, you should aim for a maximum CPU utilization of 60%, while workloads focused on throughput can handle up to 90%. Bigtable storage targets include SSD storage with a recommended limit of 5 TB per node for optimal performance, and HDD storage with a higher limit of 16 TB per node, though it is slower than SSD. Keeping storage usage under 60% helps prevent background tasks from slowing down your queries.
For Cloud SQL, scaling often involves rightsizing instances to match the actual workload requirements. You can scale up by adding more RAM and vCPUs or scale out by using read replicas to handle heavy read traffic. It is a best practice to keep at least 20% of storage space available to ensure the database has enough room for maintenance and logging.
Effective capacity planning requires running benchmarks against your database using tools like the PerfKit Benchmarker. This process helps determine the exact number of nodes needed to meet your specific performance targets before you go live. Using predictive scaling can also help by forecasting future traffic based on historical trends to prevent performance drops during sudden spikes in usage.
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
IOPS and throughput measure how fast storage reads and writes data. Larger disks, typically 4TB or greater, provide significantly better performance for enterprise-level workloads. Increasing the number of vCPUs also boosts storage performance, though it may increase wait times for parallel tasks.
It is a best practice to reserve at least 20% of your storage space for critical background tasks and updates. This ensures the database has enough room for maintenance, logging, and growth buffer to prevent performance drops.
Cloud Spanner uses nodes or processing units (1,000 units equal one node) as scaling units, with each node currently supporting up to 10 TiB of storage. For Cloud Bigtable, to maintain low latency you should aim for a maximum CPU utilization of 60%, while throughput-focused workloads can handle up to 90%.