EC2 Hibernate
Learn how EC2 Hibernate preserves in-memory state for faster instance startup and understand its requirements and limitations.
What You'll Learn
Beyond Stop and Terminate
You're familiar with stopping and terminating EC2 instances. When you stop an instance, data on EBS volumes is preserved, but the RAM contents are lost. When you start it again, the OS boots fresh and applications must reinitialize. EC2 Hibernate offers a third option: preserving the in-memory (RAM) state so your instance can resume exactly where it left off.
Key Point
EC2 Hibernate preserves RAM state, allowing instances to resume instantly without cold boot or application re-initialization.
Instance Lifecycle Actions
| Action | EBS Data | RAM Data | On Restart | |
|---|---|---|---|---|
| Stop | Preserved | Lost | Full OS boot, apps reinitialize | |
| Terminate | Root volume deleted* | Lost | Instance is gone | |
| Hibernate | Preserved + RAM dump | Preserved | Instant resume, no boot |
*Unless DeleteOnTermination is set to false for the root volume
How Hibernate Works
When you hibernate an instance, the in-memory contents (RAM) are saved to the root EBS volume. The instance then shuts down. When you start the instance again, the EBS volume is restored, the RAM contents are loaded back into memory, and the instance resumes operation. The OS is not stopped or restarted—it picks up exactly where it left off.
Key Point
Hibernate saves RAM to the encrypted root EBS volume, enabling near-instant resume without OS boot.
Hibernate Process Flow
How EC2 Hibernate saves and restores instance state
Running Instance
RAM contains active data
Hibernate Command
User initiates hibernate
RAM → EBS
Memory saved to root volume
Stopped State
Instance appears stopped
Start Command
User starts instance
EBS → RAM
Memory restored
Resumed Instance
Continues from exact state
Root Volume Must Be Encrypted
The root EBS volume MUST be encrypted for Hibernate to work. This is a security requirement because sensitive RAM data (potentially including passwords, keys, or other secrets) is being written to disk.
Use Cases for EC2 Hibernate
- Long-running processes that would take time to restart
- Applications with expensive initialization (loading large datasets into memory)
- Services that take time to warm up caches
- Development environments you want to pause and resume quickly
- Saving the exact RAM state for later analysis or continuation
Hibernate Requirements and Limitations
EC2 Hibernate has specific requirements for instance types, RAM size, AMIs, and storage. Understanding these limitations helps you plan which workloads can benefit from Hibernate and which cannot.
Key Point
Hibernate has specific requirements: encrypted EBS root, under 150GB RAM, supported instance families, and maximum 60-day hibernation period.
Hibernate Requirements
| Requirement | Details | |
|---|---|---|
| Instance Families | C3, C4, C5, I3, M3, M4, M5, R3, R4, R5, T2, T3, and more | |
| RAM Size | Must be less than 150 GB | |
| Instance Size | Not supported for bare metal instances | |
| Root Volume | Must be EBS (not instance store), encrypted, and large enough for RAM | |
| AMI Support | Amazon Linux 2, Amazon Linux, Ubuntu, RHEL, CentOS, Windows | |
| Purchase Options | On-Demand, Reserved, and Spot Instances |
60-Day Maximum
An instance can NOT be hibernated for more than 60 days. If you need to keep an instance hibernated longer, you must start it and hibernate it again to reset the timer.
Root Volume Sizing
Ensure your root EBS volume is large enough to store the RAM contents. If you have 64 GB of RAM, your root volume needs at least 64 GB of free space beyond what the OS uses.
Hibernate for ML Model Loading
Problem
Your ML inference application takes 15 minutes to load a large model into memory on startup. You want to reduce startup time.
Solution
Why This Works
Hibernate preserves the loaded ML model in RAM, eliminating the expensive model loading process on each restart. This is ideal for workloads with significant initialization overhead.
Enabling Hibernate on an Instance
Prepare the AMI
Use a supported AMI (Amazon Linux 2, Ubuntu, Windows, etc.) that has the hibernate agent installed or install it manually.
Configure Root Volume
Ensure the root EBS volume is encrypted. You can enable encryption at launch time or use an encrypted AMI.
Enable Hibernate at Launch
When launching the instance, enable 'Stop - Hibernate behavior' in the Advanced details section.
Size the Volume
Make sure the root volume has enough space for the OS plus the full RAM contents.
Hibernate When Ready
Use the console, CLI, or API to hibernate the instance. It will appear in 'Stopped' state.
Pause & Ponder
When would EC2 Hibernate be more appropriate than a regular Stop, and vice versa?
- •Consider the time and resources needed to reinitialize your application
- •Think about cost implications—you still pay for EBS storage while hibernated
- •What about applications with dynamic data that shouldn't be frozen?
Ready to Start Learning?
Dive deeper into this lesson with our interactive learning experience. Complete the quiz and earn 60 XP!
Start This LessonContinue Your Journey
EC2 Instance Type Management
Learn how to change EC2 instance types and understand the requirements for resiz...
Lesson 2EC2 Placement Groups
Master EC2 placement group strategies to optimize instance placement for perform...
Lesson 3EC2 SSH Connectivity & Troubleshooting
Master SSH connections to EC2 instances, including traditional SSH, EC2 Instance...