Effect of instance state on storage
Different EC2 instance state has different effect on storage attached to EC2 like EBS, EIS etc.
There are mainly four different state of EC2 instance
- Hibernate
- Terminate
- Stop
- Reboot
Before going further, let's dive into different storage that we cover here:
- EIS (Elastic Instance Storage) - physically attached to EC2 instance, can't be detached and attached to other instance. it's like heart(EIS) of a man(EC2) 😂
- EBS (Elastic Block Storage) - this is network attached , means storage is linked via network. it can be detached and attached to other instance. it's like clothes (EBS) of a man(EC2) 😅
- Root EBS - this is same EBS but store only system data necessary for booting up instance.
Let's see one by one and there effect on storage.
Hibernate
- Definition: Saves the in-memory state (RAM) to the root EBS volume, then stops the instance.
- Effect on Data Stored in Instance:
- Data in memory (RAM) is saved to EBS.
- Data on attached EBS volumes is preserved.
- Data on instance store (ephemeral storage) is lost.
- Effect on EBS, Instance Store (EIS), etc.:
- Root EBS volume must be encrypted to support hibernation.
- All attached EBS volumes remain attached and data is preserved.
- Instance store volumes are ephemeral and their data is lost.
Terminate
- Definition: Permanently deletes the instance and its associated resources.
- Effect on Data Stored in Instance:
- All data on the root EBS volume is lost unless you have a snapshot.
- All data on attached instance store volumes is lost.
- Data on other attached EBS volumes persists but the volumes must be detached manually if needed.
- Effect on EBS, Instance Store (EIS), etc.:
- Root EBS volume is deleted by default.
- Other attached EBS volumes persist and can be attached to another instance.
- Instance store volumes' data is lost.
Stop
- Definition: Halts the instance, releasing resources but preserving the root EBS volume.
- Effect on Data Stored in Instance:
- Data on the root EBS volume is preserved.
- Data on attached EBS volumes is preserved.
- Data on instance store volumes is lost.
- Effect on EBS, Instance Store (EIS), etc.:
- All EBS volumes remain attached and data is preserved.
- Instance store volumes are ephemeral and their data is lost.
Reboot
- Definition: Restarts the instance.
- Effect on Data Stored in Instance:
- Data on the root EBS volume is preserved.
- Data on attached EBS volumes is preserved.
- Data on instance store volumes is preserved.
- Effect on EBS, Instance Store (EIS), etc.:
- All EBS volumes remain attached and data is preserved.
- Instance store volumes remain attached and data is preserved.
Summary of Effects on Data and Storage
Action | Root EBS Volume | Attached EBS Volumes | Instance Store Volumes |
---|---|---|---|
Hibernate | Preserved | Preserved | Lost |
Terminate | Lost (unless snapshot) | Preserved (must detach) | Lost |
Stop | Preserved | Preserved | Lost |
Reboot | Preserved | Preserved | Preserved |
Explanation of EBS and Instance Store (EIS) Effects
- Amazon Elastic Block Store (EBS):
- Network-attached storage that persists independently of the lifecycle of the instance.
- Data on EBS volumes is preserved across stop, start, hibernate, and reboot actions.
- EBS volumes can be attached to other instances as needed.
- Snapshots can be taken for backup and recovery purposes.
- Note the behaviour of root EBS volume & attached EBS volume
- Instance Store (Ephemeral Storage):
- Physical storage that is directly attached to the host where the instance is running.
- Data on instance store volumes is ephemeral and is lost if the instance is stopped, hibernated, or terminated. only in reboot, it is preserved.
- Instance store volumes provide very high I/O performance but should be used only for temporary data that can be recreated.
Understanding these actions and their impacts helps in managing the EC2 instances effectively, ensuring data persistence where necessary and optimizing resource usage.