SaaS server costs rarely jump in a single month. The bill grows by one managed database and one forgotten staging server at a time, and nobody rechecks the older lines.
The cost shows up in your margins. Hosting is part of cost of goods sold, so every wasted dollar lowers gross margin, and without a cost per customer you can't tell which plans make money.
Our advice is to measure 2 numbers before cutting anything: infrastructure cost as a share of revenue and infrastructure cost per customer. With both in hand, the cuts go in order of effort, and the first round takes an afternoon.
Before the tactics, we want to ensure the 2 numbers are clear, so the formulas and a worked example come first. If you'd rather hand the work over, our hosting and infrastructure service covers platform selection, Cloudflare setup, deploy pipelines and monitoring, with every account in your name.
What Counts as SaaS Infrastructure Costs
A cloud invoice can list hundreds of line items, and most SaaS spend still falls into 8 components. Sorting the bill this way shows which lines grow with customers and which stay flat.
Component | What You Pay For | What Makes It Grow |
|---|---|---|
Compute | Virtual machines, containers and serverless functions that run the app and its background jobs | Traffic, oversized instances and servers that run all day for an hour of work |
Database | The managed instance, its storage, replicas and backups | Data volume, slow queries and a standby for high availability |
Storage | Disks, snapshots and object storage for uploads | Files nobody deletes and old backups |
Data transfer | Traffic that leaves the provider's network, often called egress | Large downloads, media and traffic between zones or regions |
Observability | Logs, metrics, traces and error tracking | Log volume, long retention and per-host pricing |
Third-party APIs and AI models | Per-request or per-token charges for services inside the product | Usage per customer, which varies widely between accounts |
Transactional and notification email | Send volume and dedicated IP addresses | |
CI and developer tools | Build minutes, artifact storage and per-seat tools | Team size and build frequency |
We'd mark each line as fixed or variable. A fixed line, such as a base database instance, costs the same at 50 customers and at 500. A variable line, such as AI model usage or email, rises with every active account, and those lines decide what the next customer costs you.
Engineering salaries are a real cost of running infrastructure, but they sit in payroll. The numbers below cover vendor bills only.
How to Calculate SaaS Server Costs
3 formulas cover most decisions, and they use numbers you already have: last month's infrastructure invoices, monthly recurring revenue (MRR) and the count of paying customers.
- Infrastructure share of revenue = monthly infrastructure cost ÷ MRR × 100
- Infrastructure cost per customer = monthly infrastructure cost ÷ paying customers
- Variable cost per customer = variable lines only ÷ paying customers
The first number tells you how much of each dollar of revenue goes to vendors. The other 2 tell you whether a plan's price covers what its customers cost to serve. Our guide to SaaS metrics such as MRR, churn and LTV covers the revenue side of these formulas.
A Worked Example
The numbers below are made up to show the method. The product in this example has 400 paying customers and $20,000 in MRR.
Component | Monthly Cost | Type |
|---|---|---|
Compute | $600 | Fixed |
Database | $450 | Fixed |
Storage | $80 | Variable |
Data transfer | $120 | Variable |
Observability | $250 | Fixed |
Third-party APIs and AI models | $700 | Variable |
$60 | Variable | |
CI and developer tools | $40 | Fixed |
Total | $2,300 | $1,340 fixed, $960 variable |
- Infrastructure share of revenue: $2,300 ÷ $20,000 = 11.5%
- Infrastructure cost per customer: $2,300 ÷ 400 = $5.75 a month
- Variable cost per customer: $960 ÷ 400 = $2.40 a month
On a $29 plan, $5.75 leaves room. The average hides the spread, though. If 40 heavy accounts cause $600 of the $700 in API and AI charges, each one costs $15 a month before any other line is counted.
For a product with a variable line this large, we'd calculate cost per customer for each plan or usage tier. Usage limits or usage-based pricing can then follow the cost, and our comparison of per-seat, usage-based and flat-rate pricing explains the options.
Where Gross Margin Fits
Gross margin is revenue minus cost of goods sold, divided by revenue. For SaaS, cost of goods sold usually includes hosting, third-party services inside the product, customer support and payment fees.
Benchmarkit's 2026 SaaS and AI Metrics Benchmarks report surveyed 342 B2B SaaS and AI-native software companies. Aleph's summary of the report puts the median software gross margin at 80% for 2025. Hosting is only one part of cost of goods sold, so if infrastructure alone takes 20% of revenue, the product lands below 80% once support and payment fees are added.
A free plan or a long trial changes the math as well, because free users cost money to serve and bring no revenue. Our product-led growth guide covers when that trade pays off.
Tag Resources Before You Calculate
The split by component only works if the bill can be grouped. Each large provider has a feature for this:
- AWS: cost allocation tags
- Google Cloud: labels
- Azure: tags
We recommend tagging every resource with an environment and a service name from the first day, since untagged spend is hard to assign afterward.
How to Estimate Server Costs Before Launch
Before launch there is no invoice to read, so the estimate is built from a baseline and a usage driver. This is the order we'd follow:
- A list of components. The 8 rows in the first table, minus the ones your product doesn't need.
- A priced baseline. The smallest setup that runs the product, priced in the AWS Pricing Calculator, the Google Cloud pricing calculator or the Azure pricing calculator. A VPS provider's plan page does the same job.
- A usage driver per customer. The thing each customer consumes, such as requests, stored gigabytes, AI tokens or emails sent.
- 3 scenarios. The bill at 100, 1,000 and 10,000 customers, with fixed lines stepping up only when a server or database tier runs out.
- A budget alert at the baseline. An alert from day 1 shows how far the estimate is from the real bill.
The estimate will be wrong in its details. It is still useful, because it shows which line grows fastest, and you can price for that line and watch it from the first month.
Where SaaS Cloud Bills Grow
Most surprise charges come from 6 places. Each one follows a billing rule that is easy to miss.
Managed Database Tiers
Managed databases are sold in steps, so one slow query can push you into the next tier early. A high-availability standby is a second instance you pay for.
Stopping a database doesn't stop the bill either. On Amazon RDS, a stopped instance is still charged for provisioned storage and backups, and RDS starts it again after 7 days.
Data Transfer
Providers charge for traffic that leaves their network, and the rules differ a lot:
- AWS: the first 100 GB a month out to the internet is free across services and most Regions, and transfer beyond that is billed per gigabyte. A NAT gateway adds an hourly charge plus a fee for each gigabyte it processes.
- DigitalOcean: each Droplet plan includes outbound transfer, pooled across the team, and extra transfer costs $0.01 per GiB at the time of writing.
- Hetzner: cloud servers include a monthly traffic allowance, and usage beyond it is billed in 100 MB blocks.
- Cloudflare R2: object storage with no egress fees, which suits files that customers download often.
For a product that serves large files or video, data transfer can pass compute as the largest line. We'd check this line first for any media-heavy product.
Logs and Metrics Retention
Log volume grows with traffic, and the default settings often keep everything. Amazon CloudWatch Logs, for example, keeps logs indefinitely unless you set a retention period, which can run from 1 day to 10 years.
Hosted observability tools usually charge by gigabytes ingested or by host. Debug-level logging left on in production is a common cause of a jump here.
Idle Resources
Stopping a server usually doesn't stop all of its charges. These are the rules we'd keep in mind:
- AWS EC2: a stopped instance has no compute charge, but its EBS volumes and Elastic IP addresses are still billed.
- AWS public IPv4: every public IPv4 address costs $0.005 an hour at the time of writing, whether it is attached to a resource or idle.
- DigitalOcean: a powered-off Droplet is billed until you destroy it, because its resources stay reserved.
- Hetzner: a cloud server is billed for as long as it exists, whether it is on or off.
- Every provider: old snapshots, unattached disks and unused load balancers keep billing until someone deletes them.
Third-Party APIs and AI Model Usage
Per-request and per-token services scale with usage, and usage is uneven. A small group of heavy accounts can produce most of the bill, as in the worked example above.
We recommend setting a usage limit on every plan before launch and logging usage per account from day 1. Caching repeated requests and sending simple tasks to a smaller model both lower the cost per request without changing the product.
Per-Seat Developer Tools
CI minutes, error tracking and monitoring seats are small lines that grow with every hire. They rarely decide the margin, but duplicates are common, such as 2 error trackers or 2 tools that collect the same logs.
How to Reduce SaaS Server Costs
We'd work through cost reduction in order of effort. The low-effort fixes often close the gap, and they add no operational risk.
Tactic | Effort | What It Saves |
|---|---|---|
Delete idle resources | Low | Charges for servers, disks, IP addresses and snapshots nobody uses |
Set log retention | Low | Storage for logs you will never read |
Right-size instances | Low | Capacity that sits unused |
Schedule non-production environments | Low to medium | Hours when staging runs with nobody using it |
Commit to a baseline | Medium | A discount on compute you run all year |
Use spot capacity for batch work | Medium | Most of the on-demand price for jobs that can restart |
Cache and use a CDN | Medium | Repeated database queries and origin traffic |
Tier object storage | Medium | The storage rate for files nobody opens |
Fix slow queries and indexes | Medium | The next database tier |
Move steady workloads to a VPS or bare metal | High | The premium for elasticity you don't use |
Clean Up and Right-Size
The first pass is a review of what is running. Each large provider has a tool that reads your usage and suggests smaller sizes:
- AWS: Compute Optimizer gives rightsizing recommendations and finds idle resources.
- Google Cloud: machine type recommendations are based on the previous 8 days of metrics.
- Azure: Advisor flags virtual machines with low use and recommends a resize or a shutdown.
It is wise to check memory use yourself before accepting a smaller size, because not every tool has memory data by default.
For staging and test environments, a schedule that shuts them down outside working hours removes most of their running hours.
Commit to a Baseline
Commitment discounts trade flexibility for a lower rate. You promise 1 or 3 years of usage, and the provider cuts the price of that usage. These are the maximum discounts at the time of writing:
Provider | Option | Maximum Discount | What You Commit To |
|---|---|---|---|
AWS | Compute Savings Plans | Up to 66% | Hourly spend, across instance families and Regions |
AWS | EC2 Instance Savings Plans | Up to 72% | Hourly spend on one instance family in one Region |
Google Cloud | Resource-based committed use discounts | Up to 37% for 1 year and up to 55% for 3 years on most machine types | A set amount of vCPU and memory |
Azure | Savings plan for compute | Up to 65% | Hourly spend across compute services |
Azure | Reserved VM instances | Up to 72% | A specific VM type |
AWS now recommends Savings Plans over Reserved Instances. Google Cloud also applies sustained use discounts automatically to some machine types that run for more than 25% of a billing month.
We'd commit only to the baseline you have run steadily for several months, and leave growth on on-demand pricing. A startup that commits to a size it later outgrows or abandons still pays for the unused part.
Use Spot Capacity for Batch Work
Spot capacity is spare capacity sold at a deep discount, and the provider can take it back at short notice.
- AWS Spot Instances: up to 90% off on-demand prices, with a 2-minute interruption notice.
- Google Cloud Spot VMs: up to 91% off for many machine types.
- Azure Spot Virtual Machines: up to 90% off, with eviction on as little as 30 seconds of notice.
Spot fits work that can stop and restart, such as queue workers, report generation, CI runners and media processing. The web app and the primary database should stay on regular instances.
Cache and Use a CDN
Caching cuts cost in 2 places. A CDN serves static files and cacheable pages from the edge, so those requests never reach your servers. An in-memory cache such as Redis or Valkey answers repeated queries without touching the database.
The gain depends on how much of your traffic repeats, so we'd measure the cache hit rate before and after the change. Our Cloudflare cache setup service handles cache rules and cookie exclusions for teams that want it done for them.
Tier Object Storage
Object storage has cheaper classes for files that are rarely opened. S3 Intelligent-Tiering moves objects automatically: to an infrequent access tier after 30 days without access and to an archive tier after 90, for a small monitoring charge per object.
For files that customers download often, the transfer fee matters more than the storage rate, and a store without egress fees is worth pricing.
Fix Slow Queries and Indexes
A database upgrade is often a query problem. A query that scans a whole table gets slower as the table grows, and the usual response is a bigger instance.
The slow query log shows where to look. MySQL writes any statement slower than long_query_time to it, and PostgreSQL's pg_stat_statements extension ranks queries by total time. Adding the missing index and archiving old rows can delay the next tier.
Move Steady Workloads to a VPS or Bare Metal
Large clouds charge for elasticity, and a workload that runs at the same size all year doesn't use it. A VPS or dedicated server with a flat monthly price and included traffic can cost less for that kind of work.
The trade is operational work, because backups, failover, patching and monitoring become your job. We'd only make this move with someone on the team who has run servers before. Our VPS hosting comparison covers the providers.
When to Scale Up vs. Scale Out
Scaling up means a bigger server. Scaling out means more servers behind a load balancer.

