EBS Volumes and Instance Store
Inkwell stops its server overnight to save money. In the morning the order database is fine, but a folder of processed images has vanished. Nothing crashed. The two folders simply lived on two different kinds of disk, and only one of them is meant to outlast a stop.
The rule
EBS survives a stop; instance store does not.
An EC2 instance can use two kinds of block storage.
Amazon EBS (Elastic Block Store) volumes are network-attached drives. Each volume is its own resource with its own lifetime:
- Data survives stopping and starting the instance.
- A volume can be detached and attached to another instance in the same Availability Zone.
- Snapshots are point-in-time copies, stored durably by AWS and incremental after the first. From a snapshot you can build a new volume, even in another zone or Region.
- Types include gp3 (general-purpose SSD, the usual default), io2 (provisioned-IOPS SSD for demanding databases), and st1 and sc1 (cheaper hard-disk types for large sequential data).
- The root volume is deleted when the instance is terminated, by default. Extra volumes you attach are kept by default. Both are settings you can change.
Instance store is disk physically attached to the host machine. It is very fast and included in the price of the instance types that offer it, but it is ephemeral: data survives a reboot, and is lost when the instance stops, hibernates or terminates, or if the underlying disk fails.
The shortcut
Ask "Would I be upset if this vanished at the next stop?" Yes → EBS, with snapshots. No, it is scratch data I can rebuild → instance store is fine and fast.
The order database
Losing it would be a disaster. EBS gp3 volume, with a daily snapshot.
Two traps. First, a reboot does not wipe instance store, so a quick test can fool you into trusting it; a stop will. Second, an EBS volume is tied to its zone, so you cannot attach a volume in ap-south-1a to a server in ap-south-1b.
Drills
Answer fast — trust the rule.
Inkwell stops and starts its server. What happens to data on its EBS volume?
Which event does instance store data survive?
A volume sits in ap-south-1a. Can it be attached directly to a server in ap-south-1b?
By default, what happens to an instance's root EBS volume when the instance is terminated?
Remember
- EBS survives a stop; instance store does not.
- Would I be upset if it vanished? Then EBS with snapshots.
- Traps: reboots do not prove instance store is safe, and EBS volumes are tied to one AZ.
