# Serverless Function Cost Calculator

> Estimate a monthly serverless function bill from invocations, duration, memory, billing increment, request and GB-second prices, and free allowances.

Category: Software, cloud & AI · Applies to: Worldwide · Last updated: 2026-10-29
Interactive calculator: https://calculators.geekmidst.com/calculators/serverless-invocation-cost-calculator

Serverless functions are billed per request plus per GB-second: memory in GB × billed duration in seconds. Enter your provider’s prices and free allowances.

Also called: Function-as-a-service cost calculator, GB-second calculator.

## Inputs
- Invocations per month (default 3000000)
- Average duration (unit ms; default 120)
- Memory allocated (unit MB; default 512)
- Memory conversion (options: 1 GB = 1,024 MB, 1 GB = 1,000 MB; default 1024)
- Billing increment (unit ms; default 1)
- Price per million requests (default 0.20)
- Price per GB-second (default 0.0000166667)
- Free requests per month (default 0; optional)
- Free GB-seconds per month (default 0; optional)
- Currency

## Results
- Monthly cost
- Request charges
- Compute (GB-second) charges
- GB-seconds used
- Billed duration per invocation
- Cost per million invocations

## Formula

```
Billed ms = ⌈Duration ÷ Increment⌉ × Increment;  GB-s = Invocations × Billed ms ÷ 1,000 × Memory MB ÷ MB-per-GB;  Cost = (Invocations − Free) ÷ 10⁶ × Request price + (GB-s − Free GB-s) × GB-s price
```

Where:
- Increment: billing granularity in milliseconds
- MB-per-GB: 1,024 or 1,000 depending on the provider

## Worked example
1. GB-seconds: 3,000,000 × 0.120 s × (512 ÷ 1,024) GB = 180,000.
2. Compute: 180,000 × 0.0000166667 = 3.00.
3. Requests: 3 million × 0.20 = 0.60. Total 3.60.

**Result:** At these example prices, 3 million 120 ms invocations at 512 MB cost about 3.60 a month.

## What the result means

More memory raises the price per second but often shortens the run, because CPU usually scales with memory. Test a few memory sizes: the cheapest setting is where duration × memory is lowest.

## Assumptions and limits
- Every invocation runs for the average duration.
- Free allowances apply to this function’s usage only.
- Provisioned concurrency, ephemeral storage, data transfer and calls to other services are not included.

## Questions

### What is a GB-second?

One gigabyte of memory allocated for one second. A 512 MB function running for 2 seconds uses 1 GB-second.

### Why does the billing increment matter?

With 100 ms rounding, a 120 ms function is billed as 200 ms, two-thirds more than its real duration. With 1 ms rounding it is billed for 120 ms.

## Related calculators
- [API Gateway Request Cost Calculator](https://calculators.geekmidst.com/calculators/api-gateway-request-cost-calculator)
- [Queue Worker Capacity Calculator](https://calculators.geekmidst.com/calculators/queue-worker-capacity-calculator)
- [Cloud Storage Cost Calculator](https://calculators.geekmidst.com/calculators/cloud-storage-monthly-cost-calculator)

Source: GM¹X CalcVerse — https://calculators.geekmidst.com/calculators/serverless-invocation-cost-calculator
