Cloud Run fully managed or Cloud Functions 2nd gen for infrequent HTTP traffic?
0 reputation · 29 Aug 2024, 14:55 UTC
0 reputation · 29 Aug 2024, 14:55 UTC
Goal: choose the lower-cost Google Cloud option for an infrequently invoked HTTP endpoint.
Cloud Run fully managed bills per request plus vCPU and memory during processing, with configurable concurrency and scale-to-zero. Cloud Functions 2nd generation bills per invocation plus compute time and memory, with no idle-instance charge but per-instance concurrency and cold starts on scale-up. Cloud Run minimum instance or CPU settings can create baseline charges even with few requests. Outbound egress is billed separately for both and may dominate payload-heavy responses. Regional SKUs and quotas affect the break-even point.
35275 reputation · 30 Aug 2024, 01:35 UTC
For an infrequently invoked HTTP endpoint with identical duration and memory, Cloud Run fully managed is typically the safer lower-cost choice at very low invocation counts. Both services often fall inside their monthly free tiers, and because Cloud Functions 2nd generation runs on Cloud Run infrastructure, it tends to match or exceed Cloud Run's cost for the same container rather than undercut it. Treat all rates, free-tier limits, and defaults as unverified until you check current Google Cloud pricing for your region.
Cloud Run exposes an explicit concurrency setting, often defaulting around 80 and capping near 1000, so a burst can reuse warm instances and reduce billable instance-seconds and cold starts. Confirm the current value for your region. Cloud Functions 2nd generation uses per-instance concurrency, and whether it can exceed one concurrent request depends on version and trigger type, so verify the limit before assuming the same burst behavior. Higher concurrency in Cloud Run generally lowers cost per request under bursty traffic; near-serial traffic keeps both services effectively tied inside free tiers.
Unexpected baseline charges usually come from minimum instances, startup-CPU boosts, provisioned concurrency, or a fronting load balancer or API gateway, not from invocations themselves. Large HTTP responses can make outbound egress the dominant cost, and egress is billed separately on both services outside any compute free tier.
gcloud run services describe SERVICE --region=REGION and gcloud functions describe FUNCTION --region=REGION, checking concurrency, min/max instances, CPU allocation, and startup-CPU behavior.What is your peak concurrent requests per second and average response size? Concurrent bursts or payload-heavy responses favor Cloud Run because concurrency control reduces instance count and egress becomes the main cost. Without those numbers, the recommendation stays conservative.
Assumption: identical container image, runtime duration, and memory allocation on both services. Regional SKUs and quotas can move the break-even independently of invocation count.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.