Serverless Function 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

  • Last updated
  • Formula tested against reference values

Your numbers

Memory conversion

Most function platforms treat memory as binary (512 MB = 0.5 GB). Check your provider.

Duration is rounded up to this step, e.g. 1 ms or 100 ms.

Example price only. Enter the current rate from your provider’s price list.

Example price only. Enter the current rate from your provider’s price list.

Result

Monthly cost
—

Calculating…

Request charges
—
Compute (GB-second) charges
—
GB-seconds used
—
Billed duration per invocation
—
Cost per million invocations
—

How to use this calculator

  1. Enter or choose invocations per month.
  2. Enter or choose average duration.
  3. Enter or choose memory allocated.
  4. Enter or choose memory conversion.
  5. Enter or choose billing increment.
  6. The monthly cost updates as you type. Use Copy result or Share to keep it.

Method

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

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.

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.