Google Cloud Platform (GCP) Cloud Functions Service Overview
Google Cloud Platform (GCP)
A serverless, stateless, execution environment for application code - running Functions as a Service (FaaS)
Run code that responds to Cloud Events, only pay while the service runs, automatically scale
Features
Triggered by a class of events
HTTP (web) Event
Cloud Storage Events
Requirements
Bucket must be in the same project as the Cloud Function
Cloud Pub/Sub Events
Cloud Scheduler - to trigger periodic events
Stackdriver integraiton for monitoring
Supported languages
Python
Requirements
'main.py' file contains definitions for 1 or more Cloud Functions
'requirements.txt' file is used by pip to load dependencies into the runtime. Non-pip dependencies also can be packaged/supplied
GCP Cloud Functions doco - Python
Node.js
Go
Deployment
Through the Console, gcloud CLI, or from local computer
Specify the trigger at deployment time
Notification retries
If app is unreachable for 20 seconds, notification is retired
If app is reachable but doesn't ACK, exponential backoff 30 seconds after failure; up to 90 minutes for up to 7 days
Concepts
Event triggers - are sent to the Cloud Function as a notification
Tips
Often used by Data Engineers for ETL when a trigger happens due to data being uploaded to a Cloud Storage bucket or a Pub/Sub message published
Consider codeless options like Cloud Dataproc Workflow Templates and Cloud Composer to manage workflows instead of Cloud Functions