{
  "slug": "serverless-invocation-cost",
  "title": "Serverless Function Invocation Cost Calculator",
  "heading": "Serverless / Lambda Cost Calculator",
  "category": "financial",
  "url": "https://www.revenuelab.fyi/toolbox/serverless-invocation-cost",
  "summary": "Turn invocation count, duration, and memory into a monthly bill.",
  "description": "Serverless platforms like AWS Lambda, Google Cloud Functions, and Azure Functions bill on two axes: a per-invocation fee and a compute charge based on memory allocated multiplied by execution duration, measured in GB-seconds. This calculator applies both, including the typical free tier of 1 million requests and 400,000 GB-seconds per month that AWS offers, so small workloads often show as effectively free while high-volume workloads reveal their real cost. Memory allocation matters more than people expect — doubling memory doubles the GB-seconds rate but can also make the function run faster due to proportional CPU allocation, so the net cost change is not always what it looks like at first. This tool assumes a fixed duration input; if you're deciding between memory tiers, run it twice with the duration you measure at each memory setting to find the actual cheapest configuration, which is often not the smallest memory size.",
  "formula": "GB-seconds = (memory MB ÷ 1024) × duration(s) × invocations; cost = invocation fee + GB-seconds × rate, minus free tier.",
  "dateModified": "2026-09-30",
  "run_url": "https://www.revenuelab.fyi/api/public/calc?tool=serverless-invocation-cost",
  "inputs": [
    {
      "id": "invocations",
      "label": "Invocations per month",
      "kind": "number",
      "hint": null,
      "default": 5000000,
      "unit": null,
      "min": 0,
      "max": null
    },
    {
      "id": "durationMs",
      "label": "Average duration",
      "kind": "number",
      "hint": null,
      "default": 250,
      "unit": "ms",
      "min": 1,
      "max": null
    },
    {
      "id": "memoryMb",
      "label": "Memory allocated",
      "kind": "number",
      "hint": null,
      "default": 512,
      "unit": "MB",
      "min": 128,
      "max": null
    },
    {
      "id": "invocationRate",
      "label": "Price per million invocations",
      "kind": "number",
      "hint": null,
      "default": 0.2,
      "unit": "$",
      "min": 0,
      "max": null
    },
    {
      "id": "gbsRate",
      "label": "Price per GB-second",
      "kind": "number",
      "hint": null,
      "default": 0.0000166667,
      "unit": "$",
      "min": 0,
      "max": null
    },
    {
      "id": "freeGbs",
      "label": "Free GB-seconds per month",
      "kind": "number",
      "hint": null,
      "default": 400000,
      "unit": null,
      "min": 0,
      "max": null
    }
  ],
  "outputs": [
    {
      "id": "total",
      "label": "Monthly serverless cost",
      "format": "currency",
      "hint": null,
      "primary": true
    },
    {
      "id": "computeCost",
      "label": "Compute (GB-second) cost",
      "format": "currency",
      "hint": null,
      "primary": false
    },
    {
      "id": "invocationCost",
      "label": "Invocation fee cost",
      "format": "currency",
      "hint": null,
      "primary": false
    },
    {
      "id": "gbSeconds",
      "label": "Total GB-seconds used",
      "format": "number",
      "hint": null,
      "primary": false
    },
    {
      "id": "costPerMillion",
      "label": "Cost per million invocations",
      "format": "currency",
      "hint": null,
      "primary": false
    }
  ],
  "worked_example": {
    "inputs": [
      "Invocations per month: 5000000",
      "Average duration: 250 ms",
      "Memory allocated: 512 MB",
      "Price per million invocations: 0.2 $",
      "Price per GB-second: 0.0000166667 $",
      "Free GB-seconds per month: 400000"
    ],
    "outputs": [
      "Monthly serverless cost: $4.55",
      "Compute (GB-second) cost: $3.75",
      "Invocation fee cost: $0.80",
      "Total GB-seconds used: 625,000",
      "Cost per million invocations: $0.91"
    ]
  },
  "how_to": {
    "title": "How to use this",
    "steps": [
      "Enter invocations per month.",
      "Enter average duration (ms).",
      "Enter memory allocated (MB).",
      "Enter price per million invocations ($).",
      "Enter price per gb-second ($).",
      "Enter free gb-seconds per month.",
      "Read your monthly serverless cost on the right — it updates as you type.",
      "Hit Share to keep the scenario or send it to someone."
    ]
  },
  "scenarios": [
    {
      "name": "Conservative",
      "description": "Lower-end numbers — what if things land soft?",
      "values": {
        "invocations": 3000000,
        "durationMs": 150,
        "memoryMb": 320,
        "invocationRate": 0.12,
        "gbsRate": 0.00001000002,
        "freeGbs": 240000
      }
    },
    {
      "name": "Typical",
      "description": "Defaults — the most common real-world setup.",
      "values": {
        "invocations": 5000000,
        "durationMs": 250,
        "memoryMb": 512,
        "invocationRate": 0.2,
        "gbsRate": 0.0000166667,
        "freeGbs": 400000
      }
    },
    {
      "name": "Ambitious",
      "description": "Higher-end numbers — what if things really pop?",
      "values": {
        "invocations": 8000000,
        "durationMs": 400,
        "memoryMb": 832,
        "invocationRate": 0.32000000000000006,
        "gbsRate": 0.00002666672,
        "freeGbs": 640000
      }
    }
  ],
  "limitations": [
    "Results are estimates before tax, fees, and inflation unless an input explicitly covers them.",
    "Rates are treated as fixed for the whole period — variable-rate products will drift from this projection.",
    "This is educational maths, not financial advice. Check anything contractual with the lender or your accountant."
  ],
  "faq": [
    {
      "q": "At what volume does serverless get more expensive than a VM?",
      "a": "As a rough rule, once a function runs close to continuously — meaning invocations × duration approaches 730 hours of compute time per month — a reserved VM or container running the same workload is typically 3-8x cheaper per unit of compute. Serverless wins on spiky, low-average-utilization workloads where you'd otherwise pay for idle VM time."
    },
    {
      "q": "Why would increasing memory ever lower total cost?",
      "a": "Lambda allocates CPU proportionally to memory. A function bottlenecked on CPU (not I/O) can run 2-4x faster with 2x the memory, so GB-seconds (memory × time) can actually drop even though the rate per GB-second stays the same, because the time term fell faster than the memory term rose. Always benchmark actual duration at each memory tier before assuming smaller is cheaper."
    },
    {
      "q": "Does cold start time count toward billed duration?",
      "a": "Yes for most providers — AWS Lambda bills from the start of code execution including initialization on a cold start, though the very first init phase for some runtimes is billed separately or capped. Cold starts add 100ms-2s depending on runtime and package size, which matters for latency but is usually a small fraction of total monthly GB-seconds unless invocations are very short and frequent."
    }
  ],
  "related": [
    "https://www.revenuelab.fyi/toolbox/cloud-vm-monthly-cost",
    "https://www.revenuelab.fyi/toolbox/kubernetes-node-bin-packing",
    "https://www.revenuelab.fyi/toolbox/llm-api-token-cost"
  ],
  "license": "CC-BY-4.0",
  "citation": "RevenueLab — Serverless Function Invocation Cost Calculator (https://www.revenuelab.fyi/toolbox/serverless-invocation-cost)"
}