- An AMI stands for Amazon Machine Images.
- An AMI is a virtual image used to create a virtual machine within an EC2 instance.
- You can also create multiple instances using single AMI when you need instances with the same configuration.
- You can also create multiple instances using different AMI when you need instances with a different configuration.
- It also provides a template for the root volume of an instance.
- First, you need to create and register an AMI.
- You can use an AMI to launch EC2 instances.
- You can also copy an AMI to some different region.
- When AMI is no longer required, then you can also deregister it.
AMI is divided into two categories:
- EBS – backed Instances
- Instance Store – backed Instances
EBS – backed Instances
- EBS is nothing but a volume that provides you persistent storage.
- When you run an EC2 instance that provides you temporary storage, if you delete an EC2 instance then the data stored in the EC2 instance will also be deleted. To make a data persistent, Amazon provides an EBS Volume. If you launch an EC2 instance and want to make some data persistent, then you need to attach an instance with the EBS Volume so that your data would be available even on deleting an EC2 instance.
- When you launch an EC2 instance, it will always have a root device as an EBS Volume which makes the data persistent. Therefore, we can say that when we delete an EC2 instance, then the data is available in a root device.
- In EBS – backed instances, you will be charged or billed for the storage of static data such as operating systems files, etc.
The cost of adding the EBS Volume to an EC2 instance is minimal.
Instance Store – backed Instances
- In Instance-Store, an instance consists of storage approx 1 TB or 2 TB which is temporary storage. As soon as the instance is terminated, all the data will be lost. For example, if you launch an instance, and deploy the database in it. If you delete an instance, then all the data will be lost and this becomes the challenge. In such a scenario, you can add an additional EBS Volume that also stores the data, so even if you delete an instance, your data would not be lost.
- In this case, EBS Volume is not a root volume. It’s an additional volume that you attach to your EC2 instance manually.
Why EBS – backed instance is more popular than Instance Store – backed instance?
Instance Store – backed instances
In Instance Store – backed instance, if you launch an instance, it would be in a pending state. After pending state, an instance comes in a running state then it would be in a shutting down state. Amazon would charge you only when it is in a running state. When you terminate an instance, Amazon would not charge you any cost. For example, if you want to run an instance for 4 hours a day and it would cost you 10 cents per hour. In instance store, my instance would be running 24 hrs a day as it has no stopped state. Therefore, it would cost 72 dollars a month.
- EBS – backed Instances
In EBS – backed instances, an instance can be either in a running state or in a stopped state. In this case, Amazon would cost you only for a running state, not for a stopped state. For example, if you want to run an instance for 4 hours a day and it would cost you 10 cents per hour. In EBS – backed instance, an instance will run for 4 hours as it has stopped state as well. I take a 100 GB volume that would cost you 5 dollars. The running cost of an instance would be 12 dollars in a month. Therefore, the total cost taken by this instance is volume cost plus running cost which is equal to 17 dollars.
EBS-backed instance is saving our 55 dollars. Therefore, we conclude that why EBS-backed instance is more popular and faster than instance store-backed instance.
Difference b/w Instance store & EBS – backed instance
|Characteristics||EBS-backed instance||Instance Store-backed instance|
|Lifecycle||It supports stopping as well as restarting of an instance by saving the state to EBS volume.||In this case, an instance cannot be stopped. It can be either in a running or terminated state.|
|Data Persistence||Data persists in EBS volume. If an instance is terminated, no data would be lost.||Data does not persist so when instance is terminated, data would be lost.|
|Boot time||It takes less than 1 min.||It usually takes less than 5 min.|
|Size limit||1 TB||10 – 16 TB|
|AMI creation||AMI is very easily created by using a single command.||To create an AMI, it requires installation and AMI tools.|
|Expensive||It is less expensive.||It is more expensive as compared to Instance Store-backed instance.|