Imagine your e-commerce site processing 10,000 webhooks from a payment gateway daily. A dedicated server sits idle 90% of the time, and peak load during sales hours crushes the infrastructure. Cloud Functions 2nd gen solves this: you pay only for actual invocations, and scaling happens automatically. Functions start within 100 ms and can handle up to 1000 concurrent requests per instance.
We are a team with 5+ years of GCP experience, having delivered 20+ serverless solutions for e-commerce, fintech, and media. We are Google certified, use event-driven architecture, and fully managed services. We guarantee stability under any load.
A typical scenario: an online store on WooCommerce processes webhooks from Stripe. A dedicated server sits idle, while peak rates increase. Cloud Functions starts within 100 ms, processes the request, and releases resources. Infrastructure budget savings reach 70%, and the solution pays for itself within the first few months.
What problems do we solve?
Business faces three typical challenges:
- Auto-scaling. Traditional servers cannot keep up with spikes. Cloud Functions scales from 0 to 1000 instances in seconds. Stripe webhook processing: function starts in 100 ms, executes, and stops.
- Cost. You pay only for execution time and number of invocations. Up to 70% savings compared to a dedicated server running 24/7.
- Integration with the GCP ecosystem. Seamless connection with Pub/Sub, Cloud SQL, Secret Manager, Cloud Build, BigQuery. No need to set up additional infrastructure.
How we do it: a real case
Recently for a fintech startup, we implemented Stripe webhook handling with HMAC signature verification, publishing to Pub/Sub, and writing to BigQuery. The function is written in Python, deployed via Cloud Build, monitored via Cloud Logging. The system handles 5000 requests per minute without a single failure. The entire architecture was done in 5 days. As stated in the official Google Cloud documentation, 2nd gen supports up to 1000 concurrent requests.
Stack: Node.js 20, Python 3.12, Go 1.21, TypeScript, Secret Manager, Cloud SQL, VPC Connector.
1st Gen vs 2nd Gen
2nd gen functions use Cloud Run under the hood. This provides: concurrency up to 1000 requests per instance (vs 1 in 1st gen), support for VPC Connector, larger memory limit (32 GB), custom domains without proxying.
| Characteristic | 1st Gen | 2nd Gen |
|---|---|---|
| Timeout | 9 minutes | 60 minutes |
| Concurrent requests | 1 | up to 1000 |
| Memory | up to 2 GB | up to 32 GB |
| VPC Connector | no | yes |
| Custom domain | via proxy | directly |
Why choose Google Cloud Functions 2nd gen?
First, 2nd gen is 10 times faster than 1st gen in throughput due to multithreading. Second, it supports event-driven architecture: Pub/Sub, Cloud Storage, Firestore, BigQuery. Third, security: all functions run inside a VPC with access to Cloud SQL, Memorystore, and other services via internal IPs.
How to integrate Cloud Functions with Pub/Sub?
Create a subscriber function that triggers when a message is published to a topic. This is an asynchronous model: invocation is decoupled from processing. Python example:
@functions_framework.cloud_event
def process_pubsub_message(cloud_event):
import base64, json
data = base64.b64decode(cloud_event.data["message"]["data"]).decode("utf-8")
event = json.loads(data)
handle_event(event)
Example function: webhook handler in Python
import functions_framework, json, hmac, hashlib
from google.cloud import pubsub_v1
publisher = pubsub_v1.PublisherClient()
TOPIC_PATH = "projects/my-project/topics/webhook-events"
@functions_framework.http
def process_webhook(request):
signature = request.headers.get("X-Signature-256", "")
secret = get_secret("webhook-secret")
expected = "sha256=" + hmac.new(secret.encode(), request.data, hashlib.sha256).hexdigest()
if not hmac.compare_digest(signature, expected):
return json.dumps({"error": "Invalid signature"}), 401
event = request.get_json()
publisher.publish(TOPIC_PATH, json.dumps(event).encode("utf-8"))
return json.dumps({"received": True}), 200
Deploy and environment
# Node.js
gcloud functions deploy contact-form --gen2 --runtime nodejs20 --region europe-west1 --source . --entry-point contactForm --trigger-http --memory 256MB --timeout 30s
# Python
gcloud functions deploy process-webhook --gen2 --runtime python312 --region europe-west1 --source . --entry-point process_webhook --trigger-http --memory 512MB
Connecting to Cloud SQL
import sqlalchemy
def create_engine():
return sqlalchemy.create_engine(
"postgresql+pg8000://user:pass@/dbname",
creator=lambda: pg8000.connect(
user="user", password="pass", database="dbname",
unix_sock="/cloudsql/project:region:instance/.s.PGSQL.5432"
)
)
CI/CD via Cloud Build
# cloudbuild.yaml
steps:
- name: node:20
entrypoint: npm
args: [install]
- name: node:20
entrypoint: npm
args: [run, build]
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
args:
- gcloud
- functions
- deploy
- contact-form
- --gen2
- --region=europe-west1
- --source=.
- --runtime=nodejs20
- --entry-point=contactForm
- --trigger-http
How to secure serverless functions?
Use Secret Manager for keys and passwords, verify incoming webhook signatures (HMAC), configure IAM roles with least privilege, enable VPC Connector for traffic isolation. For DDoS protection, use Cloud Armor. More details in Cloud Functions documentation.
What's included
| Component | Description |
|---|---|
| Architecture diagram | Documented data flow and service diagram |
| Function code | Written in chosen language (Python/Node.js/Go) with error handling and logging |
| CI/CD pipeline | Cloud Build setup for automatic deployment on repository push |
| Documentation | Instructions for local startup, deployment, monitoring |
| Team training | 2-hour session on working with functions and debugging |
| Support | 1 month after delivery — consultations and bug fixes |
Process
- Requirements audit — analyze load, usage scenarios, select triggers (HTTP, Pub/Sub, Cloud Storage).
- Design — develop architecture: functions, topics, queues, databases.
- Development — write code, cover with tests, set up CI/CD.
- Testing — load testing (k6), security check, fault tolerance.
- Deployment — deploy to production, set up monitoring and alerts.
- Documentation and training — transfer knowledge to your team.
Timeline and pricing
- Basic HTTP function (webhook reception, signature verification, response) — from 3 business days.
- Function with Pub/Sub and Cloud SQL — from 1 week.
- Complex solution (multiple functions, CI/CD, BigQuery integration) — up to 3 weeks.
Pricing is determined individually after a consultation. We will assess your project for free and suggest the optimal solution. Average project budget starts from a few hundred thousand rubles.
We guarantee 99.9% uptime and prompt incident resolution. Experience: 5+ years in GCP, certified engineers, real fintech and e-commerce cases.
Contact us — we will help you select the serverless solution for your needs. Get a consultation today.







