DEV Community

Cover image for AWS Under the Hood - Day 5 - What Is the difference between stop/start vs reboot for AWS EC2 Instances?
Prashant Lakhera
Prashant Lakhera

Posted on

AWS Under the Hood - Day 5 - What Is the difference between stop/start vs reboot for AWS EC2 Instances?

Before I explain the differences between stop/start vs. reboot, let's first understand the hypervisor's role in rebooting versus stopping and starting an AWS EC2 instance.

Hypervisor's Role in EC2 Instances
AWS uses a hypervisor, a virtualization technology that allows multiple virtual servers (instances) to run on a single physical server. The hypervisor manages the hardware and allocates resources to the virtual machines. AWS has been known to use Xen and, more recently, Nitro as hypervisors, each affecting how instances are managed.

Hypervisor Behavior During Reboot
When you reboot an EC2 instance, the process is largely managed at the operating system level inside the virtual machine:

  • Hypervisor Role: The hypervisor continues allocating the same physical resources to the instance before the reboot.
  • Process:The reboot command triggers the restart of the operating system of the EC2 instance.The hypervisor does not need to reallocate resources or move the virtual machine to different hardware.The instance retains its hardware configuration, memory allocation, network settings, and connectivity managed by the hypervisor.

Essentially, a reboot is a straightforward process in which the hypervisor monitors but does not actively intervene unless necessary to maintain the usual operations, such as resource allocations and ensuring isolation among different instances on the same host.

Hypervisor Behavior During Stop and Start

  • Stopping and starting an EC2 instance involves more extensive interaction with the hypervisor:
  • Stopping:Hypervisor Role: Actively manages the disassociation of hardware resources from the stopped instance.Process:Commands the OS to shut down.Clears the instance's state from the RAM, erasing all volatile data.Detaches the virtual machine from its assigned physical resources (CPU, memory).Stores the instance configuration and data persistence details, typically on EBS volumes, which remain intact.
  • Starting:Hypervisor Role: Allocates new physical resources from the available pool to the instance.Process:Identifies and allocates a suitable physical server that can host the instance.Reinitializes the instance using the stored EBS snapshot of the root volume and other configuration details.Runs system integrity checks to ensure the instance can operate correctly on its new hardware.

Considerations

  • Performance Implications: During the stop/start process, since the instance may be moved to a different physical server, it might experience slight variations in performance due to different hardware capabilities or varying loads on the physical servers.
  • Resource Reallocation: The hypervisor's ability to dynamically allocate resources means that when an instance is restarted, it not only changes physical servers but could potentially benefit from newer or more optimized hardware depending on the hypervisor's availability and scheduling decisions.

Conclusion
The bottom line is that rebooting is less intrusive and leaves the hypervisor's resource allocation largely unchanged. In contrast, stopping and starting an instance allows the hypervisor to re-optimize resource allocation, potentially enhancing the instance's configuration and performance based on current system states and hardware availability. This knowledge can be crucial when planning maintenance, migrations, or upgrades within your AWS environment.

📚 If you're interested in more in-depth explanation of these topics, please check out my new book "Cracking the DevOps Interview"
https://pratimuniyal.gumroad.com/l/cracking-the-devops-interview
📚 To learn more about AWS, check out my book "AWS for System Administrators"
https://www.amazon.com/AWS-System-Administrators-automate-infrastructure

Top comments (0)