{
    "name": "Serverless Function Cost Calculator",
    "url": "https://calculators.geekmidst.com/calculators/serverless-invocation-cost-calculator",
    "markdown": "https://calculators.geekmidst.com/calculators/serverless-invocation-cost-calculator.md",
    "category": "Software, cloud & AI",
    "description": "Estimate a monthly serverless function bill from invocations, duration, memory, billing increment, request and GB-second prices, and free allowances.",
    "summary": "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"
    ],
    "applies_to": "Worldwide",
    "last_updated": "2026-10-29",
    "computation": "Results are computed in the visitor’s browser on the HTML page. This API describes the calculator; it does not compute results.",
    "inputs": [
        {
            "name": "invocations",
            "label": "Invocations per month",
            "type": "number",
            "default": "3000000"
        },
        {
            "name": "duration_ms",
            "label": "Average duration",
            "type": "number",
            "default": "120",
            "unit": "ms"
        },
        {
            "name": "memory_mb",
            "label": "Memory allocated",
            "type": "number",
            "default": "512",
            "unit": "MB"
        },
        {
            "name": "mb_per_gb",
            "label": "Memory conversion",
            "type": "segmented",
            "default": "1024",
            "options": {
                "1024": "1 GB = 1,024 MB",
                "1000": "1 GB = 1,000 MB"
            }
        },
        {
            "name": "granularity_ms",
            "label": "Billing increment",
            "type": "number",
            "default": "1",
            "unit": "ms"
        },
        {
            "name": "request_price",
            "label": "Price per million requests",
            "type": "number",
            "default": "0.20"
        },
        {
            "name": "gbs_price",
            "label": "Price per GB-second",
            "type": "number",
            "default": "0.0000166667"
        },
        {
            "name": "free_requests",
            "label": "Free requests per month",
            "type": "number",
            "default": "0",
            "optional": true
        },
        {
            "name": "free_gbs",
            "label": "Free GB-seconds per month",
            "type": "number",
            "default": "0",
            "optional": true
        },
        {
            "name": "currency",
            "label": "Currency",
            "type": "currency",
            "default": "USD"
        }
    ],
    "outputs": [
        {
            "key": "monthly_cost",
            "label": "Monthly cost",
            "format": "currency"
        },
        {
            "key": "request_cost",
            "label": "Request charges",
            "format": "currency"
        },
        {
            "key": "compute_cost",
            "label": "Compute (GB-second) charges",
            "format": "currency"
        },
        {
            "key": "gb_seconds",
            "label": "GB-seconds used",
            "format": "number"
        },
        {
            "key": "billed_ms",
            "label": "Billed duration per invocation",
            "format": "number"
        },
        {
            "key": "cost_per_million",
            "label": "Cost per million invocations",
            "format": "decimal4"
        }
    ],
    "formula": {
        "text": "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",
        "variables": {
            "Increment": "billing granularity in milliseconds",
            "MB-per-GB": "1,024 or 1,000 depending on the provider"
        }
    },
    "worked_example": {
        "inputs": {
            "invocations": "3000000",
            "duration_ms": "120",
            "memory_mb": "512",
            "mb_per_gb": "1024",
            "granularity_ms": "1",
            "request_price": "0.20",
            "gbs_price": "0.0000166667",
            "free_requests": "0",
            "free_gbs": "0",
            "currency": "USD"
        },
        "steps": [
            "GB-seconds: 3,000,000 × 0.120 s × (512 ÷ 1,024) GB = 180,000.",
            "Compute: 180,000 × 0.0000166667 = 3.00.",
            "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."
    },
    "interpretation": "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": [
        "Every invocation runs for the average duration.",
        "Free allowances apply to this function’s usage only."
    ],
    "limitations": [
        "Provisioned concurrency, ephemeral storage, data transfer and calls to other services are not included."
    ],
    "rules": null,
    "faqs": [
        {
            "question": "What is a GB-second?",
            "answer": "One gigabyte of memory allocated for one second. A 512 MB function running for 2 seconds uses 1 GB-second."
        },
        {
            "question": "Why does the billing increment matter?",
            "answer": "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."
        }
    ],
    "sources": [],
    "related": [
        {
            "name": "API Gateway Request Cost Calculator",
            "url": "https://calculators.geekmidst.com/calculators/api-gateway-request-cost-calculator"
        },
        {
            "name": "Queue Worker Capacity Calculator",
            "url": "https://calculators.geekmidst.com/calculators/queue-worker-capacity-calculator"
        },
        {
            "name": "Cloud Storage Cost Calculator",
            "url": "https://calculators.geekmidst.com/calculators/cloud-storage-monthly-cost-calculator"
        }
    ],
    "disclaimer": null,
    "publisher": "GM¹X CalcVerse"
}