Serverless Solutions:
Language Support | Triggers | Startup Latency | Cost | |
Cloud Function | node.js, python, Go, java | http, Pub/Sub, Cloud Storage, Cloud Firestore, Firebase | High, Cold Start | Number of invocations plus tiered usage |
App Engine Standard | node.js, python, Go, java, Ruby, PHP | http using service name, pub/sub | Seconds | Tiered usage pricing based on instance size |
App Engine Flex | node.js, python, Go, java, Ruby, PHP, .NET, Custom | n/a – containerized app, limited by the code. | Minutes | Compute Engine based pricing |
Cloud Run | Any | n/a – containerized app, limited by the code. | Minutes | For Native based on usage |
Note: In all cases (except App Engine Flex which runs on Compute Engine), for the services to be able to connect to internal resources using private IP address, Serverless VPC Access must be enabled.
Cloud Functions Best Practices and Notes
- Design for Indempotency – same result every time
- Do not call background processes
- Due to Cold Start limit libraries to only those necessary
- Use Global Variables
- Load Global Variables as needed
App Engine Standard Best Practices and Notes
- Runs in a Sandbox on shared infrastructure
- Rapid scaling from 0 (when no traffic)
- App engine specific pricing
App Engine Flex Best Practices and Notes
- Runs in a Docker Container on dedicated Compute Engine instances
- Consistent traffic with gradual scaling
- Cannot scale to 0
- Compute engine pricing
Cloud Run
- Cloud Run native seems to be the replacement for App Engine Flex
- Cloud Run can also run as Cloud Run for Anthos leveraging Knative to provide a serverless environment
- Can scale to 0 or can be kept at a minimum for faster responses
- Supports concurrent requests to a given revision if the application supports concurrency
Use Cases for Serverless Solutions
Solution | Applicable Use Cases |
App Engine | Modern Web Applications – Serving basic web content (static and dynamic) to users Salable Mobile Backends – The backend infrastructure to support mobile applications (gaming, etc.) |
Cloud Functions | – Trigger Based Notifications – send emails, etc. due based on changes, workflow events. – Real Time File Processing – Perform actions based on changes in data to new or existing files, generate thumbnailes, validation, aggregate, enhance, transcode, etc. – Realtime Stream Processing – Enrich, process, transform streaming data from pub/sub from IoT sensors, activity tracking, etc. |
Cloud Run | Containerized native applications with benefits of serverless architecture REST API Backend Lightweight Data Transformation |