Google Cloud Platform
Intermediate 15 min read Google Cloud Platform

Cloud Run, App Engine & Functions

Cloud Run is a managed container platform that scales to zero; Cloud Functions runs single-purpose event-driven code; App Engine is a fully managed application platform; Cloud Scheduler is the managed cron service. Learn the serverless stack and when to reach for each piece.

Cloud Runcontainerrevisiontraffic splitCloud FunctionstriggerApp EngineCloud Schedulerscale to zerocold start
Introduction

What is this?

Cloud Run is a managed container platform: you deploy a container image and Cloud Run runs it serverlessly, scales from zero to thousands of instances, and provides automatic HTTPS, revisions and traffic splitting. Cloud Functions is a lightweight, event-driven compute service for single-purpose functions triggered by HTTP, Pub/Sub or Cloud Storage events. App Engine is a fully managed platform for applications with standard and flexible environments. Cloud Scheduler is a fully managed cron service that fires HTTP requests or Pub/Sub messages on a schedule.

Motivation

Why do you need it?

  • Serverless removes server management — no VMs to patch, no clusters to operate, and billing only for what you use.
  • Cloud Run is the modern default for containers on GCP and scales from zero to thousands of instances.
  • Cloud Functions is the smallest unit of glue logic, triggered by events across the platform.
  • Cloud Scheduler powers cron jobs for periodic pipelines, reports and cleanup tasks.
  • Serverless versus serverful is a core architecture decision and interview topic.
Think about it

Mental model

Imagine

A busy catering kitchen

Think of

Cloud Run, App Engine, Functions and Scheduler

Cloud Run is the professional kitchen that cooks your recipe (container image) in a disposable pan, dishes out plates on demand, and charges per plate served — empty nights cost nothing. App Engine is the full-service restaurant: you give them the menu and they handle the dining room, staff and rent. Cloud Functions is the sous-chef who does one task — chopping — whenever the head chef rings the bell (an event). Cloud Scheduler is the kitchen timer that rings at set times to start the next batch.

Mechanics

How it works

  • Cloud Run takes a container image, runs it on managed infrastructure, exposes an HTTPS endpoint, and scales instances up or down to zero based on requests.
  • Each deploy creates a revision; you can split traffic between revisions for canary rollouts and instant rollbacks.
  • Cloud Functions binds a function to an event source (HTTP, Pub/Sub, Cloud Storage) and runs code only when the event fires.
  • App Engine runs apps in either the standard runtime (autoscaling, sandboxed) or the flexible environment (containers).
  • Cloud Scheduler fires HTTP requests or Pub/Sub messages on a cron schedule like '0 9 * * *'.

Deploying a container and wiring an event-driven pipeline.

Build and push the image
gcloud run deploy
HTTPS endpoint + autoscaling
Traffic split
Cloud Functions trigger
Cloud Scheduler cron
Reference

Key commands

gcloud run deploy my-service --image=gcr.io/my-project/my-image --region=us-central1 --allow-unauthenticated

Deploy a container as a serverless service.

gcloud run services list

List the Cloud Run services in the project.

gcloud functions deploy my-function --runtime=nodejs20 --trigger-http --allow-unauthenticated

Deploy an HTTP-triggered Cloud Function.

gcloud functions list

List the deployed functions and their states.

gcloud scheduler jobs create http my-job --schedule="0 9 * * *" --uri=https://my-service-abcdef-uc.a.run.app/tick

Create a daily cron job that calls the service.

gcloud scheduler jobs list

List all scheduled jobs.

Hands-on

Examples

Deploy a container to Cloud Run and hit the endpoint

Deploy a container to Cloud Run and hit the endpoint
$ gcloud run deploy my-service \
--image gcr.io/my-project/my-image:latest \
--region us-central1 \
--allow-unauthenticated
Deploying container to Cloud Run service [my-service] in project [my-project] region [us-central1]
OK Creating Revision...
OK Routing traffic...
Done.
Service [my-service] revision [my-service-00001-abc] has been deployed.
URL: https://my-service-abcdef-uc.a.run.app
$ curl -s https://my-service-abcdef-uc.a.run.app
Hello from Cloud Run!

