Cloud economics and portability
Use the same workload and units
Cloud economics compares total cost under explicit workload and quality assumptions. Consumption billing may use input/output tokens, images, requests or compute time; dedicated capacity may bill while idle. AWS lists different Bedrock and SageMaker AI pricing dimensions [1,2]; Google has training and inference pricing categories [8]. For a hypothetical FAQ workload, assume equal validated task quality and capacity in both options, an effective per-request rate of 2 cents, and a dedicated service costing 150 cents per billed hour for 10 hours plus 100 cents of fixed overhead. These are invented user-editable values, not current AWS, Microsoft or Google prices. In a real worksheet derive the effective request rate from observed usage, model-specific input/output units, cache charges, failed calls and tool fees. Normalize currency, billing window and tax assumptions before comparison.
Compute and interpret cost
Use integer cents to avoid floating-point rounding in this simple model. The usage total is request count times effective request price. The dedicated total is billed hours times hourly rate plus fixed overhead, including idle time. At 1,000 requests the two totals are 2,000 and 1,600 cents; dedicated is cheaper under the stated assumptions. At 800 requests both cost 1,600 cents. At 100 requests consumption costs 200 cents. The function rejects negative and non-integer amounts, including booleans. Real fractional-cent prices require a smaller integer unit or decimal arithmetic with an explicit rounding policy. This comparison excludes taxes, variable dedicated costs, data transfer, storage beyond the fixed overhead, support and migration; include them when relevant. A cheaper but ineligible option is never selected.
def compare_cost(requests, request_cents, hours, hourly_cents, overhead_cents): # All amounts are hypothetical integer cents, not provider quotations. values = (requests, request_cents, hours, hourly_cents, overhead_cents) if any(type(x) is not int or x < 0 for x in values): raise ValueError("nonnegative integers required") usage = requests * request_cents dedicated = hours * hourly_cents + overhead_cents return {"usage": usage, "dedicated": dedicated, "cheaper": "usage" if usage < dedicated else "dedicated" if dedicated < usage else "tie"}
print(compare_cost(1000, 2, 10, 150, 100))print(compare_cost(800, 2, 10, 150, 100))print(compare_cost(100, 2, 10, 150, 100))Find the break-even point
For fixed dedicated cost F and a positive per-request consumption rate r, solve n*r >= F for the first whole request count n. Integer ceiling division gives (F+r-1)//r. If F=0 the answer is zero, even when r=0; if F>0 and r=0 there is no finite crossover, represented by None. With F=1,600 and r=2 the crossover is 800; with F=1,601 it is 801, where dedicated is already cheaper rather than tied. This assumes a fixed time window, sufficient dedicated capacity and no variable dedicated charge. If dedicated per-request cost is d, the positive savings slope is r-d; if that is nonpositive and fixed costs are positive there is no crossover. If demand exceeds capacity, add capacity steps and recompute. Compare pessimistic, expected and optimistic workloads and include cost per successful task, not merely per request.
def break_even(fixed_cents, request_cents): # First whole request count at which dedicated cost is no higher. if any(type(x) is not int or x < 0 for x in (fixed_cents, request_cents)): raise ValueError("nonnegative integers required") if fixed_cents == 0: return 0 if request_cents == 0: return None return (fixed_cents + request_cents - 1) // request_cents
print(break_even(1600, 2))print(break_even(1601, 2))print(break_even(1600, 0))Keep portability deliberate
Vendor lock-in may come from proprietary tools, embeddings, orchestration state, identity, observability, data export restrictions and model behavior. Use a versioned application contract and provider adapters for common operations, while preserving explicit extensions for unique features instead of pretending all APIs behave alike. Keep approved source documents, evaluation sets, prompt versions and data lineage exportable. Test fallback on the same held-out tasks, including refusals, grounded responses, latency and cost. Document switching effort, egress, retraining or reindexing, and the rollback path. Multi-provider operation adds duplicated security reviews, integration tests and operational overhead. Single-provider may be preferable when those costs outweigh resilience or feature benefits. Choose using an architecture decision record, not a promise that portability is free.
Apply spend controls and practice
Cloud budgets and alerts are notifications or configured actions, not guaranteed hard spend caps. AWS explicitly notes notification delay [9]. Use independent application-side admission and reservation limits, account and service quotas, bounded retries, concurrency limits, access restrictions and explicit shutdown procedures. Reconcile actual billing and delayed usage; neither an app budget nor a quota is a guarantee of zero further charges. In the worksheet, vary hourly rate and request count, then record the threshold, capacity assumption, missing charges and selected eligible candidate. Add a fallback decision when an approved endpoint fails and an unapproved endpoint is healthy. Document owners for access, cost and quality. Do not create accounts, cloud resources or API requests for this exercise; actual model, region, price, quotas, data terms and billing verification are required before a real deployment.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Cloud economics and portability quiz
Assess cloud service eligibility, residency, economics and portability.
What is the dedicated total for 10 hours at 150 cents plus 100 cents?
What is the first whole request count for F=1601 and r=2?
What if request price is zero and fixed cost positive?
What is an important portability cost?
Are cloud billing alerts guaranteed hard caps?