SkarpSkarp

Chapter 5 of 27

Planning Compute: Choosing Between Compute Engine, GKE, Cloud Run, and Cloud Functions

Faced with a new workload, which compute service should you choose, and why does it matter for cost, scalability, and operations on the exam?

27 min readen

Big Picture: Your Four Compute Choices

Your Four Compute Choices

For the exam, almost every workload will run on one of four compute choices: Compute Engine, Google Kubernetes Engine, Cloud Run, or Cloud Functions. You must recognize each from a short scenario.

Control vs. Convenience Spectrum

Think of these as a spectrum: Compute Engine (most control), GKE (managed Kubernetes), Cloud Run (serverless containers), Cloud Functions (serverless code). More convenience usually means less infrastructure work.

Why This Matters on the Exam

In the Planning and configuring domain, you will see stories like "legacy app needing OS access" or "event-driven thumbnail generator" and must map them to the right compute choice and explain cost and ops trade-offs.

Compute Engine: Flagship IaaS VMs

What is Compute Engine?

Compute Engine is Google Cloud's IaaS: you get virtual machines with configurable CPU, memory, disks, and OS. You manage the OS, patches, and most system administration tasks.

When VMs Fit Best

Choose Compute Engine for lift-and-shift of traditional apps, custom runtimes needing OS control or drivers, stateful workloads, and long-running services that are always on.

Cost and Ops for VMs

You pay per-second for VM uptime and disks. You handle OS patching and security. For scaling, use managed instance groups and autoscaling policies instead of manual VM management.

Google Kubernetes Engine: Managed Kubernetes

What is GKE?

Google Kubernetes Engine is a managed Kubernetes service. You run containers managed by Kubernetes; Google runs the control plane. It is ideal for containerized microservices at scale.

Standard vs Autopilot

Standard GKE: you manage node pools and pay for VMs. Autopilot: Google manages nodes; you define pod resources and pay based on pod requests, reducing operational overhead.

Regional, Private, Enterprise

Regional clusters increase availability by spreading across zones. Private clusters keep nodes off the public internet. GKE Enterprise adds advanced multi-cluster and policy features for large orgs.

Cloud Run: Serverless Containers

What is Cloud Run?

Cloud Run is a fully managed serverless platform for containers. You provide a container that listens on a port; Cloud Run handles provisioning, autoscaling, and routing with no VM or cluster management.

When to Use Cloud Run

Choose Cloud Run for stateless HTTP APIs, event-driven processing via HTTP, and containerized workloads where you want autoscaling to zero and pay-per-use pricing instead of managing GKE or VMs.

Cost and Ops for Cloud Run

You pay for CPU, memory, and requests while handling traffic. You manage container images and app code, but not OS patching or Kubernetes. It integrates with IAM, Cloud Logging, and Monitoring.

Cloud Functions: Event-Driven Serverless Code

What is Cloud Functions?

Cloud Functions lets you deploy small pieces of code that run in response to events or HTTP requests. It is fully serverless: no servers, no containers, just your function and its dependencies.

When to Use Cloud Functions

Use Cloud Functions for event-driven tasks like reacting to Cloud Storage uploads, Pub/Sub messages, or scheduled jobs, and for simple HTTP endpoints or glue code between services.

Cost and Ops for Functions

You pay for invocations, compute time, and memory while functions execute. Google manages scaling and runtime patching, making it ideal for spiky or low-volume workloads that can scale to zero.

Comparing Ops, Scalability, and Pricing Models

Ops Responsibility Spectrum

From most to least ops work: Compute Engine (manage OS and scaling), GKE Standard (nodes + Kubernetes), GKE Autopilot/Cloud Run (containers only), Cloud Functions (just code and triggers).

Scalability Differences

Compute Engine scales via VM autoscaling; GKE scales pods and nodes; Cloud Run and Cloud Functions scale automatically per request or event, including to zero when idle.

Pricing Models and Exam Traps

VMs and GKE Standard: pay for running VMs. Autopilot, Cloud Run, and Cloud Functions: pay per requested or used resources. Watch for traps: SSH/OS access implies VMs or GKE, not serverless.

Scenario Walkthroughs: Picking the Right Compute

Scenario 1: Legacy Windows App

Needs Windows Server, custom drivers, always-on. This requires OS-level control. Best fit: Compute Engine with Windows VMs. Serverless options cannot install arbitrary drivers.

Scenario 2: Kubernetes Microservices

20+ microservices, rolling deploys, team already uses Kubernetes. Best fit: GKE (Standard or Autopilot). Cloud Run is simpler but may limit advanced Kubernetes patterns.

Scenarios 3 and 4

Public stateless HTTP API with traffic spikes: Cloud Run. Image thumbnails on Cloud Storage upload: Cloud Functions reacting to events. Practice also naming two less suitable options for each.

Thought Exercise: Map Requirements to Compute

Use this mental checklist to decide between Compute Engine, Google Kubernetes Engine, Cloud Run, and Cloud Functions. Pause and answer for yourself before reading the hints.

  1. Do you need OS-level access?
  • Example: Custom drivers, specific OS tuning, legacy software that expects a full server.
  • If yes, strongly consider Compute Engine (or GKE Standard if you can containerize but still need node-level control).
  1. Are you already using Kubernetes or need advanced orchestration?
  • Example: Many microservices, custom controllers, complex service meshes.
  • If yes, GKE is usually right. Decide between Standard (more node control) and Autopilot (less ops work).
  1. Is your workload a stateless HTTP service or simple container-based job?
  • Example: REST APIs, webhooks, background jobs triggered via HTTP.
  • If yes and you do not need Kubernetes features, Cloud Run is often ideal.
  1. Is this a small, event-driven piece of logic?
  • Example: React to Cloud Storage uploads, Pub/Sub messages, or scheduled tasks.
  • If yes, Cloud Functions fits best.

