Compute is rarely the largest line on an API bill. Gateway charges, egress and log ingestion routinely exceed it, and all three are easy to model before you build. Here is the arithmetic.
Requests per month, average response size, and average compute time per request. Everything else derives from those. For a small production API, 10 million requests a month is 3.8 requests per second on average, with peaks perhaps five times that. Write those numbers down before comparing platforms, because every provider prices a different combination of them.
Managed API gateways bill per million requests, and the REST-flavoured tiers are meaningfully more expensive than the plain HTTP ones — on AWS the difference between API Gateway's REST APIs and HTTP APIs is roughly a factor of three per million requests. At 10 million requests a month that is the difference between a rounding error and a real line item, and it buys you features (request validation, usage plans, WAF integration) that many APIs do not use. An Application Load Balancer in front of containers is billed differently again, with an hourly charge plus capacity units, which favours steady traffic over spiky traffic.
Serverless bills requests plus memory-time. A 256 MB function running 120 ms serves 10 million requests for a few dollars of compute, and the free allowance may cover it entirely. A small always-on container costs a fixed amount whether it serves 10 or 10 million requests — typically $5-25 a month for something modest. The crossover is about traffic shape, not volume: bursty and low-average traffic favours serverless, steady traffic favours a server. Model both, because the answer flips depending on your duty cycle.
Ten million responses averaging 20 KB is 200 GB of egress a month. On a hyperscaler at roughly $0.09 per GB after the free allowance, that is about $18 — more than the compute in many designs. On Cloudflare it is zero. Three practical levers: enable compression (JSON compresses very well, often 70-80%), stop sending fields the client discards, and paginate aggressively. Halving the average response size halves this entire line.
A managed Postgres instance suitable for a small production API starts around $15-25 a month and rises quickly with storage, IOPS and replicas. Log ingestion is the sleeper cost: at typical cloud log pricing, verbose request logging on a high-traffic API can exceed the compute bill outright. Log at info in production, sample successful requests rather than recording all of them, keep full detail for errors, and set a retention period deliberately instead of accepting the default.
10 million requests a month, 20 KB average response, 120 ms compute, one managed database, on a hyperscaler: HTTP-tier gateway around $10, serverless compute a few dollars, egress about $18, database $25, logs $5-20 depending on discipline. Total roughly $60-80 a month. The same workload on a single $12 VPS behind Cloudflare, with Postgres on the same box: about $12, plus the operational responsibility you have taken on. Both are correct answers to different questions.
Rate limiting you did not build, so one client's retry loop becomes your traffic bill. Missing caching, so identical responses are computed and paid for repeatedly — a Cache-Control header on a genuinely cacheable endpoint is the cheapest optimisation available. And no budget alert, which is why bill shocks are always discovered a month late.
Free tools, guides, and resources across the SPUNK13 network.
Visit spunk.bet400+ Free Tools