google_ cloudfunctions2_ function cost estimation
A serverless function (2nd gen, Cloud Run-based). Billed per invocation, vCPU-time, memory-time, and outbound networking.
A google_
Pricing components:
Invocations: $0.40 per million invocations. First 2 million per month are free at the project level.
vCPU-time: billed per vCPU-second during request handling, rounded to 100ms. Rate scales with vCPU allocation (the function's CPU setting). Free tier: 360,000 vCPU-seconds/month.
Memory-time: billed per GB-second during request handling. Free tier: 180,000 GB-seconds/month.
Networking egress: standard GCP egress rates apply for bytes returned to clients.
Always-allocated CPU (available_
1st generation Cloud Functions (google_
c3x estimates Cloud Functions from c3x-usage.yml's monthly_
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "google_cloudfunctions2_function" "processor" {
name = "event-processor"
location = "us-central1"
build_config {
runtime = "python311"
entry_point = "process_event"
source {
storage_source {
bucket = google_storage_bucket.source.name
object = google_storage_bucket_object.source.name
}
}
}
service_config {
max_instance_count = 100
min_instance_count = 0
available_memory = "512M"
available_cpu = "1"
timeout_seconds = 60
max_instance_request_concurrency = 80
ingress_settings = "ALLOW_INTERNAL_ONLY"
}
}Pricing dimensions
What you actually pay for when you provision google_.
| Dimension | Unit | What's being charged |
|---|---|---|
| Invocations | per 1M invocations | Each function call. First 2M/month free at project level. $0.40/1M invocations |
| vCPU time | per vCPU-second | Billed during request handling, rounded to nearest 100ms. First 360,000 vCPU-seconds/month free. $0.000024/vCPU-second |
| Memory time | per GB-second | Billed during request handling. First 180,000 GB-seconds/month free. $0.0000025/GB-second |
| Outbound networking | per GB | Bytes returned to clients. Standard GCP egress rates. |
| Always-allocated CPU (instance-based) | per vCPU-second + per GB-second | Higher rate but CPU is always allocated, eliminating cold starts. |
Optimization tips
Common ways to reduce google_ cost without changing the workload.
Right-size memory and CPU
Workload-dependentavailable_
Set min_ instance_ count = 0 for cost
Cost during idleScale-to-zero is free during idle periods. For latency-sensitive functions, set min_
Increase max_ instance_ request_ concurrency
Workload-dependentCloud Functions 2nd gen can handle multiple concurrent requests per instance (default 80). Higher concurrency means fewer instances per request volume, lower total vCPU-seconds.
Use CPU-throttled-when-idle for spiky workloads
Up to 70% during idleThe default (cpu_
Take advantage of free tier
Up to 100% for small workloadsCloud Functions free tier (2M invocations + 360,000 vCPU-seconds + 180,000 GB-seconds) covers many smaller workloads entirely. Stay below for free production use.
FAQ
Should I use 1st gen or 2nd gen?
2nd gen. It's built on Cloud Run, supports longer timeouts (60min vs 9min), higher concurrency per instance (up to 1000), and longer support lifecycle. 1st gen is legacy.
What's the difference between Cloud Functions 2nd gen and Cloud Run?
Under the hood, Cloud Functions 2nd gen IS Cloud Run with extra automation (source code build, trigger wiring). The pricing model is identical. Choose Functions when you want simpler deployment of a single function; Cloud Run for more flexibility (full container, custom build, more endpoints).
How does c3x estimate Cloud Functions?
Same as Cloud Run. Add monthly_
Does VPC connector add cost?
Yes. A Serverless VPC Access connector (google_
Related resources
More Google Cloud resources
Further reading
- GCP Cloud Functions 2nd gen cost: what changed and how to optimize
Cloud Functions 2nd gen runs on Cloud Run and Eventarc under the hood, which changes its pricing from the 1st gen model. Here is how 2nd gen bills, how it differs from 1st gen, and how to keep function cost low.
- Cloud Functions vs Cloud Run cost: why concurrency tips it
Cloud Functions 2nd gen runs on Cloud Run, so rates converge, but Cloud Run's concurrency lets one instance serve many requests, making it cheaper for request-heavy workloads. Here's how to choose.
- GCP Cloud Run CPU allocation cost: request-based vs always-allocated
Cloud Run offers two CPU allocation modes, one that bills CPU only during requests and one that keeps CPU always allocated, and the choice changes both cost and behavior. Here is how each is priced and which fits your workload.
- GCP free tier explained: what is actually free on Google Cloud
Google Cloud has two free offerings: a 90-day, roughly 300 dollar credit for new accounts, and an always-free tier with monthly allowances for specific services. Here is what is truly free, where the limits are, and how charges begin.
Estimate this resource in your own Terraform
Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including google_.