Activity:

  • Pick a project you know (university system, side project, or workplace app).
  • For each component (frontend, backend API, batch jobs, background processing), decide which of the four compute choices fits best and why.
  • Write down one reason for your choice in terms of ops, one in terms of scaling, and one in terms of cost.

This is exactly the kind of reasoning the exam expects in scenario questions.

Quick Check 1: Pick the Right Service

Answer this exam-style question.

Your team has a stateless Python API already containerized. Traffic is low most of the time but spikes during monthly campaigns. You want to minimize operations work and avoid paying for idle capacity. Which compute option is the best fit?

  1. Compute Engine managed instance group
  2. Google Kubernetes Engine Standard cluster
  3. Cloud Run
  4. Cloud Functions triggered by Pub/Sub
Show Answer

Answer: C) Cloud Run

**Cloud Run** is designed for stateless containerized HTTP services with autoscaling to zero and minimal operations. A Compute Engine MIG and GKE Standard both require more infrastructure management and bill for VMs even when idle. Cloud Functions is event-driven and does not directly run arbitrary containerized HTTP apps; it is better for small functions, not full APIs already packaged as containers.

Quick Check 2: Ops and Control

Another scenario to reinforce the differences.

A company is building a new platform with 30 microservices. They already use Kubernetes on-prem and want to reuse their Helm charts and Kubernetes manifests in the cloud. They need control over node types and some node-level agents. Which option is most appropriate?

  1. Cloud Functions
  2. Cloud Run
  3. Google Kubernetes Engine Standard mode
  4. Google Kubernetes Engine Autopilot mode
Show Answer

Answer: C) Google Kubernetes Engine Standard mode

**GKE Standard** is the best fit because the team wants to reuse Kubernetes manifests and needs node-level control for agents and machine types. Autopilot hides node management, which may not support their node agents. Cloud Run and Cloud Functions do not expose Kubernetes primitives or node-level control.

Key Terms and Concepts Review

Use these flashcards to reinforce the core ideas before moving on.

Compute choices for a given workload
The four core options are: Compute Engine, Google Kubernetes Engine, Cloud Run, Cloud Functions.
Compute Engine (when to use)
Best when you need full OS control, custom drivers or agents, lift-and-shift of legacy apps, or long-running stateful workloads that expect a traditional server.
Google Kubernetes Engine (GKE) core idea
Managed Kubernetes service where Google runs the control plane and you run containers as Kubernetes workloads, ideal for microservices and teams using Kubernetes.
GKE Standard vs Autopilot
Standard: you manage nodes and pay for VMs. Autopilot: Google manages nodes, you define pod resources and pay per pod request, reducing operational overhead.
Cloud Run (when to use)
For stateless, containerized HTTP services or event-driven workloads where you want serverless autoscaling, minimal ops, and pay-per-use pricing, including scaling to zero.
Cloud Functions (when to use)
For small, event-driven pieces of logic triggered by events (Cloud Storage, Pub/Sub, HTTP) where you do not want to manage infrastructure or containers.
Operational responsibility order (most to least you manage)
Compute Engine → GKE Standard → GKE Autopilot / Cloud Run → Cloud Functions.
Google Cloud pricing calculator (definition)
The Google Cloud pricing calculator is a tool that lets you add and configure products to get a cost estimate to share with your team.
Identity and Access Management (IAM) (definition)
Identity and Access Management (IAM) lets you manage access control by defining who (identity) has what access (role) for which resource.
service account (definition)
A service account is a special kind of account used by an application or compute workload, not a person, to make authorized API calls and access Google Cloud resources.

Key Terms

Cloud Run
A fully managed serverless platform for running stateless containers that automatically scales based on HTTP requests or events and can scale to zero.
Serverless
A cloud execution model where the provider manages infrastructure and scaling, and you are billed based on actual usage rather than provisioned capacity.
Compute Engine
Google Cloud's IaaS virtual machine service that provides configurable VMs where you manage the OS, patches, and most system administration.
Cloud Functions
A serverless functions service where you deploy small pieces of code that run in response to events or HTTP requests without managing servers or containers.
Autopilot mode (GKE)
A GKE configuration where Google fully manages nodes and you pay based on pod resource requests, focusing on workloads instead of cluster infrastructure.
Private cluster (GKE)
A GKE cluster where nodes do not have public IP addresses and are accessed via private networking, improving security.
Regional cluster (GKE)
A GKE cluster whose control plane and nodes are distributed across multiple zones in a region to improve availability.
Event-driven architecture
A design pattern where components communicate by producing and consuming events, triggering functions or services in response to those events.
Managed instance group (MIG)
A set of identical Compute Engine VMs managed as a single entity, supporting autoscaling, autohealing, and rolling updates.
Google Kubernetes Engine (GKE)
A managed Kubernetes service on Google Cloud where Google runs the control plane and you run containerized workloads using Kubernetes APIs.

Finished reading?

Test your understanding with a custom practice exam on this chapter.

Test yourself