Skip to content

Chapter 2 of 11

Compute: Compute Engine and Cloud Run Functions

Choose configurable virtual machines or event-driven functions based on workload needs.

42 minutes 10 quick checksBy Subha Prasad
Lesson 2 of 11Course navigation

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.

Which statement correctly describes Compute Engine?
Which term matches this explanation: Google Cloud's infrastructure service for configurable virtual machines.
Which statement correctly describes machine type?
Which term matches this explanation: A VM definition describing vCPU and memory capacity.
Which statement correctly describes managed instance group?
Which term matches this explanation: A group of template-based VMs supporting autoscaling, repair, and rollout.
Which statement correctly describes Cloud Run functions?
Which term matches this explanation: Google's event-driven functions offering, formerly called Cloud Functions.
Which statement correctly describes service account?
Which term matches this explanation: A workload identity used by applications and compute resources.

0 of 10 checks passed

Your progress is saved on this device.