Lesson 2 of 4 Compute Optimization

Eliminating Idle Resources and Scheduling

Waste removal is the quickest optimization with the least risk. This lesson explains how to find idle and orphaned resources, how to remove them safely and how scheduling non-production environments removes most of their running hours.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish idle resources from orphaned resources.
  • Describe a safe process for removing waste.
  • Calculate the reduction in running hours from a schedule.
  • Explain the benefits of ephemeral environments.

Idle resources

An idle resource is running and charging but doing little or no useful work. Typical examples are test servers left on after a project, databases for retired features, load balancers with no healthy targets, development clusters with no deployments and GPU notebooks left running after an experiment. Idle resources show near-zero CPU, network and request activity over a sustained period, such as two weeks.

Idle detection needs care. A disaster recovery standby or a server that runs a monthly job can look idle most of the time and still be needed. Ownership tags and a conversation with the owner distinguish genuinely unused resources from rarely used ones.

Orphaned resources

An orphaned resource remains after the thing it served was deleted. The following list describes the most common types.

  • Unattached block storage volumes: left behind when instances are terminated without deleting their volumes.
  • Old snapshots and machine images: accumulated by backup jobs or deployments with no retention policy.
  • Unused public IP addresses: many providers charge for public IPv4 addresses, and some charge more when they are not attached.
  • Idle load balancers and gateways: kept after the application behind them was removed.
  • Stale container images and artifacts: stored in registries indefinitely.

Orphaned resources are often small individually but numerous, so their total can be large. They are good candidates for automated detection and, after a grace period, automated clean-up.

Sort into groups

Idle or orphaned?

Exam skills 7.1.2

Classify each kind of waste.

Log in to try this activity Interactive activities are free with an account.

Removing waste safely

Deletion is irreversible, so a safe process matters more than speed. A common approach is to notify the owner, wait a grace period, stop rather than delete where possible, take a final snapshot of any data that might be needed, and only then delete. Resources with an exception tag, such as a legal hold, are skipped. When no owner can be found, a resource can be stopped and tagged with a deletion date; if nobody objects before that date, it is deleted.

Put in order

Removing waste safely

Exam skills 7.1.2 · 8.1.1

Put the steps for removing apparently orphaned resources in order.

Log in to try this activity Interactive activities are free with an account.

Scheduling non-production environments

Development, test and staging environments are usually used during working hours, yet many run around the clock. A week has 168 hours. An environment that runs from 08:00 to 20:00 on weekdays runs 60 hours, so scheduling removes 108 hours, about 64% of its running time and of its time-based cost. The following table shows common schedules.

ScheduleRunning hours per weekReduction in running hours
Always on1680%
Weekdays 07:00 to 19:00 (12 hours)60About 64%
Weekdays 08:00 to 18:00 (10 hours)50About 70%
On demand only, started by developersVariesOften more than 80%

Schedules are usually driven by tags, such as schedule=office-hours, and implemented with provider schedulers or automation. Teams need an easy way to override a schedule when they work late or across time zones. Only time-based charges fall: storage attached to stopped instances continues to be charged.

The following diagram compares running hours and cost before and after scheduling.

Scheduling a non-production environment used on weekdays from 08:00 to 18:00. It needs to run 50 of 168 hours a week, about 30% of the time, so its time-based cost falls by about 70%. Storage is charged whether the environment runs or not, so it does not change.
Band lengths are proportional.
Fill in the value

Scheduling savings

Exam skills 7.1.2

Calculate savings from scheduling non-production environments.

Log in to try this activity Interactive activities are free with an account.

Ephemeral environments

A step beyond scheduling is to create environments only when needed. Ephemeral environments are created from infrastructure as code for a pull request or a test run and destroyed afterward. They cost nothing when not in use, cannot drift from the production configuration and avoid the accumulation of long-lived test resources.

Worked example

A staging environment

A staging environment costs USD 9,000 a month and runs continuously. The team uses it on weekdays from 08:00 to 18:00 in one time zone. About USD 1,000 of the cost is storage. What would scheduling save?

Time-based cost is USD 8,000. A weekday 10-hour schedule runs 50 of 168 hours, about 30% of the time, so time-based cost falls to about USD 2,380 and the saving is about USD 5,600 a month. Storage continues at USD 1,000, so the new monthly cost is about USD 3,400. The team should provide an override for late work and confirm that no overnight test jobs depend on the environment.

Worked example

The snapshot pile

An account holds 14,000 snapshots costing USD 7,200 a month. Many belong to volumes that no longer exist. The backup policy requires 35 days of retention. What should the engineer do?

Snapshots older than 35 days that are not covered by another requirement, such as a legal hold or a monthly archive, are outside the policy. The engineer should confirm the requirements with the owners and the security team, delete out-of-policy snapshots in stages, and apply an automated retention rule so that the pile does not rebuild. Snapshots of deleted volumes deserve particular attention, because nobody is likely to restore them.

Check yourself

When an instance is stopped by a schedule, which of its charges continue?

Show answer

Charges for attached storage, such as block volumes, and any other resources that are not time-based compute, such as reserved public IP addresses, continue.

Exam Tips

Remember for the exam

  • Idle resources run with little useful work; orphaned resources outlive what they served.
  • Notify owners, use a grace period and snapshot before deleting.
  • A 12-hour weekday schedule removes about 64% of running hours; storage still charges.
  • Ephemeral environments cost nothing when not in use.