Instructor: So let's talk about a lesser-known feature
called EC2 Hibernate.
So we know that we can stop and terminate instances,
and when we do so, when we stop it,
the data on disk, on your EBS disk,
is going to be kept intact until the next start.
That makes sense.
And if we terminate it, well,
if you set up the root volume
to be destroyed with your instance,
it's going to be destroyed,
but any volume that is not set up to be destroyed
when your instance is terminated will be kept.
And then when you start an instance,
well, the OS, the operating system will boot
and then the EC2 User Data that was going to be run,
the script, and then the OS will boot up.
And then your application starts, your caches get warmed,
and that can take time,
because you are booting your machine, right?
But the idea is that with Hibernate,
we want to achieve a new state.
So when we hibernate an instance, whatever was in RAM,
the in-memory state is going to be preserved.
What does that mean?
That means that your instance boot is going
to be much faster,
because the operating system is not stopped or restarted,
the operating system is actually just frozen,
it's hibernated.
And under the hood, well,
whatever was in the RAM state is going to be written
into a file in the root EBS volume.
So that means that the root EBS volume must be encrypted
and that it must have enough space to contain the RAM.
So let me show you what happens.
So we take an EC2 instance,
and it's running and there is data in RAM,
and then we start a hibernation process.
So what happens that the instance will go
in the stopping state,
and the RAM is going to be dumped into your EBS volume.
Then the instance is shut down and the RAM disappears,
because as soon as you stop an instance the RAM goes away,
but the EBS volume still contains the dump of the RAM.
And then when your instance is started,
then the RAM is going to be loaded from disk
onto the EC2 instance memory.
And that means that it is just as is
your EC2 instance never got stopped.
And we'll have a look at this in the hands-on.
So the use cases for hibernation is
if you want to have long-running processes
and never actually stop them,
or if you want to save the RAM state,
or if you just want to reboot, like boot up fast,
and you have services that take time to initialize.
So you actually don't want them to initialize,
you want them to stay up and running
even if you hibernate your instance.
So, some good things to know about EC2 Hibernate is that
it supports a lot of different families.
The instance RAM size must be less than 150 gigabytes.
Now, that can change,
and again, you're not tested on limits at the exam,
but I'm just putting this as an indication for you
to get an idea of how that works.
It doesn't work for bare metal instances.
It works for many different operating systems,
including Linux and Windows.
It works for the root volume,
so the root volume must be an EBS volume,
it must be encrypted, okay?
And it must be large to contain the RAM
that you dump onto it.
It's available for all kind of instances,
such as on-demand, reserved, and spot instances.
And hibernation is meant to be no more than 60 days.
Again, this can change,
but right now this is the actual limits.
Okay, so that's it for this lecture, I hope you liked it,
and I will see you in the next lecture for a hands-on.