Lesson content
Read, practise, then check your understanding
Serverless: Cloud Run Functions and App Engine
Cloud Run functions runs event-driven code and is the current evolution of Cloud Functions. Cloud Run services run stateless containers behind managed HTTPS endpoints. App Engine remains a managed application platform with standard and flexible environments.
Core ideas
- Cloud Run functions can respond to HTTP or events and is integrated with the Cloud Run execution model.
- Eventarc routes supported cloud events to destinations such as functions and Cloud Run services.
- App Engine standard emphasizes sandboxed managed runtimes; flexible uses containers on managed Compute Engine infrastructure.
- Serverless scaling can reach downstream limits unless maximum instances and concurrency are controlled.
Design and operating model
Choose functions for small event handlers, Cloud Run services for containerized HTTP applications, and App Engine when its platform model fits an existing application. Keep handlers idempotent, use service accounts, validate events, configure retries and dead-letter paths, and trace execution across services.
Example
import functions_framework
@functions_framework.http
def hello(request):
payload = request.get_json(silent=True) or {}
name = payload.get("name", "learner")
return {"message": f"Hello, {name}"}, 200
Run examples in a disposable training project. Replace project IDs, Regions, identities, resource names, sizes, and policies with reviewed values, and verify current Google Cloud CLI and service requirements before production use.
Production guidance
- Do not place credentials in environment variables when Secret Manager references or identity can be used.
- Set CPU, memory, timeout, concurrency, min/max instances, ingress, and authentication deliberately.
- Load-test cold-start and burst behavior and make downstream calls bounded, retried, and observable.
The chapter quiz follows the lesson and checks both service vocabulary and architecture decisions.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.