What is the billing model for serverless functions?

Answer

Serverless billing has two components: (1) Invocation count — AWS Lambda charges $0.20 per million requests. The first 1 million requests per month are free (always-free tier); (2) Compute time (GB-seconds) — charged based on function memory allocation × execution duration, measured in 1ms increments. Example: a 512MB function running for 100ms costs 0.05 GB-seconds. AWS Lambda free tier includes 400,000 GB-seconds/month. The key insight: if your function receives no traffic, you pay $0 — compared to a $50/month EC2 instance running idle. This makes serverless extremely cost-effective for low/variable traffic. However, at high constant throughput, dedicated servers can be cheaper. Break-even analysis: Lambda becomes more expensive than a reserved EC2 instance around ~3-5 million executions per month for typical workloads. Always use the AWS Pricing Calculator for accurate comparisons.