Prepare and test your skills
Prepare and test your skills
Implementing caching and content delivery strategies means answering requests as close to the user as possible instead of sending every request to the origin. In Google Cloud, Cloud CDN (opens in a new tab) serves cacheable content from edge points of presence (PoPs), layered application caches absorb repeated reads inside the region, and the global external Application Load Balancer (opens in a new tab) terminates user connections at the edge and proxies only cache misses to backends. Together these layers shorten round trips, protect origins during spikes, and improve responsiveness for geographically distributed users.
Latency segments are the four parts of end-to-end delay that show where caching can help and where it cannot. Last-mile latency covers the path from the user to their internet provider and depends on access technology, with typical values of 1-10 ms on modern networks, 10-60 ms on DSL and cable, and 100-500 ms on 3G cellular. Google frontend and edge PoP latency covers the path to Google's network edge where global load-balancing products terminate TCP and SSL sessions and where Cloud CDN delivers cached results. Compute Engine region selection (opens in a new tab) covers only the path from the edge PoP to the Compute Engine region inside Google's global network, plus app latency for processing the request.
Region selection cannot fix total user latency when the last mile dominates. If users are mainly on high-latency cellular networks, changing regions has little visible effect because the cellular segment is largest. Caching at the edge PoP is powerful because many round trips end there and never incur the edge-to-region and app segments.
Cloud CDN is the edge-caching service that works with the global external Application Load Balancer to accelerate internet-facing applications from Google's edge PoPs. A user request flows first from the user to the global front end, then through Google Cloud Armor edge security policies, then to the Cloud CDN cache check. If the request is a cache hit, content is retrieved from cache and sent back to the user without contacting the origin; if the request is a cache miss, it is evaluated by backend security policies and then fulfilled by the backend server according to policy rules.
The global external Application Load Balancer is a proxy-based Layer 7 load balancer for HTTP(S) traffic with URL mapping and SSL offloading. The TCP or SSL (TLS) session is terminated at Google Front Ends (GFEs) at Google's network edge, and traffic is proxied from the GFEs to the backends. Configurable backends include two managed instance groups (MIGs) in different regions, as well as GKE, Cloud Run, Cloud Run functions, App Engine, on-premises, and other clouds, with traffic splitting to send different users to different backend versions.
The load-balancer choice controls whether edge termination is possible:
| Option | Traffic flow | Scope |
|---|---|---|
| External Application Load Balancer | Session is terminated at GFEs at the network edge and traffic is proxied from GFEs to backends | Global |
| External passthrough Network Load Balancer | Traffic passes through unaltered to backend VMs and is distributed by Maglev based on source and destination port, IP address, and protocol | Regional |
Global load balancing requires Premium Tier in Network Service Tiers because Standard Tier traffic enters Google's network at a PoP close to the destination region rather than the PoP closest to the user.
Exam tip: Choose Premium Tier when using global load balancing and Cloud CDN, because only Premium Tier enters Google's network at the PoP closest to the sender and exits at the PoP closest to the destination.
Layered application caching reduces origin and dependency latency when requests cannot be served from Cloud CDN. The three peer layers operate at progressively deeper positions in the serving path: edge caching absorbs repeated content requests before they reach the application, Memcache absorbs repeated data lookups before they reach the slower persistence layer, and in-instance memory absorbs repeated reads inside the application instance itself. An intelligent frontend caching layer or asynchronous writes can let a distributed frontend answer with few or no synchronous round trips to a central backend.
A caching layer failure causes a sudden latency increase because more requests fall through to a slower dependency. For example, a Memcache flush causes more requests to go to a slower Datastore, so latency spikes correlate with the dependency rather than with frontend capacity. Monitor application dependencies to detect when increased traffic or a workload change increases dependency latency, and design the application to shed load with adaptive throttling when a non-scaling dependency such as a SQL database risks overload from too many connections.
Global deployment patterns trade lower user latency against data-replication complexity, and caching determines which pattern is viable without full replication. A single-region deployment keeps frontend and backend in one region and relies on Cloud CDN and global load balancing to reduce user latency; this remains the best choice in many cases because multi-region complexity outweighs the latency gain, and a second region used only for backup and disaster recovery does not affect the serving path. A distributed frontend with a single-region backend lowers latency to frontend servers without syncing data across regions and works when the average request needs no backend data or only a few backend requests, such as with frontend caching or asynchronous writes.
A distributed frontend and backend in multiple regions minimizes user latency because the application can fully answer any request locally, but all data must be stored and accessible locally through full replication. Spanner supports this pattern with a three-continent multi-regional option that places read-write replicas in the US and read replicas in Europe and Asia for low-latency reads from compute in those continents. Multiple parallel apps preserve low latency while reducing replication by directing users to the correct regional frontend and backend pair and sharing only a small fraction of data, as with country domains for retail, separate game rooms or worlds selected from a global lobby, or region-specific subdomains selected at SaaS account creation.
Diagnosing root causes of latency across GCP services means separating total end-to-end delay into application-level, network-level, and external service bottlenecks. Cloud Trace shows time spent in each span of a request, VPC Flow Logs shows TCP round-trip time between network endpoints, and latency metrics in Cloud Monitoring show where delay appears along the path. A request typically flows from the client through the internet to the Google Front End (GFE) to the serving infrastructure to the service instance and then to any backing dependencies, so each layer must be compared before changing code or capacity.
Server, operation, and workload latency signals define different owners of delay that must not be confused. Server latency measures work inside the service, starting when the service receives the request and ending when it sends the last byte of response. Operation latency measures the total end-to-end round trip from the client to the service and back to the client, including retries, client-library time, network time, and server time. Workload and request patterns can raise operation latency even when infrastructure is healthy, for example when a scan grows from a hundred rows to a million rows after a data import or logic change.
Because the signals have different owners, high operation latency with flat server latency points away from the server toward the client, network, or dependencies. For large responses, slow consumption by the client can also inflate server latency because the server waits to deliver bytes. Always compare the same percentile and time window on both sides, since a large spike in a small window can look negligible in a larger window and the reverse is also true.
Scoping the incident defines which applications, services, versions, endpoints, clients, and time window are affected and how latency was measured. Cloud Monitoring provides request-latency dashboards by percentile, such as 50th, 95th, and 99th percentile latency, so high latency on all three means at least half of requests are slow while high latency only at the 99th percentile means about 1% of requests are slow. To minimize baseline network distance, verify that the application resides in the same zone as its database cluster, and gather project ID, instance ID, cluster ID, table name, client region, client library, affected API method, before-during-after latency values, errors, and mitigation steps.
Use this ordered comparison to isolate the layer:
bigtable.googleapis.com/client in Metrics Explorer or open the Cloud Run (opens in a new tab) Request latencies dashboard under Cloud Run Revision > Request_latencies > Request latency, with no setup required for Cloud Run integration.traceSampled=true filter in Cloud Logging to correlate logs with traces in Cloud Trace, and filter by instanceId to follow sequential requests on one Cloud Run or App Engine instance when concurrency allows multiple requests per instance.If monitoring shows elevated latency but request logs do not, the failure may be upstream load balancing or a severe instance failure that stops routing. Look at logs just before the incident; rising latency before failure means application instances were degrading before the load balancer stopped sending them traffic.
Cloud Trace analyzes the network path and service dependencies by breaking one request into spans for the frontend, application code, and each downstream call. Data flows from the trigger or ingress to each connector or dependency step and then to the destination system, so missing explicit logging for a dependency can make external delay look like delay in the main service. Add explicit logging around calls to other services, databases, and APIs, then correlate container or application logs with the request log to find the request trace and its slowest span.
In App Engine, the request path flows from Client to Internet to Google Front End (GFE) to App Engine serving infrastructure to Service instance. If App Engine request logs show HTTP errors or elevated latency, the issue likely lies in the instance that runs the service; if instance count has not scaled with traffic, overloaded instances cause both errors and latency. In Cloud Run, shared global objects such as a single connection pool can bind latency to one instance under concurrency, so filtering by instanceId reveals cold starts, reused state, and queuing on specific instances.
Exam tip: When application-blocking latencies are low and serving latency is also low, the bottleneck is likely in an intermediate network or traffic-path component such as the network or GFE, not in application code or the database server.
VPC Flow Logs measures TCP round-trip time between both ends of a connection, which separates network transit time from application processing time. For HTTP(S) load balancing, Cloud Monitoring provides frontend round-trip time between the load balancer and the client and backend latency between the load balancer and the backend, while user-defined request headers can add client country, subregion, city, and estimated round-trip time. Premium Tier networking delivers traffic through Google's global private network with lower latency and is required for global load balancing, while Standard Tier delivers traffic over transit ISPs from Google Cloud regions.
When network delay is suspected, analyze the path from source to destination and capture packets at both endpoints at the same time:
traceroute, MTR, or TCP traceroute; run curl connection timing to measure client connection latency to the nearest GFE, then use traceroute to find the slow hop and test from different geographies.tcpdump or Wireshark; a PCAP sidecar runs tcpdump in the same network namespace as a Cloud Run service without modifying ingress, using its own resources so capture does not compete with the primary container.Interpreting geography matters because Google resolves hostnames to the closest GFE based on client IP in DNS lookup, and clients whose resolvers do not use EDNS0 may route to a farther GFE. HTTP/2 clients sending parallel requests can see head-of-line blocking at the GFE and need the QUIC protocol, while custom domains add an extra hop for SSL termination at the GFE compared with appspot.com. For planning, estimate about 1 ms of round-trip latency for every 100 km traveled, multiplied by about 1.5 to 2 times map distance for non-ideal routing, and remember that Europe-to-Asia traffic often flows through the US when direct connectivity is missing.
Google Cloud typically measures less than 55 microseconds round-trip at the 50th percentile and less than 80 microseconds at the 99th percentile between c2-standard-4 VM instances in the same zone using a netperf TCP_RR benchmark. With a compact placement policy that places VMs in the same low-latency network, typical latency drops to less than 45 microseconds at the 50th percentile and less than 60 microseconds at the 99th percentile.
Client-side queuing raises operation latency even when server latency is flat. In Cloud Bigtable (opens in a new tab), check the Application Blocking Latencies metric; high values that match the reported increase focus attention on the client, while high values for a client on Google Kubernetes Engine (GKE) or Compute Engine may require escalation after client causes are ruled out. Tune the gRPC channel pool by iterating to the optimal size, because too few channels cause requests to queue in gRPC channels as buffered requests and too many channels can raise attempt latencies, and enable channel priming on Java client 2.17.1 or earlier while 2.18.0 and later refresh channels by default.
Two client counters distinguish retry behavior from reachability. If connectivity_error_count is high, the application has trouble reaching the Google frontend, so set lower RPC timeouts so requests retry on different channels, but avoid setting timeouts far below the normal P99 RPC latency. If retry_count is high, check the attempt_latencies status tag; attempts failing with DEADLINE_EXCEEDED mean the request deadline is too short compared with average attempt latency. If no metric exceeds its norm, requests may queue on the gRPC thread due to small channel pool size or high client VM CPU usage, and on Java 2.21.0 and later the client_blocking_latencies metric also includes time queued on gRPC channels.
Serverless and autoscaled platforms add cold-start and scaling delay on top of code delay. Increasing Cloud Run minimum instances keeps instances warm and reduces incoming-request latency, while adjusting maximum instances limits connections to a backing service and code changes or Profiler findings address slow handlers. In App Engine, traffic that scales faster than autoscaling, interval batch spikes, CPU-based scaling of an I/O-bound flexible-environment service, and deployments that migrate traffic before caches warm can all overload instances; avoid reusing an existing version name because all instances restart together and rollback requires redeploy.
Bottleneck domains differ by where delay appears and which tool proves it. Application fixes apply when traces and client metrics name queuing, cold starts, undersized instances, or slow code; the service depends on its channel pool, CPU, and scaling settings. Network fixes apply when flow logs, frontend round-trip time, and path tools name distance, routing, bandwidth, or GFE behavior; traffic flows from client to GFE to serving infrastructure to instance, so each boundary needs its own measurement. Dependency fixes apply when only the downstream span is slow; the workflow depends on the connector or backend, so limit connections, add caching, or move work closer to users.
| Bottleneck domain | Signal in metrics and logs | Confirming tool |
|---|---|---|
| Application and client | High operation latency with flat server latency, high application-blocking latency, high retry_count or gRPC queuing, slow spans inside instance traces, high client CPU | Cloud Trace spans, correlated Cloud Logging with traceSampled=true, client-side metrics, Profiler, instanceId filtering |
| Network path | Low serving and application-blocking latency but high end-to-end latency, high frontend round-trip time, TCP retransmits or slow hops, GFE routing or SSL effects | VPC Flow Logs TCP round-trip time, load-balancer frontend and backend latencies, MTR or traceroute, simultaneous packet captures, Connectivity Tests |
| External dependency | Main-service trace is flat while a downstream span is slow, missing dependency logs make the main service look slow, dependency incident aligns with time window | Cloud Trace dependency spans, explicit dependency logging correlated to the same trace, dependency health and quota metrics |
Optimizing resource configuration and scaling for performance means matching compute, scaling, and database capacity to actual workload demand so latency stays low without overspending. In Google Cloud, this work spans Compute Engine (opens in a new tab) machine selection, Managed Instance Groups (MIGs) and Google Kubernetes Engine (GKE) autoscaling, Cloud SQL (opens in a new tab) sizing and tuning, and continuous verification with Cloud Monitoring and Cloud Profiler. The common tradeoff is headroom versus cost: too little capacity creates CPU, memory, or I/O saturation and latency, while too much capacity wastes budget.
Right-sizing Compute Engine means choosing a VM machine type that fits the workload's CPU and memory profile rather than defaulting to an oversized shape. Compute Engine machine type recommendations analyze utilization and suggest a smaller or larger type, while custom machine types let teams with predictable requirements provision cores and memory independently to avoid paying for unneeded resources. For licensed third-party software, this independence matters because limiting CPU cores directly limits license cost, and disabling simultaneous multithreading (SMT) reduces vCPUs per core from 2 to 1 for the same reason.
Disk performance also depends on sizing because throughput and IOPS scale with disk size and vCPU count. An undersized target instance can cause long migrations, database errors, and application latency even when CPU looks healthy. When performance-intensive work still saturates a well-sized VM, the next step is to scale out with groups and autoscaling rather than continuing to grow a single VM.
Capacity planning for performance establishes how much infrastructure must exist before autoscaling can react to traffic. Capacity planning for a MIG deployment decides MIG size, VM machine type, and the number, type, and size of persistent disks, with cost estimated through the Google Cloud Pricing Calculator. Forecasting that capacity considers peer demand signals:
Planned capacity must include redundancy, quotas, and assured supply. N+1 redundancy requires at least one redundant component beyond the minimum needed to handle forecast load for every layer of the stack. Quotas are per-project limits that can block scale-out and come as resource quotas for maximum creatable resources and rate quotas for API requests per period, applied at zonal, regional, or global scope. Reservations provide assured capacity in a specific zone for a specified number of VMs of a chosen machine type and can be specific to one project or shared across projects. Benchmarking validates the plan by load-testing under both normal and peak conditions, because resource efficiency relating load to CPU and memory consumption can degrade sharply at high load and drift over time.
Autoscaling for Compute Engine depends on whether the group is stateless or stateful and on the provisioning model. Autoscaling of stateless MIGs adds VMs when traffic rises and removes them when demand falls, which handles surges gracefully and reduces cost when need is low. Stateful MIGs cannot be autoscaled because each VM preserves unique state, so they must be sized manually. Spot VMs offer the same machine types, options, and performance as regular VMs at significantly lower cost, but Compute Engine can preemptively stop or delete them, and a MIG may be unable to scale out to its target size when zonal capacity is limited.
GKE separates scaling into pod and node layers that work together. HorizontalPodAutoscaler (HPA) adds and removes Pods based on CPU or custom metrics, with a target such as 70% or 80% utilization to leave buffer while new replicas start. VerticalPodAutoscaler (VPA) resizes container CPU and memory requests for workloads that do not scale horizontally or where peaks are unknown. Cluster Autoscaler scales the underlying nodes based on pending-pod scheduling simulation rather than raw metrics, while node auto-creation automatically creates custom node pools whose CPU and memory shapes fit pending Pods to reduce stranded capacity on oversized nodes.
| GKE scaler | What it scales | Scaling signal |
|---|---|---|
| HorizontalPodAutoscaler (HPA) | Number of Pod replicas | CPU utilization or custom application metrics |
| VerticalPodAutoscaler (VPA) | CPU and memory requests per container | Historical container utilization |
| Cluster Autoscaler | Number of nodes in Standard node pools | Unschedulable Pods and underutilized nodes |
| Node auto-creation | Number and shape of node pools | Scheduling requirements of pending Pods |
The layers depend on each other in order: HPA first increases Pod demand, then Cluster Autoscaler adds nodes only if Pods cannot be scheduled, then scale-down consolidates work and removes underutilized nodes. Safe operation requires bounds and disruption controls, so VPA should run in Off recommendation-only mode for at least 24 hours and ideally one week to capture representative traffic before enabling Initial or Auto with explicit minimum and maximum limits. Cluster Autoscaler similarly depends on a PodDisruptionBudget (PDB) for system and application Pods so node consolidation does not evict too many replicas at once, plus a minimum node count to preserve baseline night capacity.
Exam tip: Autoscaling applies to stateless MIGs, while stateful MIGs cannot be autoscaled and must be sized manually.
Cloud SQL performance depends on instance sizing, data locality, query efficiency, and storage choice. A Cloud SQL instance becomes constrained when CPU or memory saturates, and performance-intensive workloads should have at least 60 GB of memory to avoid pressure that slows the whole operation. Distance creates latency in both directions: slow inserts, updates, or deletes often reflect separation between the writer and the database, while slow reads often reflect separation between the reader and the database, with reads affected more than writes. A very large number of tables can further degrade performance and availability and risk loss of SLA coverage.
Query and file behavior determine whether added capacity actually helps. Query Insights, available as a predefined dashboard in Cloud Monitoring alongside engine-native tools, collects query telemetry through built-in agents and identifies the most expensive commands to optimize. Database files should not grow unchecked, so set autogrow in megabytes with increments matched to requirements rather than as a percentage. Storage selection balances speed and cost: SSD is the efficient default for most uses, while HDD fits only datasets of 10 TB or more that are latency-insensitive or infrequently accessed. Cloud SQL Enterprise Plus edition raises machine-configuration limits and adds data cache for workloads that need higher throughput and lower latency, and automatic storage increases with peak-workload buffer prevent outages as data grows over time.
Cloud Monitoring and Cloud Profiler turn resource signals into rightsizing and tuning decisions. Cloud Monitoring collects measurements from services and Google Cloud resources, provides predefined dashboards including a Cloud SQL monitoring dashboard, and supports custom dashboards and alert policies for timely notification of saturation. Telemetry flows from the workload and built-in database agents to Cloud Monitoring, then to dashboards that expose CPU, memory, disk, and query health, then to alerts and rightsizing actions that reduce overprovisioned instances without adding capacity risk. Active Assist adds cost and configuration recommendations on top of the same utilization data.
Cloud Profiler (opens in a new tab) identifies performance bottlenecks inside function blocks in application code, which helps optimize execution time and resource usage when infrastructure metrics look normal but latency remains high. Cloud Trace pinpoints latency across distributed microservices by showing request flow, while Cloud Logging provides event and error context for troubleshooting. Together, the tools separate code-level hotspots from capacity limits: fix the query or function when Profiler and Query Insights point to expensive operations, and adjust machine type, replica count, autoscaling policy, or edition only after confirming that CPU, memory, or I/O is truly constrained.
Premium Tier is required when using global load balancing and Cloud CDN because only Premium Tier enters Google's network at the point of presence closest to the sender and exits at the point of presence closest to the destination. Standard Tier traffic enters Google's network at a point of presence close to the destination region rather than the point of presence closest to the user.
Server latency measures work inside the service, starting when the service receives the request and ending when it sends the last byte of response, while operation latency measures the total end-to-end round trip from the client to the service and back to the client, including retries, client-library time, network time, and server time. High operation latency with flat server latency points away from the server toward the client, network, or dependencies.
With the global external Application Load Balancer, a user request flows to the global front end, then through Google Cloud Armor edge security policies, then to the Cloud CDN cache check. If the request is a cache hit, content is retrieved from cache and sent back to the user without contacting the origin, and if the request is a cache miss, it is evaluated by backend security policies and then fulfilled by the backend server according to policy rules.
Your microservices application running on Google Kubernetes Engine (GKE) is experiencing high p99 latency spikes during peak hours. The application communicates internally with a Cloud SQL database and externally with a third-party payment gateway via an Internal Application Load Balancer and Cloud NAT.
You need to distinguish whether the root cause of the latency bottleneck is caused by internal application processing, internal network round-trip time (RTT), or external service dependencies.
Which observability strategy should you implement?
Enable VPC Flow Logs with 100% sampling across all VPC subnets, export the logs to BigQuery, and execute scheduled queries on TCP sequence numbers to isolate application processing time.
Configure Cloud Profiler across all GKE pods and monitor Dataflow system lag metrics to track downstream third-party API response times.
Run tcpdump packet captures manually across all GKE worker nodes to inspect ARP packets and TCP retransmissions for each pod endpoint.
Instrument the services with OpenTelemetry to export distributed trace spans to Cloud Trace, correlate spans with Cloud Logging, and evaluate Application Load Balancer RTT and proxy latency metrics.
Last updated