Tech Interview RoomStudy guides

GCP

How do you choose between Compute Engine, GKE, Cloud Run, App Engine and Cloud Run functions?

Intermediate · 2 min read · Lesson 1 of 6 in GCP

  • Compute Engine: VMs (managed instance groups for autoscaling and autohealing). Full control; you operate the OS. For legacy, licensed or specialised workloads.
  • GKE: managed Kubernetes. Autopilot mode manages nodes for you and bills per pod resources; Standard gives full node control (custom machine types, GPUs, DaemonSets, node tuning). For platforms standardised on Kubernetes or complex microservice estates.
  • Cloud Run: serverless containers. Any language or framework in a container, HTTP or event-driven (Eventarc, Pub/Sub push), scales to zero and out to thousands of instances, per-request or instance-based billing. Concurrency up to 1,000 requests per instance (default 80), unlike Lambda's one request per environment. Cloud Run jobs for batch. Often the best default for stateless Spring Boot services on GCP.
  • App Engine: older PaaS (standard and flexible environments); Cloud Run is usually preferred for new workloads.
  • Cloud Run functions (formerly Cloud Functions): single-purpose functions triggered by events; good for glue code.

Decision factors

Operational overhead you want to own, need for Kubernetes features (operators, mesh, stateful sets), traffic pattern (scale to zero), long-running or background processing, and startup latency.

Follow-up questions interviewers ask

Try answering each one before you open it.

How do you tune Spring Boot on Cloud Run?

Set min instances above zero for latency-sensitive services to avoid cold starts; enable startup CPU boost; choose concurrency to match the application's capacity (with virtual threads, high concurrency works well); use CPU "always allocated" (instance-based billing) if you run background work, Kafka consumers or scheduled tasks after the response; reduce startup with CDS, lazy initialisation or a native image; and size memory with MaxRAMPercentage. Use Cloud SQL connectors or a connection pool sized per instance multiplied by max instances to stay within database limits.

Cloud Run or GKE for a set of 20 microservices?

Cloud Run if services are stateless HTTP or event consumers and the team wants minimal operations: no cluster upgrades or node management, per-service scaling, built-in revisions and traffic splitting. GKE if you need Kubernetes-specific capabilities (stateful workloads, custom operators, service mesh with fine control, DaemonSets, GPUs), very steady high utilisation where node-level bin packing is cheaper, or portability with an existing Kubernetes platform.