Lesson 7-AWS SysOps Administrator Associate

EC2 Hibernate

Learn how EC2 Hibernate preserves in-memory state for faster instance startup and understand its requirements and limitations.

13 Topics
5 Quiz Questions
60 XP Reward

What You'll Learn

1

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.

Comparison

Instance Lifecycle Actions

ActionEBS DataRAM DataOn Restart
StopPreservedLostFull OS boot, apps reinitialize
TerminateRoot volume deleted*LostInstance is gone
HibernatePreserved + RAM dumpPreservedInstant resume, no boot

*Unless DeleteOnTermination is set to false for the root volume

3

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
7

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.

Comparison

Hibernate Requirements

RequirementDetails
Instance FamiliesC3, C4, C5, I3, M3, M4, M5, R3, R4, R5, T2, T3, and more
RAM SizeMust be less than 150 GB
Instance SizeNot supported for bare metal instances
Root VolumeMust be EBS (not instance store), encrypted, and large enough for RAM
AMI SupportAmazon Linux 2, Amazon Linux, Ubuntu, RHEL, CentOS, Windows
Purchase OptionsOn-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

1. Launch instance with encrypted EBS root volume 2. Start application and load model into memory 3. Hibernate the instance when not in use 4. When needed, start the instance—model is already in memory 5. Application is ready in seconds instead of 15 minutes

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

1

Prepare the AMI

Use a supported AMI (Amazon Linux 2, Ubuntu, Windows, etc.) that has the hibernate agent installed or install it manually.

2

Configure Root Volume

Ensure the root EBS volume is encrypted. You can enable encryption at launch time or use an encrypted AMI.

3

Enable Hibernate at Launch

When launching the instance, enable 'Stop - Hibernate behavior' in the Advanced details section.

4

Size the Volume

Make sure the root volume has enough space for the OS plus the full RAM contents.

5

Hibernate When Ready

Use the console, CLI, or API to hibernate the instance. It will appear in 'Stopped' state.

Reflection

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 Lesson

Continue Your Journey