Google Cloud Functions (GCF) is Function as a Service (FaaS) — a serverless platform that lets you run your code in response to events, without worrying about infrastructure.
It’s fully managed, pay-per-use, and scales automatically based on demand.
🔹 How Does It Work?
You simply write a function, choose a trigger (event), and let Google Cloud handle everything else — provisioning, scaling, and execution.
Example Events:
🌐 HTTPS Trigger → Run code when an HTTPS URL is invoked.
📩 Cloud Pub/Sub → Run code when a message is published to a topic.
📦 Cloud Storage → Run code when a file is uploaded to a bucket.
Cloud Functions - Flow
🔹 Why Use Cloud Functions?
🚀 Serverless – No servers to provision or manage.
📈 Autoscaling – Scales automatically with incoming events.
💡 Multi-language support – Write functions in Python, Node.js, Go, Java, .NET, or Ruby.
🔹 Types of Cloud Functions
1️⃣ HTTPS Functions
- Triggered via HTTPS endpoints.
- Support HTTP methods: GET, POST, PUT, DELETE, and OPTIONS.
- Ideal for APIs, webhooks, and form submissions.
2️⃣ Event-Driven Functions
- Triggered by events from other Google Cloud services.
- Examples: Cloud Storage (file upload), Pub/Sub (messages), Firestore (DB changes).
- Integrated with 125+ event sources via Eventarc.
🔹 Common Use Cases
✅ Build REST APIs quickly
✅ Automate workflows (e.g., image processing on file upload)
✅ Process data streams from Pub/Sub
✅ Run scheduled jobs with Cloud Scheduler
Cloud Function 1st Gen vs 2nd Gen – Key Feature Comparison
Cloud Function Feature | Cloud Function 1st Gen | Cloud Function 2nd Gen |
---|---|---|
Why do we need two versions of Cloud Functions? | First version with limited features | Very advanced – built on top of Cloud Run and Eventarc |
Timeout | Default: 1 minute HTTP Functions: 9 minutes Event-driven Functions: 9 minutes |
Default: 1 minute HTTP Functions: 60 minutes Event-driven Functions: 10 minutes ✅ Longer processing times |
Compute Power (Memory & CPU) | Max Memory: 8GB Max CPU: 4 vCPU CPU is auto-allocated (❌ no option to choose) |
Max Memory: 32GB Max CPU: 8 vCPU ✅ Option available to select CPU |
Concurrency | ❌ No concurrency option Example: 10 Requests → 10 Container Instances created |
✅ Concurrency supported Example: Concurrency: 10, Requests: 10 → 1 Container Instance created ⚠️ Limitation: Not supported for all runtimes |
Traffic Splitting | ❌ Not possible | ✅ Possible (Built on Cloud Run) Gradual rollout supported (e.g., V1: 90%, V2: 10%) Can be applied via gcloud run or Cloud Run web console |
Cloud Function Feature | Cloud Function 1st Gen | Cloud Function 2nd Gen |
Number of Event Triggers | Limited 1. HTTP 2. Cloud Storage 3. Cloud Pub/Sub 4. Cloud Firestore 5. Few Firebase triggers |
125+ Triggers supported 1. HTTPS 2. Eventarc (many Google Cloud sources) 3. Third-Party Events |
Top comments (0)