The formula
Request cost = requests × price per million ÷ 1,000,000
Compute cost = requests × GB-seconds per request × price per GB-second
Egress (GB) = requests × response size + other transfer; egress cost = max(0, egress − free allowance) × price per GB
Storage cost = GB stored × price per GB-month
Monthly total = requests + compute + egress + storage + fixed costs
Worked example
- An API serving 50 million requests a month at $1.00 per million: $50.00.
- Compute: 50M × 0.0625 GB-s × $0.0000166667 = $52.08.
- Egress: 50M × 15 KB = 750 GB plus 200 GB other = 950 GB; after 100 GB free, 850 GB × $0.09 = $76.50.
- Storage: 500 GB × $0.023 = $11.50, plus $25 fixed.
- Total ≈ $215.08 a month, or $4.30 per million requests.
Where cloud costs come from
Cloud bills are made up of many small unit prices: charges per request, per GB-second of compute, per GB of data stored and per GB of data transferred out. Each looks tiny, but at scale they add up, and the biggest item isn't always the one you expect. This calculator models a typical API or web app running on serverless or managed services, so you can see how each part of the bill changes as traffic grows and test the effect of optimisations before you deploy them.
Requests and serverless compute
Managed API gateways typically charge per million requests, roughly $1 for HTTP-style APIs and $3.50 for fuller REST APIs on AWS at published 2025 list prices, with volume discounts. Serverless functions such as AWS Lambda, Google Cloud Run functions and Azure Functions add a charge for GB-seconds, the memory allocated multiplied by how long each invocation runs, plus a small per-invocation fee. Halving a function's duration or memory halves its compute cost, so profiling hot paths and right-sizing memory pays off quickly.
Egress: the hidden cost
Data coming into the cloud is usually free, but data going out to the internet is charged per GB after a monthly free allowance, often around $0.05–0.12 per GB depending on provider, region and volume. For APIs that return large responses, media sites and downloads, egress is frequently the biggest line on the bill. Compressing responses with gzip or Brotli, caching at a CDN, paginating results and serving static assets from providers with cheap or free egress can cut costs dramatically. Our Base64 calculator shows how encoding inflates payloads.
Storage and fixed costs
Object storage such as S3, Google Cloud Storage and Azure Blob Storage costs a few cents per GB per month in standard tiers, with cheaper infrequent-access and archive tiers for data you rarely read. Databases, load balancers, NAT gateways, monitoring and support plans often have fixed hourly or monthly charges regardless of traffic; include them in fixed costs. NAT gateway data processing charges in particular surprise many teams, so check your architecture's data paths.
Using the results
The cost per million requests is a useful unit metric for pricing your own product: if each customer makes 2 million requests a month, they cost you about twice the per-million figure to serve. Compare the annual figure with reserved capacity, savings plans or a fixed server, which can be cheaper for steady, predictable workloads. Prices here are inputs, not live quotes: check your provider's current pricing page and calculator, since prices vary by region and change over time.
A quick optimisation example
In the default example, egress is the largest cost at $76.50. Enabling Brotli compression, which commonly shrinks JSON responses by 70–80%, would cut the 750 GB of API responses to about 190 GB and save around $50 a month. Caching popular responses at a CDN could reduce both request and egress charges further, while trimming function memory from 512 MB to 256 MB, if performance allows, would halve the compute line.
Related tools
For estimating ad revenue to cover hosting costs, try the CPM and eCPM calculator. To size bandwidth for backups and migrations, use the data transfer time calculator, and for storage hardware on-premises, the RAID calculator. Business owners comparing subscriptions can audit recurring software spending with our subscription cost calculator.