Prepare and test your skills
Prepare and test your skills
Data Tier Scalability and Storage Expansion is the ability of databases and storage to handle more users, transactions, and data without redesigning the application. In Google Cloud, databases grow through horizontal or vertical scaling, while block, file, and object storage replicate data across zones and regions as capacity increases. Cloud Spanner (opens in a new tab) provides horizontal global scaling, while Cloud SQL (opens in a new tab) provides vertical scaling with read replicas.
Choosing a database for growth is a decision between horizontal scale across regions and vertical scale within a region. Cloud Spanner scales throughput and storage horizontally by distributing data across many replicas that all serve traffic. Cloud SQL scales vertically by moving the primary to a larger machine and scales reads horizontally with replicas.
| Service | Scaling model | Replication and availability |
|---|---|---|
| Cloud Spanner | Horizontal, multi-region scale for reads and writes | Built-in synchronous replication across zones and regions in an active-active topology |
| Cloud SQL | Vertical scale plus read replicas for read-intensive workloads | High availability (HA) with primary and standby, plus cross-region and cascading read replicas that require promotion on failover |
Choose Cloud Spanner when the workload needs global writes with consistency everywhere. Choose Cloud SQL when a larger primary plus offloaded reads in one region is sufficient.
Cloud Spanner is a globally consistent relational database service that grows by adding capacity across zones and regions without manual sharding. A regional Spanner configuration maintains three read-write replicas, each in a different Google Cloud zone in that region, and each replica holds a full copy of the database that can serve read-write and read-only requests. A Spanner multi-region configuration extends this across regions, for example with four read-write replicas in separate zones across two regions plus a witness replica in a third region. Because replication and synchronization are built in, traffic flows from application tiers in any region to the multi-region instance while Spanner keeps the copies consistent.
Exam tip: Choose Cloud Spanner when the workload needs horizontal scaling of both reads and writes across regions; choose Cloud SQL with read replicas when the need is vertical growth of one primary plus scaling of reads.
Cloud SQL is a managed relational database service that scales vertically and handles more reads through replicas. A Cloud SQL instance configured for high availability (HA) is also called a regional instance and consists of a primary instance in a primary zone and a standby instance in a secondary zone in the same region, with automatic failover that keeps the same database endpoint. For read growth, the primary offloads traffic to read replicas, including cross-region replicas in a different region that can be promoted to become the new primary if a disaster occurs. Read replicas can themselves be configured for HA in advance and can have their own cascading cross-region replicas, so protection continues immediately after promotion.
Application growth creates a direct dependency between compute scaling and database connections. An application service accessing the database typically uses an internal connection pool that pre-creates a minimum set of connections to improve efficiency and reduce latency. Each time another application service instance is added, that instance creates its own pool and adds more connections to the database, so total connections grow with the number of instances. Because databases cannot support unlimited connections, pooling limits must be managed to avoid overload.
Expanding storage systems for massive data growth means selecting block, file, and object storage that replicates data across locations as capacity increases. The storage layer must keep data durable during zone and region growth while letting performance and capacity scale independently. Persistent Disk (opens in a new tab) and Hyperdisk cover block storage, Cloud Storage (opens in a new tab) covers object storage, and Filestore covers shared file storage:
For backup growth, application and database backups stored in dual-region Cloud Storage buckets survive a zone or region outage, and snapshots of persistent disks can be stored in multi-region locations for the same reason.
Compute Autoscaling and Serverless Elasticity is the ability to adjust capacity dynamically so resources are added precisely where needed without over-provisioning or under-provisioning. Horizontal scaling adds more replica instances to distribute load, while vertical scaling replaces existing components with larger ones that have more CPU, memory, and storage. Horizontal scaling is preferred for most cloud-first applications because it is more resilient, more cost-efficient for variable load, and virtually unlimited compared to the hard limits of a single large virtual machine (VM).
Compute Engine managed instance groups (MIGs) (opens in a new tab) are groups of VMs that are managed and scaled as a single entity. An autoscaling policy for a MIG defines the minimum and maximum number of VMs to maintain and the conditions that trigger scaling. When average demand exceeds the target, the autoscaler creates new instances to absorb load, and when demand decreases, the autoscaler removes instances that are no longer needed.
A MIG autoscaler can respond to diverse signals, not just CPU utilization. Cloud Monitoring (opens in a new tab) provides metrics across apps and infrastructure that feed data-driven scaling decisions:
This flexibility lets an architect match the scaling signal to application behavior instead of relying only on CPU. A queue-based worker scales better on queue depth, while a web front end scales better on utilization or serving capacity.
Reactive, predictive, and scheduled scaling are three timing strategies for when a MIG adds capacity. Reactive scaling responds to real-time changes in load and suits unpredictable spikes, but adding VMs can take several minutes, so capacity may lag behind a sudden surge. Predictive autoscaling forecasts future load from historical metric trends, such as CPU utilization, and recomputes that forecast every few minutes to adapt rapidly to recent changes. Scheduled scaling pre-provisions a required number of instances ahead of known demand, such as daily business hours, weekly reports, or seasonal sales.
Choose the timing strategy by how predictable the peak is and how fast instances start. Manually scale out or schedule capacity before a known event to ensure immediate availability, because waiting for reactive autoscaling can leave users with delays while new VMs initialize. Define clear thresholds and stabilization rules to prevent flapping, which is frequent unnecessary scale-in and scale-out around a threshold.
Exam tip: MIG autoscaling stays within a configured minimum and maximum and can take minutes to add VMs, so pre-provision capacity before known peaks; Cloud Run scales automatically between its minimum and maximum and scales to zero when idle.
Cloud Run (opens in a new tab) is a serverless container platform that automatically scales stateless containers based on incoming traffic. A service owner configures a minimum and maximum number of container instances, and Cloud Run scales instances between those limits as requests arrive. When a Cloud Run service receives no traffic, it scales efficiently to zero instances, and billing follows actual use because teams pay only for what they consume.
Cloud Run functions (formerly Cloud Functions) is a serverless functions platform for event-driven code that is inherently elastic alongside Cloud Run. Both platforms remove the need to manage servers or clusters, and both scale quickly from zero to high request volumes to handle variable demand. This makes serverless a strong fit when traffic is spiky, intermittent, or unpredictable, and when fast scale-out without pre-provisioned VMs matters more than direct control over the VM.
| Option | What scales | Scaling signal | Idle behavior |
|---|---|---|---|
| Compute Engine managed instance groups (MIGs) | VMs in the group | CPU, load balancer capacity, latency, or Cloud Monitoring custom metrics | Stays at configured minimum |
| Cloud Run | Container instances | Incoming requests between minimum and maximum | Scales to zero with no traffic |
| Cloud Run functions | Function instances | Requests and events | Scales to zero with no traffic |
The table shows the core tradeoff for growth planning: MIGs provide VM-level control with explicit bounds and metric policies, while serverless options trade that control for automatic request-driven elasticity and scale to zero.
Designing workloads to scale effectively means building them so instances can be added or removed without data loss. Stateless design stores no user session or local data on the compute instance, so any instance can handle any request. Session state is stored outside the instance, such as in Memorystore for Redis, which lets the autoscaler replace or add instances without worrying about consistency.
Modular design further improves elasticity by letting individual components scale independently instead of scaling the entire application. Each service exposes clear interfaces and scales on the metric that reflects its own bottleneck, such as queue depth for workers and request rate for front ends. Combined with Cloud Monitoring metrics and appropriate min-max limits, stateless and modular design lets MIGs and serverless platforms consume only the resources needed to meet demand while maintaining performance during growth.
Global Traffic Management and Capacity Planning is the practice of spreading user requests across regions for low latency while making sure quotas and backend capacity do not become bottlenecks during growth. In Google Cloud, Cloud Load Balancing (opens in a new tab) distributes traffic based on backend availability, capacity, and proximity to the user, while project quotas, rate limits, and reserved capacity protect backends from overload. Together these controls let a deployment stay fast during rapid growth and stay available when demand spikes or a region loses capacity.
Global external Application Load Balancer is a proxy-based Layer 7 load balancer that distributes HTTP and HTTPS traffic to backends in multiple regions. The load balancer advertises a single anycast IP address that is implemented by many proxies on Google Front Ends (GFEs), so a client request is directed to the GFE closest to the client and then forwarded to a healthy backend with capacity. In a typical global design, regional managed instance groups (MIGs) serve as backends in different regions, and the global load balancer sends each request to the appropriate region based on availability, capacity, and proximity to the source.
A request through a programmable global front end moves through an ordered sequence:
A process flow showing a user request arriving at the closest Google Front End via a single anycast IP, being evaluated by Cloud Armor edge policies, checked by Cloud CDN where a cache hit returns directly to the user, and on a cache miss passing backend security policy checks before being fulfilled by backend compute such as a regional MIG.
This order matters because filtering and caching happen before backend compute is used, so malicious traffic and repeatable content do not consume application capacity during growth.
Load balancer scope defines where backends can live and how traffic survives zone or regional problems. A global load balancer supports backends in multiple regions, whereas a regional load balancer supports backends in a single region and is resilient to zone outages. Even though a regional load balancer has an IP address located in one region, clients can still reach that frontend from anywhere on the internet.
| Option | Backend scope | Choose when |
|---|---|---|
| Global load balancer | Backends in multiple regions | External traffic must shift across regions for proximity, capacity, and high availability |
| Regional load balancer | Backends in a single region | All backends are in one region and global multi-region distribution is not needed |
Internal traffic needs load balancing as well as external traffic. A cross-region internal load balancing layer can distribute traffic from web-tier virtual machines (VMs) in any region to application-tier VMs across all regions, and a regional internal load balancer can provide reliable communication between tiers such as the web and application tiers in a 3-tier stack. When choosing a type, weigh availability together with geographic control over Transport Layer Security (TLS) termination, performance and latency requirements, cost, and traffic type, such as HTTP(S) for Application Load Balancers versus TCP, SSL, UDP, ESP, and ICMP for Network Load Balancers.
Exam tip: Choose a global load balancer when backends span multiple regions; choose a regional load balancer when all backends live in one region, even though the regional frontend remains reachable from anywhere.
Load-balancing health checks keep traffic on backends that can actually serve requests. Autoscaling may provide enough VMs, but a VM can be in the RUNNING state while the application software on it has crashed. Health checks solve this by probing backend responsiveness, so the load balancer routes application traffic only to responsive backends and stops sending traffic to failed instances.
When backends are MIGs, a second layer of health checking enables autohealing. The MIG health check depends on the same responsiveness signal, and when autohealing is configured the MIG proactively deletes unavailable VMs and creates replacement VMs. The load balancer therefore depends on health checks to avoid overload of failed hosts, while the MIG depends on autohealing to restore healthy capacity without manual intervention.
Network Service Tiers control how traffic travels between the internet and Google Cloud workloads. For applications that serve users globally with backends in more than one region, choose Premium Tier. Traffic from the internet enters the high-performance Google network at the point of presence (PoP) closest to the sender, travels within the Google network from the entry PoP to the Compute Engine VM or other resource, and outbound traffic exits at the PoP closest to the destination. This path reduces the number of public-internet hops between users and the nearest PoP, which improves perceived availability and latency.
Premium Tier costs more than Standard Tier, which routes traffic across the public internet instead of the Google backbone, so the choice is a tradeoff between cost and performance. Some load balancing services are available only in Premium Tier. Cloud CDN integrates with the global external Application Load Balancer to cache content at edge PoPs, which lets the application scale globally without adding backend compute for every request, while Google Cloud Armor integration blocks volumetric distributed denial-of-service (DDoS) attacks and Layer 7 web attacks before they reach backend services.
Rate limiting protects applications from rapid or sustained load increases caused by DDoS attacks, client configuration errors, or sudden popularity. Without limits, the application or the resources it depends on can fail and become unavailable. API request quotas limit how many requests a Google Cloud service receives, while project-level quotas for specific resources limit how much of those resources a project can consume and therefore limit billing exposure.
Graceful degradation extends the same idea into application behavior, letting the system keep functioning with reduced performance or accuracy until load returns to normal. Protections for graceful degradation (opens in a new tab) work best when replicas can act independently:
Dropping some requests early preserves overall recovery, in contrast to circuit-breaking where all traffic is dropped during overload.
Quotas and capacity planning ensure that large-scale deployments do not stall on regional or project limits during growth or failover. Multi-region high availability requires either sufficient capacity reserved in all regions or explicit acceptance of the risks of emergency autoscaling. If traffic must shift because one region cannot scale within its regional quota, the global load balancer can send requests to a region that still has quota and capacity, but only when that spare capacity actually exists.
Operational safeguards complete the design by covering limits and load balancer failure. Set and review project quotas, regional quotas, and service API quotas before launch so normal growth and a regional failover both fit within limits. To protect against global load balancer outages and configuration errors, implement an automated failover or bypass strategy that uses Cloud DNS (opens in a new tab) with regional backup load balancers. After any outage, verify that the application runs as expected in every deployed region before returning to normal traffic distribution.
Cloud Spanner scales throughput and storage horizontally by distributing data across many replicas that all serve traffic with built-in synchronous replication across zones and regions in an active-active topology, while Cloud SQL scales vertically by moving the primary to a larger machine and scales reads horizontally with replicas. Choose Cloud Spanner when the workload needs global writes with consistency everywhere, and choose Cloud SQL when a larger primary plus offloaded reads in one region is sufficient.
Compute Engine managed instance groups (MIGs) autoscale within a configured minimum and maximum number of virtual machines by creating new instances when average demand exceeds the target and removing instances when demand decreases. The autoscaler can respond to CPU utilization, load balancer serving capacity, request latency, and Cloud Monitoring custom metrics such as queue depth, but adding virtual machines can take several minutes so capacity may lag behind a sudden surge.
Use a global load balancer when external traffic must shift across regions for proximity, capacity, and high availability with backends in multiple regions, and use a regional load balancer when all backends are in one region and global multi-region distribution is not needed. A Global external Application Load Balancer advertises a single anycast IP address implemented by many proxies on Google Front Ends and forwards each request to a healthy backend with capacity based on availability, capacity, and proximity to the source.
Cloud Run automatically scales stateless container instances between a configured minimum and maximum based on incoming requests and scales to zero instances when it receives no traffic. Billing follows actual use because teams pay only for what they consume, which makes serverless a strong fit when traffic is spiky, intermittent, or unpredictable.
An enterprise runs a batch and transaction processing workload on a Compute Engine regional Managed Instance Group (MIG). The workload faces diverse bottlenecks depending on customer behavior:
You need to configure an autoscaling policy that combines these signals to ensure the application maintains high performance without dropping requests.
How does the Compute Engine autoscaler evaluate these multiple signals to determine the target size of the MIG?
The autoscaler evaluates signals by strict priority hierarchy, where scaling schedules override Cloud Monitoring metrics, which in turn override CPU utilization.
The autoscaler calculates the arithmetic average across all recommended instance counts from the configured signals to smooth out sudden scaling fluctuations.
The autoscaler calculates the recommended number of VM instances independently for each signal and provisions the largest resulting instance count.
The autoscaler sums together the recommended instance counts calculated for each individual signal up to the configured maximum number of replicas.
Last updated