Lesson content
Read, practise, then check your understanding
Compute: Compute Engine and Cloud Run Functions
Compute Engine provides configurable virtual machines, images, machine families, disks, accelerators, and networking. Cloud Run functions is the current name for Google's event-driven functions offering formerly known as Cloud Functions; it runs code from HTTP or event triggers without server management.
Core ideas
- An instance template captures VM configuration for repeatable managed instance groups.
- Managed instance groups support autoscaling, autohealing, and rolling replacement.
- A service account gives a VM or function a workload identity; attached permissions should be narrow.
- Cloud Run functions scales managed instances in response to requests or events and can scale toward zero.
Design and operating model
Use Compute Engine for custom operating systems, long-running processes, specialist machine types, or software needing host-level control. Use functions for focused event handlers, lightweight APIs, and integrations. Keep both replaceable, use immutable artifacts, restrict identity, define limits, and export telemetry.
Example
gcloud compute instances create training-vm \
--zone=asia-south1-a \
--machine-type=e2-small \
--service-account=training-runtime@PROJECT_ID.iam.gserviceaccount.com \
--scopes=cloud-platform
gcloud run functions describe image-resizer \
--region=asia-south1
Run examples in a disposable training project. Replace project IDs, Regions, identities, resource names, sizes, and policies with reviewed values, and verify current Google Cloud CLI and service requirements before production use.
Production guidance
- Patch or replace VM images automatically and avoid external IPs when private access is sufficient.
- For functions, configure timeout, memory, maximum instances, retries, and dead-letter handling.
- Measure cold starts, sustained utilization, operational effort, and downstream limits before choosing.
The chapter quiz follows the lesson and checks both service vocabulary and architecture decisions.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.