gcloud run deploy takes a container image, creates a revision, and routes HTTPS traffic to it. --allow-unauthenticated makes the endpoint public for this example; in production you protect it with IAM or Identity-Aware Proxy. The curl shows the service answering at its managed URL.

Real world

In production

  • Run stateless web APIs and background workers on Cloud Run with per-instance concurrency tuned for your app.
  • Use traffic splitting for canary releases and instant rollbacks between revisions.
  • Build event-driven glue with Cloud Functions listening to Pub/Sub, Cloud Storage and Cloud Scheduler.
  • Use Cloud Scheduler for nightly jobs, database maintenance and report generation.
  • Keep container images small and warm-start friendly so cold starts stay low.
Guidelines

Best practices

  • Design for statelessness — Cloud Run instances can be killed at any time; store state in external services.
  • Set memory and concurrency explicitly rather than accepting defaults that oversize or undersize instances.
  • Use startup probes and health checks so new revisions pass traffic only when ready.
  • Version functions and pin runtime versions for reproducibility.
  • Use min-instances only for latency-sensitive services you must keep warm; it costs money.
Watch out

Common mistakes

  • Writing state to the local filesystem on Cloud Run — it is ephemeral and not shared across instances.
  • Deploying functions with dependencies missing from the runtime and only discovering it at cold start.
  • Forgetting that scale-to-zero means the first request pays a cold-start penalty.
  • Using Cloud Functions for long-running jobs that exceed the function timeout.
  • Pointing Cloud Scheduler at a URL that requires auth and never configuring a service account.
Root cause analysis

Common issues

Error
503 Service Unavailable on Cloud Run
Root cause

The container failed to start or keeps crashing, so no instance is ready to serve.

Fix

Read the revision's startup logs with gcloud logging read "resource.type=cloud_run_revision" and fix the container.

Error
Function cold-start timeout
Root cause

The function takes too long to initialize dependencies at first invocation.

Fix

Reduce dependencies, warm-start the runtime, or increase the function timeout and memory.

Error
Cloud Scheduler job returns PERMISSION_DENIED
Root cause

The job's service account lacks permission to invoke the target endpoint.

Fix

Grant roles/run.invoker (or the target's invoker role) to the scheduler job's service account.

When things break

Debugging tips

  • gcloud run services describe shows the deployed revision and traffic configuration.
  • Read request logs in Cloud Logging — gcloud logging read is faster than scanning the console.
  • Check Cloud Run startup errors with gcloud logging read "resource.type=cloud_run_revision".
  • Test functions locally before deploying; most failures are dependency or permission issues.
  • Verify the scheduler job's target URL responds to a plain curl before blaming the schedule.
Interviews

Interview checkpoint

Practice

Hands-on lab

Run a Local Function and Simulate a Scheduler
20 min · intermediate
In progress
Objectives
  • Write a bash function that processes an event payload
  • Invoke the function the way a trigger would
  • Pipe and transform output like a function pipeline
  • Simulate a scheduled trigger and inspect its log

Run a Local Function and Simulate a Scheduler

20 min · intermediate

0/6 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/3
1

Which GCP service runs a container image serverlessly and scales to zero?

2

Cloud Scheduler is GCP's managed cron service that fires HTTP requests on a schedule.

3

A teammate's Cloud Run service returns 503 right after deploy. What should you check first?

Quick reference

Cheat sheet

Serverless services
Cloud RunContainers, HTTPS, scale to zero
Cloud FunctionsEvent-driven single-purpose code
App EngineFully managed application platform
Cloud SchedulerManaged cron for HTTP and Pub/Sub
Everyday commands
gcloud run deployDeploy a container service
gcloud functions deployDeploy a function
gcloud run services describeShow revisions and traffic
gcloud scheduler jobs create httpSchedule an HTTP job
Go deeper

Official documentation