Skip to main content
Welcome back. This lesson summarizes the key concepts from the Compute section you need for practical use and certification. Read the short explanations below for each primary resource and use the quick commands and tables to reference typical operations.
  • Compute Engine (VMs)
  • Persistent Disk
  • VPC Firewall Rules
  • Other compute options (Cloud Run, Cloud Functions, GKE)

Compute Engine (VM)

Compute Engine provides virtual machines (VMs) for running applications and services that require full OS control. Use Compute Engine for long-running servers, lift-and-shift migrations, custom OS requirements, and workloads needing specialized hardware (CPUs, large memory, GPUs). Key points:
  • Machine types: pick the right family for your workload — general-purpose, memory-optimized, compute-optimized, and GPU-optimized are common choices.
  • Operating systems: use public OS images, marketplace images, or import/create custom images.
  • Billing: Compute Engine charges per second, which reduces costs for short-lived instances.
  • Use cases: persistent services, stateful applications, and workloads requiring direct VM access.
Machine type examples:

Persistent Disk

Persistent disks provide durable block storage for Compute Engine instances. They persist independently of the VM lifecycle and can be used as boot disks or additional data disks. Key points:
  • Disk roles: boot disks and additional data disks.
  • Disk types: choose standard HDD, SSD, or balanced options based on performance and cost.
  • Attach/detach: disks can be moved between instances and remain available after instance deletion.
  • Resize: you can enlarge a disk; after changing the block device size you typically grow the filesystem inside the VM.
  • Snapshots: create point-in-time backups and use snapshots to create new disks.
Disk type comparison:
When you resize a persistent disk, the block device is expanded immediately, but you normally must run a filesystem resize inside the VM (for example, sudo resize2fs /dev/sdX for ext4 or sudo xfs_growfs /mountpoint for XFS) to make the extra space available to the operating system.
Useful gcloud examples:
  • Resize a persistent disk:
  • Create a snapshot:
  • Create a new disk from a snapshot:

VPC Firewall Rules

VPC firewall rules control ingress and egress traffic to and from VM instances in a VPC network. Firewalls operate at the network level and use targets such as instance tags or service accounts. Key points:
  • Scope: rules are defined per VPC network and can Allow or Deny traffic.
  • Targets: choose to target instances via network tags, service accounts, or all instances on the network.
  • Stateful behavior: return traffic for an allowed connection is automatically permitted.
  • Typical ports: open SSH (tcp:22) for management, and application ports such as tcp:80 and tcp:443 as needed.
  • Priority: lower numeric priority values are evaluated first. If multiple rules match, the one with the highest precedence (lowest number) takes effect.
For secure access, restrict SSH to specific source IP ranges or use Identity-Aware Proxy (IAP) to avoid exposing management ports to the public internet whenever possible: https://cloud.google.com/iap
Firewall rule example:

Other Compute Options (brief)

Consider managed or serverless compute platforms when they better match your architecture or operational model. Choose based on trade-offs: operational overhead, scaling model, and stateful vs. stateless requirements.

Practical tips and best practices

  • Right-size VMs: pick machine types and disk sizes that match workload requirements to avoid overprovisioning and excess cost.
  • Use snapshots and automated backups for persistent disks, and test restorations.
  • Restrict management ports (SSH/RDP) to known IPs or use IAP and bastion hosts for improved security.
  • Monitor disk IOPS and latency; choose SSD or balanced disks for I/O-sensitive apps.
  • Prefer managed services (Cloud Run, Functions, or GKE) for faster deployments and reduced operational burden when appropriate.

Useful references

That’s it for this lesson — see you in the next one.

Watch Video