Serverless Cost Calculator

Estimate monthly serverless function costs based on invocations, execution duration, and memory allocation. Plan your AWS Lambda or cloud function budget.

ms
MB
$
$
Total GB-Seconds
500,000
Sum of all values
Request Cost
$1.80
9,000,000 billable requests
Compute Cost
$1.67
100,000 billable GB-seconds
Monthly Cost
$3.47
Annual Cost
$41.60
Planning notes, formulas, and examples

About the Serverless Cost Calculator

Serverless computing lets you run code without provisioning servers, but understanding the cost model is essential for budget planning. Services like AWS Lambda, Azure Functions, and Google Cloud Functions charge based on the number of invocations and the compute time consumed, measured in GB-seconds.

A GB-second represents one second of execution with 1 GB of memory allocated. If your function uses 512 MB and runs for 2 seconds, that's 1 GB-second. The pricing is remarkably granular โ€” you pay only for what you use, down to the millisecond.

This calculator helps you estimate monthly serverless costs by factoring in request count, average execution duration, memory allocation, and the generous free tier most providers offer. Use it to compare serverless against always-on compute options and find the break-even point for your workloads.

When This Page Helps

Serverless pricing can be deceptively cheap for low-traffic workloads but expensive at scale. Without forecasting, teams discover cost surprises only after deployment. This calculator helps you model different traffic scenarios, compare against EC2 or container alternatives, and determine whether serverless is cost-effective for your specific use case.

How to Use the Inputs

  1. Enter the total number of function invocations expected per month.
  2. Set the average execution duration in milliseconds for each invocation.
  3. Choose the memory allocation in MB for your function.
  4. Enter the per-request rate (e.g., $0.20 per 1 million requests for AWS Lambda).
  5. Enter the per-GB-second rate (e.g., $0.0000166667 for AWS Lambda).
  6. Optionally set the free-tier invocations and GB-seconds to subtract.
  7. Review the monthly cost breakdown and annual projection.
Formula used
GB-Seconds = invocations ร— (duration_ms / 1000) ร— (memory_MB / 1024) Billable GB-Seconds = max(0, GB-Seconds โˆ’ free_tier_GBs) Billable Requests = max(0, invocations โˆ’ free_tier_requests) Monthly Cost = Billable_Requests ร— request_rate + Billable_GB-Seconds ร— GBs_rate

Example Calculation

Result: $7.53/month

Ten million invocations at 200ms each with 256 MB memory produce 500,000 GB-seconds. After subtracting the free tier (1M requests and 400K GB-seconds), the billable amount is 9M requests ($1.80) plus 100,000 GB-seconds ($1.67), plus minor rounding for a total of approximately $7.53/month.

Tips & Best Practices

  • AWS Lambda offers 1 million free requests and 400,000 GB-seconds per month in the free tier.
  • Reduce cost by minimizing function execution time through code optimization.
  • Lower memory allocation for lightweight tasks; increase it to get proportionally more CPU.
  • Use provisioned concurrency for latency-sensitive endpoints (adds a fixed hourly cost).
  • Compare serverless costs against a small EC2 instance at high traffic volumes.
  • Monitor cold start frequency โ€” it adds latency but not cost.

Serverless Pricing Model Explained

Serverless pricing has two components: a per-request fee and a per-GB-second fee. AWS Lambda charges $0.20 per million requests and $0.0000166667 per GB-second. These rates are consistent across most regions with minor variations. The key insight is that total cost depends on three variables: invocation count, duration, and memory allocation.

Optimizing Serverless Costs

The most impactful optimization is reducing execution duration. Profile your function to identify slow operations, cache external API results, and minimize cold start overhead. Right-sizing memory is equally important โ€” too little memory causes slower execution, while too much wastes money on unused capacity. Use AWS Lambda Power Tuning to find the optimal memory setting.

Serverless vs Containers vs VMs

Serverless excels for sporadic workloads, event-driven processing, and APIs with variable traffic. Containers (ECS, EKS) offer more control at medium scale. EC2 VMs remain cheapest for steady high-utilization workloads. Many architectures combine all three, routing each workload to the most cost-effective compute layer.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • A GB-second is the unit of compute time in serverless billing. It represents one second of function execution with 1 GB of memory allocated. If you allocate 512 MB and run for 2 seconds, that equals 1 GB-second.