We'd scale up first. A resize needs no change to the application, and on most providers it is a short restart.
Scaling out adds parts that each carry a bill: a load balancer, shared session storage, shared file storage and a deploy process that updates every server. These are the cases where it earns that cost:
- Redundancy: the product can't afford downtime when one server fails.
- Zero-downtime deploys: one server takes traffic while the other updates.
- Latency: customers on other continents need a server near them.
- Size: the workload has outgrown the largest instance that makes sense.
When an app is slow at modest traffic, we'd look at caching and queries before adding a server.
Billing Alerts and Budgets
Every provider can warn you when spend crosses a line. Almost none of them will stop the spending for you.
- AWS Budgets: alerts on actual or forecasted cost, and forecast alerts need about 5 weeks of usage data. A budget stops nothing unless you add a budget action, which can apply an IAM policy or target specific EC2 and RDS instances.
- AWS Cost Anomaly Detection: uses machine learning to flag unusual spend and its likely cause.
- Google Cloud: an alerts-only budget does not cap usage or spending. Spend cap budgets exist only for the services that support them.
- Azure: budgets send notifications and leave resources running. Cost data usually arrives 8 to 24 hours late.
- DigitalOcean: a spend alert is a notification, and it doesn't limit how much you can use.
- Hetzner: traffic notifications go out at 75% and 100% of the included allowance, and they don't stop usage.
Our advice is to set 3 alerts on the day you open the account, at 50%, 80% and 100% of the monthly amount you expect. A forecast alert is worth adding where the provider offers one. Alerts lag behind real usage, so the first one should be low enough to leave time to act.
A Monthly Cost Review
Alerts catch spikes, and a monthly review catches the slow growth that alerts miss. For a small product, 15 minutes is enough. This is what we'd check:
- The total against last month and against MRR
- The 3 lines that grew the most, with a reason for each
- Anything running that has no named owner
- Subscriptions that duplicate each other
- Cost per customer, recalculated
Tracking infrastructure share of revenue next to net revenue retention and your other SaaS numbers shows whether growth is getting cheaper or more expensive to serve.
When Cost Work Is Premature
Cutting costs takes engineering time, and that time has a price too. For an early product with a small bill, the same hours are usually worth more in the product.
A quick test helps here. We'd multiply the monthly saving by 12 and compare it with the time the change takes. For example, saving $150 a month is $1,800 a year, and a change that takes an engineer a week probably costs more than that.
The low-effort list is the exception, because deleting idle resources and setting alerts take an afternoon at any stage. We'd leave commitments and architecture changes until infrastructure share of revenue is high or rising faster than revenue.
For a micro-SaaS, our breakdown of micro-SaaS costs and margins shows what a lean monthly stack includes.
What We'd Do First
If the bill feels too high and you aren't sure where to start, we'd begin with the 2 numbers: infrastructure share of revenue and cost per customer. They take about an hour with last month's invoices, and they tell you whether there is a problem at all.
From there, we'd set the alerts, clear the idle resources and right-size, then look at commitments once usage has been steady for a few months. If your stack runs on AWS and the bill is the worry, our AWS hosting setup service covers EC2, RDS, CloudFront, monitoring and backups.
Frequently Asked Questions
What percentage of revenue should a SaaS spend on infrastructure?
There is no single correct figure, because it depends on what the product does, and gross margin is the useful anchor. Benchmarkit's 2026 report put the median software gross margin at 80% for 2025, and hosting shares the remaining 20% with support and payment fees. Products that run heavy AI or media workloads spend a larger share. We'd track the share every month and act when it rises while revenue grows.
How do I calculate infrastructure cost per customer?
The sum is last month's total infrastructure cost divided by the number of paying customers. Repeating it with only the variable lines, such as API usage, email and data transfer, shows what one more customer costs. If usage varies a lot between accounts, we recommend calculating it for each plan.
How do I estimate server costs before launching a SaaS?
We'd price the smallest setup that runs the product in the provider's pricing calculator. The next step is to pick the thing each customer consumes, such as requests, storage or AI tokens, and model the bill at 100, 1,000 and 10,000 customers. The estimate won't be exact, but it shows which line grows fastest.
Do cloud budget alerts stop my spending?
In most cases, no. AWS, Google Cloud, Azure and DigitalOcean all describe their standard budgets and spend alerts as notifications. AWS can act on a budget if you set up a budget action, Google Cloud offers spend cap budgets for some services, and elsewhere you need your own automation. It is wise to treat alerts as a warning and keep a monthly review as well.
Does a stopped server still cost money?
Usually, yes. A stopped AWS EC2 instance has no compute charge, but its disks and Elastic IP addresses are still billed. DigitalOcean and Hetzner bill a powered-off server until you destroy or delete it. A stopped Amazon RDS database still pays for storage and backups, and RDS starts it again after 7 days.
Are Savings Plans or reserved instances worth it for a startup?
They are worth it for the part of your usage that has been steady for several months. The discounts are large, up to 72% on AWS and Azure at the time of writing, but you pay for the commitment even if you shrink or move. We'd cover the baseline and keep growth on on-demand pricing.
Is a VPS cheaper than AWS for a small SaaS?
Often, for a workload that stays the same size. A VPS has a flat monthly price that includes a traffic allowance, which makes the bill predictable. AWS bills each resource separately and offers managed services a VPS doesn't have. We'd choose by what the team can operate, because backups, failover and patching are your job on a VPS.
Can serverless reduce SaaS hosting costs?
For spiky or scheduled work, yes, because you pay per request and nothing while idle. Webhooks, cron jobs and endpoints with uneven traffic are good fits. For steady, high-volume traffic, a server that runs all day usually costs less per request, so we'd compare both on your own numbers.
How often should I review cloud costs?
Once a month is enough for most small SaaS products, and 15 minutes covers it. We'd compare the total with last month and with MRR, look at the lines that grew the most and remove anything nobody owns. Alerts handle the spikes in between.



