Google Cloud

Cloud Functions 2nd gen Complete Guide: 1st gen Differences, Pricing & Lambda Comparison

2026-05-24
NicheeLab Editorial Team

Cloud Functions 2nd gen is GCP's evolved serverless function service, internally built on Cloud Run + Eventarc. With 60-minute execution, Cloud Run-grade infrastructure, and 90+ event sources, it's now ready for enterprise-class serverless workloads.

1st gen vs 2nd gen Comparison

Item1st gen2nd gen
FoundationProprietary runtimeCloud Run + Eventarc
Max execution time9 min60 min
Concurrency1 request / instance1-1000 (configurable)
Max memory8 GB16 GB
Max vCPU24
Event sourcesLimited90+ (via Eventarc)
HTTP/2 supportNoYes
VPC connectivityVPC connector requiredDirect VPC Egress supported
Recommended for newYes

Trigger Types

  • HTTPS: Direct HTTP requests
  • Pub/Sub: Auto-triggered from a Topic
  • Cloud Storage: Object create / delete / update
  • Cloud Scheduler: Cron-style scheduled execution
  • Firestore: Document changes
  • Cloud Audit Logs: Triggered by API operations
  • BigQuery: Query completion and other events
  • Firebase: Auth / RTDB changes

Pricing (2nd gen = same as Cloud Run)

ItemPrice (us-central1)
vCPU-time$0.00002400 / vCPU-second
Memory-time$0.00000250 / GiB-second
Requests$0.40 / million
Free tier2M requests, 400,000 GB-seconds, 200,000 vCPU-seconds per month

Sample Code (Python)

import functions_framework

@functions_framework.http
def hello_http(request):
    name = request.args.get('name', 'World')
    return f'Hello {name}!'

@functions_framework.cloud_event
def hello_pubsub(cloud_event):
    import base64
    data = base64.b64decode(cloud_event.data['message']['data']).decode()
    print(f'Received: {data}')
# デプロイ
gcloud functions deploy hello-http \
  --gen2 --runtime=python311 --region=asia-northeast1 \
  --source=. --entry-point=hello_http \
  --trigger-http --allow-unauthenticated

Comparison with AWS Lambda / Azure Functions

Item2nd genAWS LambdaAzure Functions
Max execution time60 min (HTTP) / 60 min (Event)15 min10 min (60 min on Premium)
Max memory16 GB10 GB14 GB (Premium)
ConcurrencyConcurrency 1-10001 request / worker1〜200
LanguagesNode/Python/Go/Java/.NET/Ruby/PHPManyMany
Free tier / month2M requests1M requests1M requests

Typical Use Cases

  • Webhook receivers (Slack / GitHub / Stripe)
  • GCS upload → image resize / OCR
  • Pub/Sub → BigQuery writes (lightweight ETL)
  • Firestore changes → push notifications
  • Cloud Scheduler → periodic API calls
  • IAM Audit Log → security alerts

Best Practices

  • Dedicated Service Account with least privilege
  • Tune Concurrency to optimize parallelism
  • Use Min Instances 1+ to avoid cold starts (critical APIs only)
  • Use VPC Egress for secure access to internal resources
  • Manage secrets with Secret Manager
  • Optimize performance with Cloud Trace / Profiler
  • Use a Dead Letter Topic to handle failed messages (Pub/Sub triggers)

What's the difference between Cloud Functions 1st gen and 2nd gen?

2nd gen runs on Cloud Run + Eventarc under the hood. It supports 60-minute execution, concurrency up to 1000, up to 16 GB memory, and 90+ event sources via Eventarc. 2nd gen is recommended for all new workloads.

Should I use Cloud Run or Cloud Functions 2nd gen?

Use 2nd gen for simple function-per-endpoint workloads; use Cloud Run for full web APIs, complex routing, or full container control. Both run on the same underlying infrastructure.

Which languages are supported?

Node.js, Python, Go, Java, .NET, Ruby, and PHP. You can also run custom containers via Buildpacks.

How bad are cold starts?

With Min Instances 0, expect 100ms to a few seconds. Setting Min Instances 1+ keeps instances warm (at a cost). Java and Python tend to be slower; Go and Node.js start faster.

How is pricing structured?

You pay for requests + CPU-seconds + memory-seconds. The free tier covers 2M requests, 400,000 GB-seconds, and 200,000 vCPU-seconds per month. Same billing model as Cloud Run.

What is Eventarc?

GCP's standard eventing backbone. It delivers events from 90+ sources (Cloud Storage, Audit Logs, Pub/Sub, etc.) to Cloud Functions, Cloud Run, and Workflows.

How does it compare to AWS Lambda?

Lambda caps at ~15 minutes; 2nd gen goes to 60 minutes. Lambda scales higher on concurrency (1000 default, up to 100K). Eventarc is roughly equivalent to EventBridge.

How should I configure the Service Account?

Create a dedicated SA per function with least-privilege predefined roles. Avoid using the default App Engine SA in production.

Related articles: Serverless

GCP Professional Cloud Developer (PCD) 完全ガイド|Cloud Run・GKE・CI/CD・APM

Google Cloud Professional Cloud Developer の試験範囲、Cloud Run / GKE / Cloud Build / Cloud Trace、AWS DVA / Azure AZ-204 比較、学習ロードマップを徹底解説。

App Engine 完全ガイド|Standard vs Flexible・料金・Cloud Run 比較 (GCP)

Google App Engine の Standard と Flexible の違い、料金、Traffic Splitting、Cron、Cloud Run / Cloud Functions との使い分け、AWS Elastic Beanstalk / Azure App Service 比較を徹底解説。

Cloud Deploy 完全ガイド|Canary・Blue-Green・GKE/Cloud Run プログレッシブデプロイ (GCP)

Google Cloud Cloud Deploy の全機能解説。Delivery Pipeline、Canary / Blue-Green、Approval Gate、Verify、Skaffold 統合、GKE / Cloud Run / Anthos 対応、AWS CodeDeploy / ArgoCD 比較を網羅。

Workflows / Cloud Tasks 完全ガイド|サーバレスオーケストレーション (GCP)

Google Cloud Workflows と Cloud Tasks の全機能解説。YAML ベース DAG、サーバレス、Eventarc 統合、Cloud Composer / Pub/Sub との使い分け、AWS Step Functions / Azure Logic Apps 比較を網羅。

Google Cloud is a trademark of Google LLC. For the latest information, see the official Cloud Functions documentation.

Check what you learned with practice questions

Practice with certification-focused question sets

See GCP exam prep
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Google Cloud

Google Cloud Certification Roadmap (2026)

Choose your GCP certification path — Foundational, Associate...

Google Cloud

CDL Cloud Digital Leader: Complete Exam Guide (2026)

Pass the Cloud Digital Leader exam — cloud business value, G...

Google Cloud

GAIL Generative AI Leader: Complete Exam Guide (2026)

Pass the Generative AI Leader exam — Gemini, Vertex AI, Work...

Google Cloud

Vertex AI Fundamentals for GCP Certs (2026)

Vertex AI basics every cert candidate needs — Workbench, Pip...

Google Cloud

Associate Cloud Engineer (ACE): Complete Guide (2026)

Pass the Associate Cloud Engineer exam — Console, gcloud, pr...

Browse all Google Cloud articles (103)
© 2026 NicheeLab All rights reserved.