Sub topic 11
Choosing a pricing model for each workload
This chapter assumes you know EC2 instance families, Regions, and Availability Zones. It also assumes you have met the three discount models: Reserved Instances (RIs), Savings Plans, and Spot Instances. Here you learn to pick one for a given workload.
Three questions to ask
Every workload can be judged on three traits. Each trait points toward a different model.
- Steadiness. Does the workload run at a predictable level for months or years? Steady load can be committed to. Spiky or short-lived load cannot.
- Flexibility. Will the instance family, size, Region, or operating system change? The more you expect to change, the broader the commitment must be.
- Fault tolerance. Can the workload survive losing an instance with two minutes of warning? If it can, Spot becomes an option.
Matching traits to models
| Workload trait | Best fit | Reason |
|---|---|---|
| Steady, and you may change families, Regions, or move to Fargate or Lambda | Compute Savings Plan | Applies across instance families, Regions, and compute services |
| Steady, and you will stay on one family in one Region | EC2 Instance Savings Plan | Deeper discount in exchange for narrower scope |
| Steady, and you need reserved capacity in one Availability Zone | Zonal Reserved Instance | A zonal RI reserves capacity as well as lowering the price |
| Fault-tolerant, stateless, or restartable | Spot Instances | Deepest discount, but AWS can reclaim the capacity |
| Short-lived, unpredictable, or still being sized | On-Demand | No commitment, no interruption risk |
Savings Plans and Spot are the usual first choices. Choose an RI mainly when you need its capacity reservation.
Worked examples
A web tier with steady traffic. The load rarely drops below a known floor. Commit to that floor with a Compute Savings Plan. Run the traffic above the floor on On-Demand or Spot.
A nightly batch job. It can be retried, and it does not matter which instance type runs it. This is a Spot workload. Use several instance types so a shortage of one type does not stall the job.
A database on a fixed instance type. It cannot be interrupted, and it will stay on one family for a year or more. An EC2 Instance Savings Plan or a Standard RI fits.
A new service with unknown demand. Stay on On-Demand until usage settles. Committing early risks paying for hours you do not use.
Common errors
- Committing to peak load. A commitment bills every hour whether you use it or not. Commit to the lowest steady level, not the highest.
- Using Spot for stateful work with no recovery path. If an interruption loses data or leaves a job half done, Spot is the wrong choice until the work is made restartable.
- Locking in a narrow plan too early. Choosing an EC2 Instance Savings Plan and then moving to another family leaves the commitment unused.
- Assuming a Savings Plan reserves capacity. It lowers the price only. If you need guaranteed capacity in a zone, you need a zonal RI or a capacity reservation.
Exercise
Exercise
A video-transcoding service processes queued files. Each job takes about ten minutes, failed jobs are simply retried, and any instance type with enough CPU will do. Which pricing model fits best, and why?
Show answer
Spot Instances. The work is fault-tolerant because jobs are short and retried, and it is flexible about instance type, so the service can diversify across types and absorb interruptions. This gives the deepest discount. A commitment would be wasteful if the queue is bursty.
Exercise
A company runs a payment API on m5 instances in one Region. Load never drops below 20 instances, and the team does not plan to change family for two years. The API cannot tolerate interruption. What would you commit to, and what would you do about load above 20 instances?
Show answer
Commit to the steady 20-instance floor with an EC2 Instance Savings Plan, or a Standard RI if capacity reservation is needed. The narrow scope earns a deeper discount, and the family is not expected to change. Serve the load above the floor with On-Demand, because the API cannot tolerate Spot interruption.