All guides
Practice now
D4 · Infrastructure and application modernization

Compute on Google Cloud

Compute Engine, GKE, Cloud Run, Cloud Run functions, and App Engine. When to use each option and the key trade-offs for the CDL exam.

The compute spectrum on GCP

Google Cloud offers compute across a spectrum of control vs. abstraction. More control = more responsibility. More abstraction = more development speed.

Compute Engine (IaaS)

→

GKE (Containers)

→

Cloud Run (Serverless containers)

→

Cloud Run functions (FaaS)

→

App Engine (PaaS)

← More control / more managementMore abstraction / more speed →

: Google Cloud's

VMs (instances) on Google's infrastructure. Full control: operating system, network, storage. Equivalent to AWS EC2 or Azure VMs.

Machine types

General purpose (N2, E2), memory-optimized (M3), compute-optimized (C3), GPU/TPU. Fine-tune vCPUs and RAM as needed.

Persistent Disk

Block storage attached to VMs. Standard HDD, Balanced SSD, or Extreme SSD. Independent of the VM lifecycle.

Managed Instance Groups

A group of identical VMs with auto-scaling, auto-healing, and load balancing. For and scale.

Spot VMs

VMs with up to 91% discount that GCP can revoke with 30s notice. Ideal for fault-tolerant batch workloads.

: Google Kubernetes Engine

GKE is fully managed Kubernetes. Google created Kubernetes internally (Borg) and donated it as open source — GKE is its most mature and optimized implementation.

Autopilot mode

Google manages all nodes and the control plane. You pay per pod, not per node. Maximum automation.

Standard mode

You control the nodes (VMs). More flexibility for workloads with special hardware requirements.

Auto-scaling

Horizontal Pod Autoscaler (pods) + Cluster Autoscaler (nodes). Scales automatically based on load.

GCP integration

Integrated with Cloud Load Balancing, Cloud Storage, Artifact Registry, Cloud Monitoring, and IAM.

When to choose GKE

Containerized apps with multiple microservices, you need advanced orchestration (rolling updates, canary deployments, service mesh), or your team already uses Kubernetes on-premises.

: serverless for containers

Cloud Run runs containers without managing infrastructure. Upload your Docker image, Cloud Run scales from 0 to N instances automatically, and you pay only for requests processed.

Scale-to-zero

If there's no traffic, Cloud Run scales to 0. You pay nothing at rest. Scales in milliseconds when a request arrives.

Any language

If it runs in a container, it runs on Cloud Run: Python, Node.js, Go, Java, Ruby, Rust, .NET...

Cloud Run Jobs

For batch tasks that run to completion (not HTTP). File processing, ETL, ML training.

Pricing

You pay per request + CPU/memory while processing. 2M requests/month free. Very economical for APIs with variable traffic.

and App Engine

Cloud Run functions (FaaS)

Runs individual functions in response to events: HTTP, Pub/Sub, Cloud Storage, Firestore. Fully serverless — zero infrastructure management.

Triggers: HTTP, Pub/Sub, Cloud Storage events, Firestore, Firebase
Built into Cloud Run (formerly Cloud Functions): up to 60 min for HTTP and 9 min for events
Use cases: webhooks, image processing on upload, notifications
You pay per invocation + execution time (2M invocations/month free)

App Engine ()

Managed platform for web apps and APIs. Upload your code, Google manages the runtime, scaling, and OS patches.

Standard: limited sandbox environment, scales to 0, fixed runtimes (Python, Java, Go, Node)
Flexible: uses Compute Engine VMs, any runtime in Docker
Traffic splitting: distributes % of traffic between versions (A/B testing, canary)
Legacy: many new apps prefer Cloud Run for greater flexibility

Comparison: when to use each service

ServiceUse it whenDon't use it when
Compute EngineYou need full OS control, you have legacy apps that can't be containerized, you require specific hardware (GPUs, TPUs)You want to forget about patching the OS or managing updates
GKEContainerized microservices, you need advanced orchestration, you already use Kubernetes on-premisesYou have few simple apps — the K8s overhead isn't worth it
Cloud RunHTTP APIs and services in containers, variable or unpredictable traffic, you want serverless but with your own imageYou need to run long-running processes without HTTP (use Cloud Run Jobs)
Cloud Run functionsSimple event-driven logic (max 60 min HTTP / 9 min events), responding to GCP events (Storage, Pub/Sub), quick webhooksComplex logic with multiple dependencies — better to use Cloud Run
App EngineMigrating legacy web apps to the cloud quickly without containerizing, apps with predictable trafficNew projects — Cloud Run offers more flexibility with fewer limitations

Containers vs. VMs: key differences

DimensionVMs (Compute Engine)Containers (GKE/Cloud Run)
What they includeFull OS + runtime + app. The entire stack is virtualized.Only the app + dependencies. They share the host OS kernel.
Typical sizeGB (image includes the entire OS)MB (only the app and its libraries)
Startup timeMinutes (full OS boot)Seconds or less (no OS boot)
IsolationVirtualized hardware — strong isolation between VMsIsolated process — share the host kernel
PortabilityDepends on the hypervisor and the imageHigh: runs the same on any host with Docker/Kubernetes
Resource overheadHigh: each VM has its own full OSLow: they share the kernel, more apps per server
When to useLegacy apps, specific OS, hardware isolation neededMicroservices, fast CI/CD, high app density

The value of APIs and Apigee

An API (Application Programming Interface) is a contract that defines how two software systems can communicate with each other. APIs let different applications share data and functionality without revealing their internal implementation.

In the digital economy, APIs are business assets: they enable partner ecosystems, open new revenue channels, and accelerate integration between services.

New sales channels

An airline exposes a flights API → Kayak, Google Flights integrate it → more sales without more infrastructure.

Direct monetization

Google Maps API, Stripe, Twilio charge for calls to their APIs. The APIs are the product.

Partner ecosystem

APIs let third parties build on top of your platform. The App Store is an ecosystem of APIs.

Internal integration

Microservices communicate via internal APIs. Teams develop independently and in a decoupled way.

API Management

Google Cloud's platform for designing, deploying, securing, and scaling APIs. It acts as the managed "front door" to all backend services. Apigee is the market-leading API management solution.

API Gateway: unified entry point for all APIs
Security: OAuth 2.0, API keys, rate limiting, JWT
Analytics: usage metrics (who calls, how much, from where)
Monetization: pricing plans and billing for third-party APIs
Developer Portal: documentation and sandbox for developers
Versioning: manages multiple API versions in parallel

Did you get this topic?

Test what you just learned

A startup is building a REST API that receives unpredictable traffic — high load during the day and almost none at night. They have no infrastructure team and want to deploy Docker containers. Which GCP service is most suitable?

Ready to test "Compute: Compute Engine, GKE, and Cloud Run"?

Put what you learned to the test with original CDL exam questions.

Start CDL mock exam

Unlimited mock exams with the Pro plan

Log in to track your progress.