Cloud Functions 2nd gen は GCP のサーバレス関数サービスで、内部的に Cloud Run + Eventarc を使った進化版です。 実行時間 60 分、Cloud Run と同等のインフラ、90+ イベントソース対応により、エンタープライズ用途のサーバレスに耐えうる仕様になりました。
| 項目 | 1st gen | 2nd gen |
|---|---|---|
| ベース | 独自実行環境 | Cloud Run + Eventarc |
| 最大実行時間 | 9 分 | 60 分 |
| 同時実行 | 1 リクエスト/インスタンス | 1〜1000 (concurrency 設定可) |
| 最大メモリ | 8 GB | 16 GB |
| 最大 vCPU | 2 | 4 |
| イベントソース | 限定 | 90+ (Eventarc) |
| HTTP/2 サポート | 不可 | 可 |
| VPC コネクタ | 必要 | Direct VPC Egress 対応 |
| 新規推奨 | — | ◎ |
| 項目 | 料金 (us-central1) |
|---|---|
| vCPU 時間 | $0.00002400 / vCPU 秒 |
| メモリ時間 | $0.00000250 / GiB 秒 |
| リクエスト数 | $0.40 / 100 万 |
| 無料枠 | 月 200 万リクエスト、400,000 GB 秒、200,000 vCPU 秒 |
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
| 項目 | 2nd gen | AWS Lambda | Azure Functions |
|---|---|---|---|
| 最大実行時間 | 60 分 (HTTP) / 60 分 (Event) | 15 分 | 10 分 (Premium 60 分) |
| 最大メモリ | 16 GB | 10 GB | 14 GB (Premium) |
| 同時実行 | Concurrency 1〜1000 | 1 リクエスト/Worker | 1〜200 |
| 言語 | Node/Python/Go/Java/.NET/Ruby/PHP | 多数 | 多数 |
| 無料枠/月 | 200 万req | 100 万 req | 100 万 req |
Cloud Functions 1st gen と 2nd gen の違いは?
2nd gen は内部的に Cloud Run + Eventarc ベース。実行時間 60 分対応、同時実行 1000、最大 16 GB メモリ、Eventarc 統合で 90+ イベントソース対応。新規は 2nd gen 推奨。
Cloud Run と 2nd gen どちらを使う?
Function 単位なら 2nd gen (シンプル)、Web API / 複雑なルーティング / Container 制御なら Cloud Run。両方とも同じインフラ上で動作。
対応言語は?
Node.js、Python、Go、Java、.NET、Ruby、PHP。Buildpacks 経由でカスタム Container も可。
コールドスタートはどのくらい?
Min Instances 0 で 100ms〜数秒。Min Instances 1+ で常時起動 (コスト発生)。Java/Python は遅め、Go/Node が速い傾向。
料金体系は?
リクエスト数 + CPU 時間 + メモリ時間。月 200 万リクエスト + 400,000 GB 秒 + 200,000 vCPU 秒の無料枠。Cloud Run と同じ課金体系。
Eventarc とは?
GCP の標準イベント基盤。Cloud Storage / Audit Logs / Pub/Sub など 90+ ソースから Cloud Functions / Run / Workflows へイベント配信。
AWS Lambda との比較は?
Lambda は ~15 分実行制限、2nd gen は 60 分。同時実行は Lambda の方がスケール上限高い (1000 既定 → 10万まで)。Eventarc は EventBridge 相当。
Service Account はどう設定する?
Function 専用 SA を作成、Predefined Role で最小権限。デフォルト SA (App Engine default) は使用禁止が推奨。
関連記事・サーバレス
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 は Google LLC の商標です。最新情報は Cloud Functions 公式 をご確認ください。
NicheeLab編集部
データエンジニアリング・クラウド資格の専門家。Databricks・Snowflake等の認定資格を保有し、実務経験に基づいた問題作成・解説を行っています。NicheeLab運営。
Google Cloud (GCP) 認定資格ロードマップ 2026 完全版|全 15 試験を体系化
Google Cloud 認定資格 全 15 試験 (Foundational 2 + Associate 3 + Pr...
Cloud Digital Leader (CDL) 完全ガイド|出題範囲・学習リソース・合格戦略
Google Cloud Cloud Digital Leader (CDL) の完全ガイド。6 ドメイン 92 bul...
Generative AI Leader (GAIL) 完全ガイド|Google Cloud 生成 AI 認定
Google Cloud Generative AI Leader (GAIL、2025-05-14 リリース) の完全...
Vertex AI 入門|Google Cloud 統合 ML プラットフォームの全機能
Google Cloud Vertex AI の入門解説。Vertex AI Studio / Agent Builde...
GCP Associate Cloud Engineer (ACE) 完全ガイド|試験範囲・受験料・学習ロードマップ
Google Cloud Associate Cloud Engineer (ACE) の試験範囲・受験料 125 US...