Prepare and test your skills

Prepare and test your skills

Designing for state management and data durability means keeping processing progress and data copies outside ephemeral compute so a restart resumes work without loss. Cloud Storage (opens in a new tab) holds backups, exports, and transaction logs as replayable sources, Compute Engine (opens in a new tab) persistent disks and snapshots hold VM and filesystem state, and managed databases hold replicated table state. Together, checkpoints, durable copies, and replay steps let a pipeline restart from the last good point instead of restarting from the beginning.
Checkpointed processing is a design where a job writes regular progress markers to durable storage so it can resume from the point of failure after VMs are replaced. Batch processing workloads use this approach because they can tolerate interruptions and can run on cost-effective Spot VMs and preemptible VM instances, which Compute Engine can preemptively stop or delete when capacity is needed elsewhere. When new VMs launch, the job reads the last checkpoint and continues, which creates a short pause while replacements start in what is described as a warm pattern. If the workload runs on Managed Service for Apache Spark, a managed instance group manages the launch of preemptible worker nodes automatically.
The same checkpoint idea applies to training and long-running compute that can tolerate interruptions. Training code that implements checkpointing can restart on Spot VMs without losing all progress, trading lower compute cost for the need to write and restore state frequently. The pipeline therefore depends on two sides: ephemeral workers that do the work, and durable storage that holds checkpoints, backups, and logs. First the job writes state outward to durable storage, then on failure new workers read that state back before resuming.
A replayable source is a durable copy that can be re-applied in order to rebuild state after a restart, such as a full backup followed by transaction logs. In the database recovery topology, backup files and transaction log files flow from the on-premises database to a Cloud Storage bucket, then from the bucket to the recovery database instance in Google Cloud. Keeping transaction logs in addition to full backups keeps recovery point objective (RPO) small, because replaying logs moves the recovered state much closer to the pre-disaster point than the last full backup alone. When returning to production, the flow reverses: a backup of the database running in Google Cloud flows back to production, transaction logs follow, and clients are redirected only after the logs are applied.
A typical recovery sequence to a database server in Google Cloud follows this fixed order:
This ordered replay also applies to analytics state. Data warehouses are often append-only and updated through controlled extract, transform, load (ETL) or extract, load, transform (ELT) paths, so recent updates can be reproduced from alternative sources instead of restoring petabytes. Strategies include storing data in different tables for specific time periods so only the affected subset is restored to a new table, and storing original data in Cloud Storage so a new table can be reloaded without corrupted rows. If corruption is caught within 7 days in BigQuery (opens in a new tab), a table can be queried to a point in time in the past with snapshot decorators; otherwise an export can be used to create a new table that excludes corrupted data.
Exam tip: Replication continuously copies changes, including corruption, to the replica, while point-in-time backups and snapshots preserve an earlier clean state for restore.
Durable storage for pipeline state separates where progress is kept from where compute runs, so disks, tables, and objects survive VM loss. Persistent Disk snapshots provide block-level copies that can recreate disks, and snapshots are available across regions so a disk can be restored in a different region from the source. A variation uses regional persistent disks instead of standard persistent disks, which removes the explicit snapshot-restore step during recovery. Persistent Disk Asynchronous Replication provides asynchronous block replication with low RPO and low recovery time objective (RTO) for cross-region active-passive disaster recovery at the infrastructure level rather than the workload level.
Tiered object storage lowers the cost of keeping older durable copies that are rarely accessed. When production runs in Google Cloud, a common pattern migrates backup data from persistent disks to Cloud Storage Nearline, Coldline, and Archive classes because the likelihood of access decreases over time. Data stored in regional buckets is replicated synchronously across multiple zones within a region, while dual-region or multi-region buckets replicate asynchronously across regions for higher availability. The Nearline, Coldline, and Archive classes carry additional retrieval costs and minimum storage durations, so the choice trades lower storage cost against higher cost and delay if the data must be read back quickly.
Managed database services add built-in durability that reduces custom backup work. Bigtable replication provides higher availability, additional read throughput, and resilience to zonal or regional failures, while Bigtable backups save a copy of a table schema and data for later restore to a new table. BigQuery stores data synchronously in two zones within the specified region to survive a zone outage, and tables unedited for 90 consecutive days automatically move to long-term storage pricing with about a 50 percent price drop and no loss of performance or durability. Spanner (opens in a new tab) uses multi-region configurations that replicate data across zones in multiple regions, plus deletion protection, scheduled and cross-region backup copies, and point-in-time recovery for up to seven days against logical corruption or accidental writes.
Recovery readiness describes how much of the recovery environment is already running before a failure, which directly controls RTO and cost. A cold pattern keeps minimal resources and starts a mirror of production only after failure, a warm pattern keeps a small standby such as a minimally sized database receiving replication plus reference images or snapshots, and a hot pattern runs both environments in production mode serving traffic concurrently. The tradeoff is continuous cost against pause during replacement: cold is cheapest but waits for deployment and restore, warm shortens the pause because replication and snapshots are already current, and hot minimizes intervention because traffic only needs rerouting.
The following comparison shows what is running before failure and how restart behaves for each pattern:
| Pattern | What is running before failure | Restart behavior |
|---|---|---|
| Cold | Minimal resources, custom images, backups in Cloud Storage, Deployment Manager template | Deploy from template, restore latest backup and logs, then point Cloud DNS to Google Cloud |
| Warm | Small database accepting replication, snapshots, reservations for web and application servers | Resize database for production load, create web and application instances from snapshots, then point Cloud DNS to Google Cloud |
| Cold recoverable server on Google Cloud | Instance template, custom image, scheduled snapshots, managed instance group with target size of one | Managed instance group recreates the failed VM automatically, startup script creates and mounts a disk from the latest snapshot behind the same load balancer IP |
| Hot | Both on-premises and Google Cloud serving production with database replication and regional managed instance groups | Reroute DNS to the surviving environment and promote the read-only replica to writeable primary if promotion is not automatic |
Restart behavior depends on health detection and traffic control sitting outside the failed component. Cloud DNS with health checks or weighted routing moves client traffic from the failed environment to the equivalent service in the surviving environment, while Cloud Load Balancing keeps a stable front-end address when a replacement VM is created. If the database allows only a single writeable instance, the surviving read-only replica must become the writeable primary, either automatically on heartbeat loss or through manual promotion. After the failed environment can handle traffic again, databases must be resynchronized before traffic is distributed across both environments, otherwise writes on the two sides will diverge.
Configuring managed restart and recovery strategies means combining Compute Engine restart policies, health-checked instance groups, and automated restore workflows so failed services return to a healthy state without manual rebuilds. Compute Engine (opens in a new tab) provides the host-level restart behavior, managed instance groups (MIGs) provide the auto-repair behavior, and startup scripts, templates, snapshots, and DNS routing provide the data and traffic recovery behavior. Together they let batch, transactional, and streaming workloads meet different recovery time and recovery point targets.
Compute Engine restart behavior is controlled by two instance properties that handle different failure types. The onHostMaintenance property set to MIGRATE keeps instances online during Google-initiated maintenance by live-migrating the running VM from the source host to the destination host, and MIGRATE is the default. The automaticRestart property set to true, also the default, lets Google restart any instance that becomes unresponsive or crashes, which covers instances that do not support live migration. For sole-tenant nodes that do not support live migration or planned maintenance, advanced maintenance controls provide additional planned-maintenance behavior.
Live migration and automatic restart remove single points of failure at the host layer, but they do not replace application-level redundancy. Resilient deployments therefore combine these policies with broader practices:
The VM depends on quota and capacity in the recovery region, so designs that defer deployment until recovery must verify quotas periodically, while pre-deployed stopped VMs save compute cost but still incur charges for attached external static IPs and persistent disks.
A managed instance group (MIG) is the managed recovery controller that keeps the target number of identical VMs running from an instance template. The MIG depends on the instance template, which depends on the custom VM image, so a replacement VM is configured identically to the VM it replaces. When a VM fails its health check, the MIG automatically deletes and recreates the VM without an operator initiating failover. For a cold single-writer case where only one instance should write to disk, the MIG is configured with a target size of one, which replaces an on-premises active/passive cluster.
Health checking and traffic stability come from Cloud Monitoring (opens in a new tab) alerts and load balancer health checks placed in front of the MIG. Cloud Monitoring sends an alert when the service fails and can invoke an automated failover process, while the load balancer continuously probes backend VMs and sends traffic only to healthy backends. An external Application Load Balancer preserves the same frontend IP address in front of the application server even while the MIG replaces the backend VM, so clients do not need a new address during repair. In hot designs, regional MIGs distribute application and web servers across zones, and Cloud Load Balancing distributes traffic across those healthy instances.
Exam tip: automaticRestart=true restarts a crashed VM after failure, while onHostMaintenance=MIGRATE keeps a running VM online during host maintenance by moving it to another host.
Automated recovery workflows restore both configuration and data when a new VM starts. A custom VM image holds the application web service, and the instance template references that image plus a startup script. On boot, the startup script queries for the latest persistent disk snapshot, creates a persistent disk from that snapshot, mounts the disk, and then starts the application service, so data flows from the snapshot to the new disk to the replacement VM. Scheduled snapshots of the persistent disk and Backup and DR Service incremental backups of persistent disks at the instance level provide the recurring point-in-time copies that the script restores from.
Stateful recovery adds ordering constraints that the workflow must preserve. First, the database backup from Cloud Storage (opens in a new tab) is applied to the database server, then transaction logs copied to Cloud Storage are replayed to reach the smallest recovery point, and only after replay is the instance resized to a machine type capable of accepting production traffic. Persistent disks attached to a standby database must have auto-delete set to no-auto-delete so the data survives if the instance is deleted, and snapshots must be stored in a Cloud Storage multi-regional or regional location that is accessible from the recovery site. For cross-region block replication with low recovery point and recovery time, Persistent Disk Asynchronous Replication replicates individual VMs or Consistency Groups of dependent VMs, with Jetstream as a supervisory appliance over replication for stateless workloads and database-native replication such as HANA System Replication for databases.
Failover moves production traffic only after the recovered environment proves it can serve requests. Cloud DNS controls the traffic boundary between the primary environment and the recovery environment, with records pointing to the internet-facing web service in whichever environment is currently primary. If the DNS service supports health checks, traffic reroutes automatically when health checks determine that web servers in one environment cannot be reached; otherwise DNS routing must be changed manually to send traffic to the system that is still up. For partial failures, traffic flows from the failed tier to the equivalent service in the other environment rather than failing over the entire system.
A typical recovery sequence preserves verification before cutover:
Batch processing workloads use a lighter variant of this sequence where regular checkpoints let the job resume from the point of failure. Batch jobs can run on lower-cost Spot VMs and preemptible instances that Compute Engine may preempt, and when Managed Service for Apache Spark launches preemptible worker nodes through a MIG, replacement VMs continue processing after a short pause.
Cold, warm, and hot patterns differ by how much compute stays running and how much intervention recovery needs. Cold keeps minimal resources and rebuilds on failure, warm keeps a small standby with replicated data and reservations, and hot runs both environments in production concurrently. The choice trades cost against recovery time objective (RTO) and recovery point objective (RPO).
The following comparison summarizes the running resources and failover behavior for each pattern:
| Pattern | Running resources | Failover and restart behavior |
|---|---|---|
| Cold | Minimal project resources, custom images, snapshots, and templates only | Start mirror environment from template on failure, restore latest backup and logs via startup script, then switch Cloud DNS; highest RTO and lowest cost |
| Warm | Small database instance accepting replication, snapshots, and capacity reservations | Resize database to production size, create web and application instances from snapshots, replay logs, then switch Cloud DNS; short pause for replacement VMs |
| Hot | Full production capacity in both on-premises and Google Cloud serving traffic via weighted DNS | No rebuild needed; reroute DNS away from failed environment and promote read-only replica to writeable primary if not automatic, then resynchronize after repair; minimal RTO and RPO at highest cost |
Ecommerce illustrates mixing patterns in one application, with the purchasing pipeline kept hot for minimal RTO while order-notification email tolerates hours of delay as warm or cold. Video streaming requires a hot pattern throughout because search and streaming both need high availability and low latency. Backup frequency controls maximum data loss since the last copy, retention controls how far back recovery can go, and replication reduces elapsed time since the last backup to near zero for business-critical databases and files.
Implementing proactive fault tolerance patterns means designing data and AI systems so a single failing component cannot cascade into a full outage. The core patterns are the circuit breaker pattern, which stops traffic to an overloaded or failing service so it can recover, exponential backoff, which spaces out retries, and graceful degradation, which keeps essential functions running with reduced performance or stale data. On Google Cloud these patterns are implemented with a combination of application logic, a service mesh, caching, redundancy, and proactive monitoring.
The circuit breaker pattern isolates a faulty component by blocking new requests to it once error rates or latency cross a threshold, giving the overloaded service time to recover instead of being overwhelmed by retries. Exponential backoff complements the circuit breaker by increasing the wait between retry attempts, which reduces load on the failing service and prevents cascading failures across distributed services. Together they increase resiliency either by allowing recovery or by handling the error state gracefully.
A service mesh (opens in a new tab) is software that links distributed services together and decouples business logic from networking. Traffic flows from the calling service through the mesh to the destination service, and the mesh applies resiliency features on that path, including request retries, failovers, and circuit breakers. For externally exposed prediction, training, and data APIs, API Gateway provides a centralized entry point where rate limiting and usage quotas protect backends from overload. For distributed code, fault isolation is implemented with resilience libraries such as Resilience4j in Java and CircuitBreaker in Python, with thresholds based on workload metrics like error rates and latency and fallbacks defined as simpler models or cached data.
The following comparison shows how each traffic pattern protects the failing service:
| Pattern | What it does to traffic | Outcome for the failing service |
|---|---|---|
| Circuit breaker | Stops forwarding requests to the failing service after a threshold | Service gets a chance to recover without added load |
| Exponential backoff | Spaces out retries with increasing delays | Reduces retry storms and cascading pressure |
| Graceful degradation | Serves a reduced response from cache or fallback logic | User impact is limited while the failure persists |
Exam tip: Use a circuit breaker to stop traffic and let a service recover, and use graceful degradation to keep serving requests with reduced or stale results during the outage.
Graceful degradation ensures that essential functions continue to operate, potentially with reduced performance, which prevents complete outages and improves overall availability. Graceful degradation is critical for latency-sensitive inference, distributed training, and generative AI, where a full stop is worse than a slower or simpler answer. When a downstream dependency fails, the system falls back to a defined alternative such as a simpler model or cached data.
Caching directly enables this pattern for data workloads. A cache increases retrieval performance by serving requests from memory and reducing reliance on slower disk-based storage, which also reduces load on downstream databases. If the underlying storage layer is overloaded or unavailable, requests flow from the application to the cache instead of the storage layer, and the cache continues to handle requests even though the data may be incomplete or not up to date. Memorystore for Redis (opens in a new tab) provides this capability as a fully managed Redis in-memory datastore with low-latency access and high throughput, and it can be deployed in a high-availability configuration that provides cross-zone replication and automatic failover.
Component redundancy ensures that failure of an individual component does not cause failure of the complete system by building replication into the architecture. For compute, this means running Google Kubernetes Engine (GKE) as multi-zone or regional clusters and deploying Cloud Run services redundantly across different regions. Traffic flows from clients to Cloud Load Balancing, which detects unhealthy instances and routes traffic only to healthy instances in available zones or regions.
Data redundancy follows the same principle across storage layers. Cloud Storage multi-regional buckets replicate data across regions so reads can survive a regional disruption, while synchronous replication within a region protects against zonal loss. For distributed training, asynchronous checkpointing lets a job resume after failures from the last checkpoint rather than restarting, and Pathways provides resilient and elastic training that adapts to node failures. Choose redundant deployment when the component is critical for inference availability or training progress; accept the added cost and replication latency as the tradeoff for continuity.
Proactive monitoring detects the need for graceful degradation and triggers recovery before accuracy or availability collapses. Cloud Monitoring (opens in a new tab) collects system metrics specific to AI and ML workloads, such as latency, throughput, and GPU utilization, while Model Monitoring on Gemini Enterprise Agent Platform tracks model performance degradation such as model drift and data drift. Continuous health checks evaluate these signals against thresholds, so degradation is caught while partial functionality is still possible.
When a health check fails, the monitoring system triggers a defined recovery action. The action depends on the signal: replace faulty nodes, deploy more capacity through autoscaling, or automatically trigger continuous retraining or fine-tuning pipelines that use updated data. Adopt site reliability engineering (SRE) practices to govern these decisions with service level objectives (SLOs), where alerts on error budget loss and burn rate serve as early indicators of reliability problems. This loop connects detection to action: metrics flow from workloads to monitoring, monitoring triggers failover or retraining, and traffic returns to healthy capacity once it is available.
In Compute Engine, automaticRestart set to true lets Google restart an instance that becomes unresponsive or crashes, while onHostMaintenance set to MIGRATE keeps a running instance online during Google-initiated maintenance by live-migrating it to another host. Both settings are defaults, they handle different failure types, and they do not replace application-level redundancy.
Spot VMs and preemptible VM instances should be used for checkpointed batch processing and training workloads that can tolerate interruptions because Compute Engine can preemptively stop or delete them when capacity is needed elsewhere. The job writes regular progress markers to durable storage so when new VMs launch it reads the last checkpoint and continues, trading lower compute cost for frequent state writes and a short pause while replacements start.
Cold keeps minimal resources such as custom images, backups in Cloud Storage, and templates and rebuilds the mirror environment on failure with the highest recovery time objective and lowest cost. Warm keeps a small standby such as a minimally sized database receiving replication plus snapshots and reservations so recovery only needs resizing and restore with a short pause. Hot runs both environments in production serving traffic concurrently so failover only needs rerouting with Cloud DNS and promoting a read-only replica if needed, giving minimal recovery time and recovery point objectives at the highest cost.
You are redesigning a data ingestion pipeline for a high-traffic e-commerce platform. Currently, the order management service sends data to a downstream inventory processing service using synchronous API calls. When the inventory service experiences an outage or a traffic spike, the order management service blocks while waiting for responses. This leads to timeouts and cascading failures across the platform.
You need to implement a fault-tolerant pattern to achieve the following:
Which architectural approach should you implement?
Last updated