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.
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.
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.
Mental model
A busy catering kitchen
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.
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.
Key commands
gcloud run deploy my-service --image=gcr.io/my-project/my-image --region=us-central1 --allow-unauthenticatedDeploy a container as a serverless service.
gcloud run services listList the Cloud Run services in the project.
gcloud functions deploy my-function --runtime=nodejs20 --trigger-http --allow-unauthenticatedDeploy an HTTP-triggered Cloud Function.
gcloud functions listList 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/tickCreate a daily cron job that calls the service.
gcloud scheduler jobs listList all scheduled jobs.
Examples
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-unauthenticatedDeploying 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.appHello 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.
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.
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.
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.
Common issues
503 Service Unavailable on Cloud RunThe container failed to start or keeps crashing, so no instance is ready to serve.
Read the revision's startup logs with gcloud logging read "resource.type=cloud_run_revision" and fix the container.
Function cold-start timeoutThe function takes too long to initialize dependencies at first invocation.
Reduce dependencies, warm-start the runtime, or increase the function timeout and memory.
Cloud Scheduler job returns PERMISSION_DENIEDThe job's service account lacks permission to invoke the target endpoint.
Grant roles/run.invoker (or the target's invoker role) to the scheduler job's service account.
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.
Interview checkpoint
Hands-on lab
- 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
Quick quiz
Which GCP service runs a container image serverlessly and scales to zero?
Cloud Scheduler is GCP's managed cron service that fires HTTP requests on a schedule.
A teammate's Cloud Run service returns 503 right after deploy. What should you check first?
Cheat sheet
Cloud RunContainers, HTTPS, scale to zeroCloud FunctionsEvent-driven single-purpose codeApp EngineFully managed application platformCloud SchedulerManaged cron for HTTP and Pub/Subgcloud run deployDeploy a container servicegcloud functions deployDeploy a functiongcloud run services describeShow revisions and trafficgcloud scheduler jobs create httpSchedule an HTTP job