Computed Truth
Doubling your serverless memory (e.g., 128MB to 256MB) doubles the cost per second, but often halves the execution time. For CPU-bound tasks, this results in **zero net cost increase** with 2x performance gains. Always benchmark your function; paying for 1024MB might actually be cheaper than 128MB if it runs 10x faster.
Serverless Execution Cost Estimator
Calculate Monthly Bill
The Technical Proof
Serverless billing is derived from GB-seconds:
$$ GB_{sec} = Requests \times \frac{Duration_{ms}}{1000} \times \frac{Memory_{MB}}{1024} $$
$$ Cost = (GB_{sec} - FreeTier) \times Price_{per\_GB\_sec} + (Requests - FreeRequests) \times Price_{per\_req} $$
- AWS/GCP Free Tier: 400,000 GB-seconds per month.
- Azure Free Tier: 400,000 GB-seconds per month.
- Request costs are typically $0.20 per million, often negligible compared to compute time.
Step-by-Step Logic
- Normalize Units: Convert Memory to GB (e.g., 512MB = 0.5GB) and Duration to Seconds.
- Calculate Volume: Multiply by total monthly requests to get total Compute Seconds.
- Calculate Capacity: Multiply Compute Seconds by Memory (GB) to get GB-seconds.
- Apply pricing: Subtract Free Tier (if enabled) and multiply by provider execution rates. Add request fees ($0.20/1M).