Google App Engine

What is a compute engine in GCP?

Compute Engine is Google Cloud's IaaS service for virtual machines. Learn what you manage, how it's billed, and how it differs from App Engine.

On this page
  1. What you manage and what Google manages
  2. Machine families
  3. Storage, networking, and images
  4. Reliability and scaling
  5. How to create an instance
  6. How Compute Engine is billed
  7. Compute Engine, App Engine, and Cloud Run compared
  8. Common misconceptions
  9. Safety note
  10. Next steps

Compute Engine is Google Cloud’s infrastructure as a service (IaaS) offering for virtual machines (VMs). You choose the machine size, operating system, disks, and network, and Google runs the VM on its data center hardware. You are responsible for the operating system, its patches, and the software on it. AWS’s equivalent is EC2, and Azure’s is Virtual Machines.

What you manage and what Google manages

Cloud services are often grouped by how much of the stack the provider runs:

  • IaaS (Compute Engine): Google runs the physical hardware and the virtualization. You manage the operating system, updates, runtimes, and applications.
  • PaaS (App Engine, and Cloud Run for containers): Google also manages the operating system and much of the scaling. You deploy code or a container.

Compute Engine is not a PaaS. That difference is the main reason to choose it. You get full control over the machine, including custom software, root access, and specific kernel or driver needs. The cost is the operational work that a PaaS would do for you.

Typical uses include web servers and backends, databases, batch processing, machine learning and high-performance computing on GPUs, and moving existing on-premises servers to the cloud.

Machine families

Compute Engine offers machine families for different workloads:

  • General-purpose families (such as E2, N2, N4, C3, and C4) balance CPU and memory for most web and application workloads.
  • Compute-optimized families (such as C2 and H3) favor CPU performance.
  • Memory-optimized families (such as M1 to M3) suit large in-memory workloads, such as big databases.
  • Accelerator-optimized families (such as A2, A3, and G2) include GPUs for machine learning and graphics.

On supported families, you can use custom machine types and pick the number of vCPUs and the amount of memory separately.

Storage, networking, and images

Compute Engine attaches several storage types. Persistent Disk is network-attached block storage with standard, balanced, SSD, and extreme options. Hyperdisk is a newer high-performance option. Local SSD is fast but temporary, so its data is lost when the VM stops.

Each VM connects to a Virtual Private Cloud (VPC) network, with firewall rules and optional static external IP addresses. You can start a VM from a public image, such as Debian, Ubuntu, RHEL, or Windows Server, or from a custom image. Windows and RHEL images carry license fees.

Reliability and scaling

A VM lives in one zone, so a single zone failure can take it down. For higher availability, run VMs in more than one zone. Live migration moves a running VM to different hardware during host maintenance, though not every VM type supports it. Managed instance groups add autoscaling, autohealing, and rolling updates across identical VMs.

Spot VMs cost much less than on-demand VMs, but Google can stop them at any time. They suit fault-tolerant batch work, not stateful workloads that cannot be interrupted.

How to create an instance

You can create a VM in the Google Cloud console, with the gcloud command line, with Terraform, or through the API. A minimal command looks like this:

gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-micro

Add --image-family and --image-project to choose a specific operating system image.

How Compute Engine is billed

Compute Engine bills each VM per second, with a one-minute minimum. A few points matter in practice:

  • Always Free: one e2-micro per month in us-west1, us-central1, or us-east1, plus 30 GB of standard persistent disk. The free e2-micro is not free in every region.
  • Discounts: sustained-use discounts apply automatically to some machine types, committed-use discounts require a one- or three-year commitment, and Spot VMs cost much less but can be stopped.
  • Stopped VMs still cost money for their disks, snapshots, and static IP addresses. Deleting a VM does not delete snapshots, reserved static IP addresses, or any disks that don’t have auto-delete enabled.

The pricing guide compares these billing models with App Engine and AWS.

Compute Engine, App Engine, and Cloud Run compared

Compute Engine App Engine Cloud Run
Model IaaS: virtual machines PaaS: code on managed runtimes or containers Serverless containers
You manage OS, patches, runtime, scaling setup Your code and app.yaml Your container image
Scales to zero No Standard: yes. Flexible: no Yes
Typical fit Full control, custom software, steady workloads Web apps on supported runtimes New container-based serverless apps

For a comparison of App Engine’s two environments, read the Standard vs Flexible guide. For the serverless options, read App Engine vs Cloud Run.

Common misconceptions

  • “Compute Engine is a PaaS.” It is IaaS. App Engine and Cloud Run are the managed options.
  • “Stopping a VM stops all charges.” Disks and static IP addresses keep billing.
  • “Spot VMs suit any workload.” They can be stopped at any time, so they do not suit stateful, uninterruptible work.
  • “The e2-micro is always free.” The Always Free allowance applies only in the three listed US regions.

Safety note

Restrict SSH and RDP firewall rules. Do not open port 22 to 0.0.0.0/0 in production. Consider Identity-Aware Proxy for SSH access so you don’t expose the port to the internet.

Next steps

For a first hands-on project, the App Engine tutorial shows a managed alternative to running a VM yourself. The architecture guide explains what App Engine manages on your behalf.

The complete guide to google app engine

Google App Engine Tutorial for Beginners
Read the guide

Keep exploring

Guides from other topics

All topics →