DEV Community

Prashant Lakhera
Prashant Lakhera

Posted on

Differences Between AWS EC2 Instance:Start, Stop, and Restart Operation

Image description

Many of us who use AWS often stop, start, or restart instances. However, only some realize differences in how these operations work.

🔄 Instance Reboot:
A reboot is equivalent to a restart operation on a traditional physical machine. It keeps the instance on the same host machine unless the host is unhealthy or has other problems. The instance keeps the same public and private IP addresses, and any data on the instance store volumes and Elastic Block Store (EBS) volumes remains intact.

❓How does it work
When a reboot command is initiated, the hypervisor sends a signal to the guest operating system to perform a soft reboot, which is a more graceful way to restart the system. The operating system will stop all running processes, flush any cached data to disk, and restart.

⏹️ Instance Shutdown (Stop):
Stopping an instance is like shutting down a physical machine. The instance is powered down and no longer running, so you're not billed for additional instance hours. The instance retains its instance ID, but all data in the instance store volumes is lost. The public IP address is released when the instance is stopped (unless associated with an Elastic IP), but the private IP address remains associated. When the instance is started again, it might be run on a different host machine.

❓How does it work
When a stop command is initiated, the hypervisor sends a signal to the guest operating system to perform a soft shutdown, which is a more graceful way to shut down the system. All the processes will be stopped, and any cached data will be written to disk. After that, the hypervisor will deallocate the previously allocated resources to the instance.

🏁 The key difference is that a reboot keeps the data on the instance, which will run on the same host (unless the host is unhealthy), while a shutdown stops the instance and deallocates its resources. Data in instance store volumes is lost, and when the instance is restarted, it may run on a different host machine.

Image description

📚 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

📚 content: https://github.com/100daysofdevops/Cracking-the-devops-interview-code/blob/main/book-content

Top comments (0)