Buy vs rent
Before the cloud, launching a web app meant buying servers: pay thousands up front, wait weeks for delivery, install them in a rented rack, hire someone to replace failed disks at 3 a.m. That up-front spending is called capital expenditure (capex).
The cloud converts it to operational expenditure (opex): no purchase, no waiting, pay a bill each month for exactly what you used, stop paying the moment you turn things off.
Renting is not always cheaper per unit. AWS charges a markup for the flexibility. The reason companies pay it is what the flexibility lets them do, which the next example puts in numbers.
Code exercise · bash
Compare buying a $1,200 server (plus $30/month for power and hosting) against renting a similar cloud server for $25/month, over 3 years. Run it and look at who wins.
Elasticity: the real reason
The bigger win is elasticity: changing how much you rent, minute by minute.
Imagine a ticket shop that needs 2 servers most days and 100 servers for one hour when a tour goes on sale. Buying means owning 100 servers that sit idle 99.9% of the time. Renting means paying for 100 servers for one hour, then going back to 2.
But the arithmetic flips for big, steady workloads. If you know you will run the same 500 servers flat-out for years, owning gets cheaper than renting, which is why a few large companies famously moved off the cloud. For a small or growing app, rent wins.
Quiz
A startup's traffic is 10× higher every Saturday night than the rest of the week. Which cloud property is the strongest argument for them?
Code exercise · bash
Your turn. Renting an expensive server costs $70/month. Buying it costs $1,200 up front plus $30/month to run. Complete the loop so it finds the first month where the total cost of buying is LESS than the total cost of renting, then prints it. Expected: month 31.