Learning objectives
After reading this article you will be able to:
- List the infrastructure items of a SaaS and how each one is billed
- Estimate the cost at each stage: prototype, first customers and growth
- Separate the items that grow in steps from the ones that grow with every customer
Most SaaS founders work out the infrastructure bill once, at the prototype, and then forget about it. But the bill changes shape as customers arrive. At first it is almost all fixed: one instance for the API, a database, the domain. With growth come the usage-based items, like AI tokens, emails and file downloads, and those decide how much each customer costs you.
This guide lists the items, shows how each one grows and builds the bill across three stages with hypothetical round prices; current rates are on the official pages listed in the sources. For the architecture itself, see how to host a SaaS.
What goes into SaaS infrastructure?#
A small SaaS almost always has eight infrastructure items:
- Front end: the site and web app your customers use. A static front end is cheap; one with server-side rendering is another process that stays on.
- API: the back end with your product's rules, billed by reserved capacity or by usage. Details are in how much it costs to host an API, and the choice between the two models in serverless or an always-on server.
- Database: accounts, subscriptions and each customer's data. It is usually the largest fixed line, because it needs RAM, disk and backups.
- File storage: uploads, attachments, avatars, exports. Object storage charges per GB stored, per request and, with many providers, for egress.
- Transactional email: sign-up confirmation, password resets, invoices, notifications. Services like Amazon SES charge per thousand emails sent, plus the size of attachments.
- Domain: paid yearly at the registrar. The TLS certificate usually comes at no cost from your host or from Let's Encrypt.
- Observability: logs, error tracking and an uptime monitor, billed per GB of logs, per event or per team seat.
- AI: if the product uses a language model, every call is billed for its input and output tokens.
Outside infrastructure, but on the same margin, sits your payment processor's fee, a percentage of every charge. It isn't in the tables below, but it is part of how much is left per customer.
How does each item grow with the number of customers?#
Step items cost the same until capacity runs out, then jump to the next size. Linear items grow with every customer, every email, every token.
| Item | How it is usually billed | How it grows |
|---|---|---|
| Front end | fixed instance or static hosting | in steps, with traffic |
| API | fixed instance or usage-based | in steps, with requests |
| Database | fixed instance by RAM and disk | in steps, with data and queries |
| File storage | GB stored, requests and egress | linearly, with uploads and downloads |
| Transactional email | per thousand emails, plus attachments | linearly, with users and notifications |
| Domain | per year | doesn't grow |
| Observability | per GB of logs, per event or per team seat | with traffic and with the team |
| AI | per million tokens, input and output | linearly, with each customer's usage |
The distinction matters because step items dilute: the same database serves 10 or 200 customers. Linear items never dilute. If each customer makes a thousand AI calls a month, your thousandth customer costs the same as your first.
How much does each stage cost?#
Hypothetical prices, in dollars: $10 a month per GB of RAM on an always-on instance; $0.02 per GB stored and $0.10 per GB downloaded for storage; $1 per thousand emails; $12 a year for the domain; and, for AI, $1 per million input tokens and $5 per million output tokens.
Prototype#
You and a few test users. The API itself serves the front end on a 1 GB instance, the database is small, files add up to 10 GB with few downloads, emails stay under a thousand a month and AI only runs in tests. The total is $38 a month, almost all fixed.
First customers#
Fifty paying customers. The front end gets its own instance with server-side rendering, the API moves to 2 GB and the database goes to a mid size with daily backups. Files reach 50 GB stored and 100 GB downloaded a month, 10,000 emails go out, and observability moves to a paid plan.
AI is where the bill changes. If each customer makes 300 calls a month, with 2,000 input tokens and 500 output tokens each, that is 30 million input tokens ($30) and 7.5 million output tokens ($37.50). Rounded, $68: the largest line on the invoice, above the database. The token math is in how much it costs to use an LLM API.
Growth#
Five hundred customers. The front end moves to 2 GB, the API runs on two 4 GB instances and the database gets a replica. Files reach 500 GB stored and 1 TB downloaded, 100,000 emails go out, and more traffic and a bigger team raise the cost of logs and error tracking. AI, with the same usage per customer, reaches $675.
| Item | Prototype | 50 customers | 500 customers |
|---|---|---|---|
| Front end | $0 (on the API) | $10 | $20 |
| API | $10 | $20 | $80 |
| Database | $15 | $50 | $150 |
| File storage | $1 | $11 | $110 |
| Transactional email | $1 | $10 | $100 |
| Domain | $1 | $1 | $1 |
| Observability | $5 | $25 | $100 |
| AI | $5 | $68 | $675 |
| Total per month | $38 | $195 | $1,236 |
| Per customer | $3.90 | $2.47 |
How do you calculate cost per customer?#
Divide the bill by the number of active customers, but look at the two groups separately. In the example, front end, API and database cost $80 with 50 customers ($1.60 per customer) and $250 with 500 ($0.50 per customer): step items dilute. AI costs $1.35 per customer at both stages, because it is linear. As you grow, cost per customer approaches the sum of the linear items.
Three practical consequences:
- Plan pricing. Your cheapest plan has to cover the linear items of a customer who uses everything, not of an average customer.
- Per-plan limits. Quotas on AI calls, storage and emails per plan keep a customer from costing more than they pay. For files, see how much it costs to store user files and images.
- Optimization that pays back. Cutting 30% of input tokens lowers the bill every time a customer uses the product; cutting 30% off the database saves a fixed amount, no matter how many customers arrive. Prompt caching, smaller models and batch processing, which providers bill at a discount, are covered in how to reduce LLM token costs.
What hidden costs show up?#
- Extra environments. Staging and preview environments repeat the API and the database. A staging database the size of production is money sitting idle.
- Backups and retention. Keeping database backups for a long time and read replicas are separate lines with many services. Compare the options in how much a cloud database costs.
- Egress. Large exports, videos and files downloaded straight from storage generate egress billed per GB. A CDN with long caching in front of public files cuts this line.
- Email with a dedicated IP. Senders with large volumes may want a dedicated IP to protect deliverability, and on SES it is a separate monthly fee.
- Per-seat tools. Monitoring, error tracking and support tools often charge per user; that bill grows with your team, not your customers.
- Trial accounts and abuse. A trial with no AI limit can generate more cost than revenue. Cap usage on accounts that haven't paid.
- Domain renewal and currency. Renewing a domain can cost more than the first year, as how much a domain costs shows. Services billed in another currency add exchange-rate swings and card fees.
Review the bill every month, item by item, and write down the cost per customer: it tells you whether the next customer improves or hurts your margin.
How to do this on Square Cloud#
On Square Cloud, the front end, API, database and files live in the same account, under one plan billed in Brazilian reais. A SaaS with a database and its own domain starts on Standard, from R$44.99 a month with 4 GB of RAM: that RAM is a pool you split between the front end and the API (512 MB minimum per web application) and the databases (1024 MB minimum for PostgreSQL, MongoDB and MySQL, and 512 MB for Redis). The domain stays at your registrar, with an automatic TLS certificate that renews on its own, and Standard also brings team workspaces.
Part of the usage-based lines in the table fall within the plan. There is no charge for bandwidth or requests (fair use policy); real-time logs and metrics and 4xx/5xx error monitoring come with every plan; and Blob Storage, with an S3-compatible API, charges no egress fees. Every plan includes a storage quota and, from Standard, overage is optional, with a cap you choose. For your product's AI, the AI Gateway, also from Standard, is an OpenAI-compatible API for the cubic model, at no extra cost within the plan's limits (up to 2.5 million tokens a day on Standard); beyond them, AI credit packs apply.
There is no autoscaling: when you reach a new stage, you change plans or raise each application's RAM. See how the pieces fit together on SaaS hosting and compare plans on pricing.
API hosting
APIs in always-on containers, with no cold starts
FAQs
How much does SaaS infrastructure cost at the start?
At the prototype stage, the bill usually comes down to one instance for the API, a small database and the domain. At entry-level prices, that lands in the range of a few dozen dollars a month.
Which SaaS infrastructure item grows the most with customers?
The usage-based ones: AI (tokens), transactional email, storage and bandwidth. Compute and the database grow in steps, when the current instance can no longer keep up.
How do you calculate infrastructure cost per customer?
Divide the monthly bill by the number of active customers, keeping fixed items apart from usage-based ones. Cost per customer falls with growth until it approaches the sum of the usage-based items, which never dilute.
Can AI become the largest cost of a SaaS?
It can. A model API charges per million tokens, and output usually costs more than input, so the bill grows with every active customer and never dilutes. Limit usage per plan and track tokens per customer.
More in APIs
See all 36 articles- How to host an APIHosting an API means running its HTTP server around the clock at a public address with HTTPS. Step-by-step with Node.js and Python, testing and common errors.
- How to host a Node.js appTo host a Node.js app, prepare package.json, read the port and secrets from the environment, pick an LTS version and run it with node. Step-by-step guide.
- How much does it cost to host an API?Hosting a small API costs a few to a few dozen dollars a month. See what goes into the bill (compute, database, bandwidth, requests, logs) and how to estimate it.
- CORS error (blocked by CORS policy): cause and fixA CORS error means the API did not allow your page's origin. Learn the causes, how to fix it in Express and FastAPI, and how to test the preflight with curl.