Module 01 · Lesson 12 of 14Free
Cost-aware design: avoiding unnecessary infrastructure
- Level
- Intermediate
- Topic
- System design fundamentals
- Reading time
- 18 min
When you finish this page you can
- Build a cost model that connects resource usage to a useful product outcome.
- Distinguish spare capacity from waste using peak demand and service requirements.
- Compare infrastructure savings with implementation and operating costs.
- Set measurable conditions for adding, removing or changing infrastructure.
Builds on 5 lessons
Start with lesson 515 minVideo lesson · coming soon
’s app server shows about 3% CPU usage during normal traffic. Someone proposes halving its size to save ₹3,000 a month, just before the festival sale.
At the sale’s opening, that smaller server would receive more CPU work than it could finish.
How do you reduce infrastructure cost without removing capacity or safeguards the product actually needs?
Count the whole workload
Kartly remains at its one-server stage: one app server with 8 CPU cores and one PostgreSQL database. It handles about 50 requests a second normally. The festival’s first minute reaches 1,000 requests a second.
Before comparing machines, draw a boundary around the costs you mean. Otherwise, moving work can look like saving money.
A new service reduces Kartly’s app-server bill by ₹2,000, but adds ₹3,000 in service charges. Has the design become cheaper?Show answer
Diagram not drawn yet: kartly-cost-boundary.svg
Customers send requests to Kartly’s app server, which queries PostgreSQL and returns responses. The app also reads product files and sends diagnostic logs to a logging service. A workload boundary includes the app, database, files, logs and outbound delivery charges.
Here is an illustrative monthly budget. These amounts are assumptions for this lesson, not provider prices.
| Cost item | What we count | Monthly estimate |
|---|---|---|
| App server | Compute allocation | ₹6,000 |
| PostgreSQL | Database compute and management | ₹9,000 |
| Database storage and backups | Allocated space and retained copies | ₹1,000 |
| Product files | Stored images and other files | ₹2,000 |
| Diagnostic logs | Ingestion, storage and queries | ₹2,000 |
| Outbound delivery | Billable data sent to customers | ₹2,000 |
| Total | This workload boundary | ₹22,000 |
The app server is not even half the bill. Removing half its cost cannot halve the workload’s cost.
This table excludes payment-provider fees, taxes and staff time. Those exclusions make the model narrower, not wrong. Record them so nobody mistakes infrastructure cost for total business cost.
AWS recommends attributing spending to workloads and comparing it with the business output they deliver. That is a better starting point than comparing individual machine prices.1
The boundary tells you what to count. You still need to know what makes each amount grow.
Turn actions into billable usage
A cost model connects product behavior to quantities, then quantities to charges.
Capacity estimation provides the usage estimates. Here, attach a billing rule to each estimate.
Some costs are fixed within a chosen allocation. Others change with usage. A third group changes in steps when you cross a capacity limit.
| Billing shape | In this scenario | What changes the bill |
|---|---|---|
| Fixed allocation | App-server rental | Changing the allocation |
| Usage-based | Outbound delivery | Sending more billable bytes |
| Stepwise | Database capacity tier | Moving beyond the current tier |
Lower CPU usage does not reduce a fixed server rental. It creates an opportunity to choose a smaller allocation, if that allocation still meets requirements.
For outbound delivery, suppose Kartly sends 250 GB of billable data in the month. Assume a flat rate of ₹8 per GB.
Calculate the delivery charge
250 GB/month × ₹8/GB = ₹2,000/month
This reproduces the delivery line in our scenario budget.
Change the delivered quantity
125 GB/month × ₹8/GB = ₹1,000/month
Halving billable bytes saves ₹1,000 under this assumed pricing rule.
Do not equate that quantity with all application traffic. Measure which bytes the billing boundary includes. Images, API responses and internal calls may have different charging rules.
A billing record should therefore carry a quantity, unit, rate and scope. “250 GB of outbound delivery” is useful. “Network: ₹2,000” gives you less to investigate.
Next, connect the total to something customers successfully achieve.
Price a useful product outcome
Kartly receives 5,000 orders a day at this course stage. For this calculation, assume a 30-day month with the same daily volume.
Count the monthly outcome
5,000 orders/day × 30 days = 150,000 orders
Use recorded orders, not checkout button taps. A tap that fails to create an order is not the same outcome.
Allocate infrastructure cost
₹22,000/month ÷ 150,000 orders/month ≈ ₹0.15/order
This is infrastructure cost per recorded order across our stated boundary.
Test lower demand
₹22,000/month ÷ 75,000 orders/month ≈ ₹0.29/order
If the bill stays unchanged but orders halve, the allocated cost per order roughly doubles.
This is a : cost divided by a useful unit of output. It helps separate healthy growth from declining efficiency.
Suppose next month’s bill rises to ₹26,000. If Kartly records 200,000 orders, the allocated cost is ₹0.13 per order. The total increased, but this measure of efficiency improved.
That does not prove the change caused the improvement. Traffic mix, promotions and order conversion may also have changed.
Nor does ₹0.15 mean one extra order costs ₹0.15. The existing server might handle it without a larger allocation. The average cost allocates shared spending; the extra cost of another order can differ.
Choose the denominator carefully. Cost per request can improve when a bug generates more requests without helping anyone. AWS’s efficiency guidance focuses on business output for this reason.1
Now the opening proposal has a clearer goal: reduce the bill without reducing successful outcomes.
Idle capacity can be necessary
The proposal relies on a common belief: low average CPU usage means the server is too large.
Kartly’s product-page request uses about 5 ms of CPU work. Its database and pricing waits are separate from that CPU time, as covered in Server concurrency.
For this simplified capacity check, assume every request has that CPU cost.
Estimate normal CPU demand
50 requests/s × 0.005 CPU-seconds/request = 0.25 CPU-seconds/s
Across 8 cores, this is about 3% of the available CPU capacity.
Estimate festival CPU demand
1,000 requests/s × 0.005 CPU-seconds/request = 5 CPU-seconds/s
The sale needs the equivalent of 5 fully busy cores before allowing for other work.
Check the proposed smaller server
5 CPU-seconds/s ÷ 4 CPU-seconds/s = 125% of capacity
Four cores cannot finish this CPU work as fast as it arrives.
This is a lower-bound resource check, not a benchmark. It does not prove the larger server meets response-time targets. The database, memory and connection limits still matter.
Should Kartly halve the app server’s size to save ₹3,000 a month?
Use the smaller server throughout the month.
Normal traffic fits, but the stated festival workload exceeds the smaller server’s CPU capacity. Customers wait or fail to open product pages.
Keep the current server until a smaller allocation passes the required workload.
The existing allocation passes this CPU check and avoids a capacity change immediately before the sale. A representative load test must still validate the complete system.
Change capacity ahead of scheduled peaks.
A smaller baseline could work if larger capacity becomes ready before the fixed sale time. The team must account for provisioning, deployment and rollback.
Why this choice
The problem is uneven demand, not unexplained waste. Keeping the existing server is the simplest option that passes this calculation.
Scheduled changes become attractive if the saving pays for their implementation and operation. They also need a tested fallback when capacity is not ready.
Change the choice when measurements show lower CPU work, lower peak demand or a proven capacity-change process. Do not change it because the monthly average looks small.
Vertical and horizontal scaling covers the capacity mechanisms. Cost analysis decides whether their benefit justifies using them.
Resource choices should follow workload patterns and environment requirements, rather than one number. Google Cloud’s guidance makes that distinction explicit.
Capacity protects a known peak. Unbounded data growth needs a different control.
Bound data before adding storage
Assume Kartly generates 2 GB of diagnostic logs daily. The current policy keeps them searchable for 90 days.
These are additional scenario assumptions. The calculation concerns diagnostic logs, not order records or backups.
Diagram not drawn yet: kartly-log-retention-cost.svg
Two independent panels show diagnostic-log retention. Keeping 2 GB daily for 90 days retains about 180 GB. Keeping the same daily volume for 14 days retains about 28 GB. Both panels exclude ingestion charges and assume expired logs are removed.
Estimate current retained volume
2 GB/day × 90 days = 180 GB
This is steady-state volume with constant arrivals and timely expiry.
Estimate shorter retention
2 GB/day × 14 days = 28 GB
The retained volume falls by 152 GB. Incoming logs remain unchanged.
The simplest implementation is a retention policy in the logging service. It expires data after the chosen age. The team should verify that expired data stops contributing to the relevant storage charge.
Choosing 14 days requires a product and operations answer: how far back must the team investigate failures? If support regularly investigates older incidents, shorter searchable retention may remove evidence they need.
An alternative is a short searchable window plus a longer archive. It trades cheaper storage for retrieval delay and retrieval charges. Compare the expected retrieval workload before choosing it.
For this scenario, choose shorter retention only after the team confirms its investigation needs. Keep order records, security records and backups under their own policies.
Microsoft recommends removing unnecessary data and resources as part of ongoing optimization. That guidance does not decide which Kartly records are unnecessary; the requirements do.3
A smaller stored volume is a measurable saving opportunity. Whether implementing it is worthwhile depends on the work it creates.
Include the team’s operating work
Suppose someone proposes replacing a managed logging service with a self-operated one. Assume the infrastructure saving would be ₹3,000 a month.
The replacement also needs upgrades, access controls, recovery procedures and someone responsible when searches stop working.
Microsoft’s cost model includes implementation, support and operational expenses, not only resource charges.3
Should Kartly replace the managed logging service to lower its bill?
Keep the managed service.
The infrastructure bill is higher, but the team avoids taking ownership of another service’s maintenance and recovery.
Operate the replacement service.
The proposed infrastructure bill falls by ₹3,000 a month, but implementation and recurring operating work become Kartly’s responsibility.
Why this choice
For this scenario, assume the migration takes 24 engineering hours. Use an internal planning value of ₹1,500 per hour. The one-time implementation cost is ₹36,000.
Ignoring recurring work, recovering that investment takes 12 months. If maintenance takes 2 hours monthly at the same planning value, it consumes the entire proposed saving.
Keep the managed service under these assumptions. Reconsider if the team already operates the replacement, savings grow substantially, or a required capability is missing.
Engineering time is not always an extra invoice. It is still time unavailable for checkout fixes or customer features. State that separately from cash spending.
Avoid treating unknown operating work as zero. List the work, name its owner and estimate a range.
Before implementing any saving, write a short decision record:
- What amount should fall, and why?
- What implementation and recurring work will appear?
- Which product targets must remain unchanged?
- What measurement would make us undo the change?
That record turns a price comparison into a decision you can review.
Make cost changes reversible
Cost work starts with the product requirements from Functional and non-functional requirements. A cheaper design that misses those requirements is not an equivalent design.
For each experiment, pair a cost measurement with a user-facing measurement.
| Proposed change | Cost measurement | Requirement to protect |
|---|---|---|
| Smaller app allocation | Compute charge | Response time and error rate under peak load |
| Shorter log retention | Stored volume and billed storage | Required investigation window |
| Smaller product images | Billable outbound bytes | Useful image quality |
| Fewer backup copies | Retained backup charge | Agreed recovery requirements |
Start with a limited change where possible. Compare equivalent workloads, rather than a quiet weekday against a festival launch.
Keep the previous configuration available. If response time or errors worsen beyond the agreed target, restore it and investigate.
Review forecast spending before month-end. In this scenario, the team chooses a ₹25,000 monthly infrastructure budget and assigns an owner to investigate forecast overruns. An alert starts a review; it is not a reason to stop accepting orders.
Google Cloud recommends different resource choices for production and development environments. Kartly could stop an unused development environment overnight without applying the same policy to its store.
Where this shows up
- Design: a fast product catalog page: compare added infrastructure with the database work and delivery cost it removes.
- Design: monitoring and SLOs for a service: connect operating measurements to the requirements cost changes must preserve.
The next lesson applies this restraint to a URL shortener on a single server: which requirements actually justify another component?
Common mistakes
Optimizing the most visible line. The app server may be easy to resize, but another cost may dominate. Rank opportunities by expected net benefit.
Buying future capacity without a trigger. “We might grow” gives no decision boundary. Name the workload or requirement that would justify the purchase.
Counting a discount as lower usage. A lower rate can reduce spending without improving resource efficiency. Track quantity and rate separately.
Removing safeguards to meet a budget. Backups and recovery capacity serve requirements. Renegotiate those requirements explicitly instead of silently weakening them.
Check your understanding
Kartly’s bill stays at ₹22,000, but recorded orders halve. Did its allocated infrastructure cost per order improve?Show answer
A smaller server has low average CPU usage, but the required peak needs 5 CPU-seconds each second. Can a 4-core allocation meet that CPU demand?Show answer
Kartly shortens log retention but sends the same volume of logs. Should you expect the ingestion charge to fall?Show answer
A replacement saves ₹3,000 monthly and takes ₹36,000 of implementation effort. Why is 12 months an optimistic payback estimate?Show answer
Summary
- Reduce cost by removing spending that does not help meet the workload’s requirements, not by choosing the lowest individual price.
- Model the whole boundary with quantities, billing units and rates.
- Track cost per useful outcome alongside total spending.
- Validate peak demand before removing spare capacity, and bound retained data according to its purpose.
- Include implementation and operating work, then measure each change against both cost and product targets.