
EC2 Hibernate: Explanation with Examples
π What is EC2 Hibernate?
EC2 Hibernate is a feature that preserves the in-memory state of an instance when it is stopped, allowing you to resume from where you left off without losing data. It works like hibernation in a laptop, where active applications and processes remain intact when the machine is powered back on.
π How EC2 Hibernate Works?
1οΈβ£ When an instance is put into hibernation, its RAM contents are saved to the root volume.
2οΈβ£ The instance is stopped, and EBS volumes remain attached.
3οΈβ£ When you start the instance again, it restores the saved RAM state, so applications resume running from the exact same point before hibernation.
π Example Scenario: Using EC2 Hibernate
Scenario 1: Running a Long Process
Imagine you are running a data processing job on EC2 that takes multiple hours to complete. Instead of stopping and restarting the instance (which would require restarting the job), you can:
β
Hibernate the EC2 instance when needed.
β
Resume it later without losing progress.
Scenario 2: Application Servers with Preloaded Data
β A financial trading application with preloaded datasets can be hibernated overnight and resumed instantly in the morning without reloading data.
Scenario 3: Development Environments
β Developers can hibernate EC2 instances running development tools and resume their work the next day without rebooting everything.
π Key Features of EC2 Hibernate
β Saves RAM state and resumes applications instantly.
β Faster startup compared to rebooting.
β No additional cost apart from standard EBS storage.
β Supported on Amazon Linux, Ubuntu, Windows, RHEL (with specific instance types).
π Limitations of EC2 Hibernate
π« Only supports instances with up to 150 GB RAM.
π« Requires encrypted EBS root volume.
π« Only EBS-backed instances are supported.
π« Not available on bare metal or burstable instances (T2, T3, etc.).
π How to Enable EC2 Hibernate?
Step 1: Check Instance Compatibility
- Instance type should support hibernation (e.g., C5, M5, R5, T3).
- Root volume should be EBS-backed and encrypted.
Step 2: Enable Hibernate Option
- While launching the EC2 instance, go to Advanced Details.
- Select Enable Hibernation under Shutdown Behavior.
Step 3: Hibernate the Instance
Use the following AWS CLI command:
aws ec2 stop-instances --instance-ids i-1234567890abcdef0 --hibernate
Step 4: Start the Instance Again
aws ec2 start-instances --instance-ids i-1234567890abcdef0
π Difference Between Stop, Terminate, and Hibernate
Action | What Happens? | RAM State Preserved? | EBS Volume Attached? | Use Case |
---|---|---|---|---|
Stop | Instance shuts down | β No | β Yes | Save storage, restart later |
Terminate | Instance is deleted | β No | β No | No longer needed |
Hibernate | Instance saves RAM & stops | β Yes | β Yes | Resume workloads instantly |
π Why Use EC2 Hibernate?
β
Faster startup β Resume workloads instantly.
β
Cost savings β Pay only for storage, not compute.
β
Data retention β No need to reload applications after every reboot.
π‘ Need help enabling EC2 Hibernate for your workloads? Contact us today! π