How this serverless cost calculator works
Most serverless providers bill functions using a pay-per-use model. Your total cost is typically the sum of: (1) request volume (how many times the function runs), (2) compute time (how long it runs multiplied by the memory size), and sometimes (3) data transfer (outbound GB). Many platforms include a monthly free tier for requests and compute. This estimator applies those same concepts so you can model AWS Lambda, Google Cloud Functions, Azure Functions, or a private pricing plan.
Inputs and units (important)
- Invocations per Month is the number of function executions in a month.
- Average Runtime (ms) is the average duration per invocation in milliseconds. The calculator converts it to seconds.
- Memory (MB) is the configured memory size. The calculator converts it to GB by dividing by 1024.
- Price per Million Invocations ($) is the request price (e.g., $0.20 per 1M requests on some plans).
- Price per GB-Second ($) is the compute price for 1 GB-second.
- Free Requests per Month and Free GB-Seconds per Month are monthly allowances. Defaults match a common AWS free tier, but you can change them.
- Data Transfer (GB) and Price per GB Data ($) are optional. Enter 0 if you don’t want to include egress.
Formula and assumptions
The calculator uses the following model (with negative values clamped to zero after free tier is applied):
- Billable requests = max(0,
N − FR) - Total GB-seconds =
N × (M/1024) × (Tms/1000) - Billable GB-seconds = max(0,
TotalGBSec − FG) - Total cost =
(BillableReq/1,000,000)×P + BillableGBSec×G + DataGB×PriceData - If Show annual cost is checked, the final cost is multiplied by 12.
Notes: This is an estimate. Real bills can differ due to provider-specific rounding (e.g., per-ms or per-100ms), CPU allocation differences, architecture (x86 vs ARM), regional pricing, and additional services (API Gateway, queues, databases, logging, monitoring).
Worked example (quick)
Suppose your function runs 2,500,000 times per month, averages 120 ms, uses 256 MB, and your pricing is $0.20 per million requests and $0.00001667 per GB-second. If your free tier is 1,000,000 requests and 400,000 GB-seconds:
- Billable requests = 2,500,000 − 1,000,000 = 1,500,000 → request cost = 1.5 × 0.20 = $0.30
- Total GB-seconds = 2,500,000 × (256/1024) × (120/1000) = 2,500,000 × 0.25 × 0.12 = 75,000 GB-seconds
- Billable GB-seconds = max(0, 75,000 − 400,000) = 0 → compute cost = $0.00
- If data transfer is 0, total monthly estimate = $0.30
This illustrates why the free tier can dominate small-to-medium workloads, while high traffic or long runtimes quickly shift the cost toward compute.
Understanding serverless pricing in practice
Serverless pricing is designed to be simple, but the details matter. Compute is measured in GB-seconds, which combines memory size and runtime. If you double memory and runtime stays the same, compute cost roughly doubles. If you reduce runtime by optimizing code, compute cost drops proportionally. Request charges are usually small compared to compute for heavy workloads, but they can matter for extremely high invocation counts.
Optimization tips
If your estimate is higher than expected, try these levers:
- Reduce runtime: faster code, fewer network calls, reuse connections, and avoid cold-start-heavy patterns.
- Right-size memory: more memory can reduce runtime (sometimes lowering total GB-seconds), but not always—measure both.
- Batch work: process multiple events per invocation when latency requirements allow.
- Reduce egress: compress responses, cache, and use a CDN to lower outbound data transfer.
Data transfer charges
Compute is only part of the bill. Outbound data transfer (egress) can be significant for APIs, file downloads, media processing, or cross-region traffic. Enter your estimated outbound GB and the per-GB price to include it. If your provider has tiered egress pricing, use an average blended rate for a quick estimate.
Cold starts and provisioned concurrency
Cold starts can increase runtime for a subset of invocations, which increases GB-seconds. If you use provisioned concurrency (or similar reserved capacity), that introduces a fixed monthly charge not modeled directly here. You can approximate it by adding the expected monthly fee into your data transfer line (as a workaround) or by calculating it separately and combining totals.
Regional pricing nuances and budgeting
Prices vary by region and can change over time. For multi-region deployments, run the calculator per region (with that region’s prices and traffic split) and sum the results. For budgeting, revisit inputs monthly using real monitoring metrics (p50/p95 runtime, memory usage, and invocation counts) to keep forecasts realistic.
Example scenarios (illustrative)
| Invokes | Runtime | Memory | Monthly Cost After Free Tier |
|---|---|---|---|
| 1,000,000 | 200 ms | 512 MB | $18.40 |
| 5,000,000 | 100 ms | 256 MB | $16.00 |
| 10,000,000 | 50 ms | 128 MB | $10.50 |
These rows are simplified examples and may not match your provider’s exact metering rules. Use your provider’s documentation for authoritative pricing, and treat this page as a fast estimator for planning and comparisons.
FAQ
Can I use different units?
Runtime should be in milliseconds and memory in megabytes. The calculator converts to seconds and gigabytes internally. If your provider lists memory in GB, multiply by 1024 before entering.
How accurate are the results?
It’s an estimate. Real bills may vary due to rounding, regional pricing, free tier eligibility, and additional services (API gateways, queues, databases, logs, monitoring).
Why can the result be $0.00?
If both requests and compute fall within the free tier, billable amounts clamp to zero, producing a $0.00 estimate.
Does this include provisioned concurrency or reserved capacity?
No. This estimator focuses on on-demand execution plus optional data transfer. Add fixed monthly fees separately.
