AWS EC2 and IAM
The second part in our three-part series on cloud architecture with AWS, taken from Packt’s title on Mastering AWS Development: looking at AWS EC2 and IAM more closely, including functionality, instance types and pricing.
This introduction to AWS is taken from the Packt title Mastering AWS Development.
Amazon EC2 is a web service (launched in 2006) that helps virtual machines run on host applications or databases. In other words, it provides a resizable compute capacity in the AWS Cloud. You can group your OS, application software, and its associated configuration settings with EC2 AMIs.
An AWS user can boot AMIs to launch virtual machines. In AWS terms, it is called an “instance”. A user can create, configure, launch, and delete the EC2 instances as per requirements. You can use AMIs to launch a number of virtual instances and also decommission them using web service calls to scale your environment as per your requirements.
The AWS EC2 functionality
AWS EC2 generates a fully virtualized environment, which allows you to use a web-based interface to start instances with different types of operating system and, built-in application packages with custom permissions. You can run n number of instances from the same AMI as required.
To work with AWS EC2, you have to:
- Choose a pre-configured template called AMI to run and make it available for use. Another option is to manually create your own custom AMIs to have your required applications and
- Create a new or configure an existing default security group and network accessible protocols to reach your instance from the backend as well as from the frontend.
- Select your instance type and size based on the requirement.
- Select your instance location, addition storage, plus the Elastic IP requirement.
- Pay only for what you use per hour.
Instance types and pricing
AWS EC2 instances are the basic building blocks required for your computing requirements on the AWS Cloud platform. Also, as it’s a core component of any customer infrastructure, AWS provides a variety of instance types. Instance types comprise various combinations of memory, CPU, storage, and network capabilities, and so will give the freedom to AWS users to select the appropriate mix of resources for their web-based solutions.
Selecting an instance type
For an easier understanding of instance types and based on real-time cases, AWS has grouped together instances into families based on final application usages. The following information guide will help you to think about the instance type that would be best suited as per your requirements.
AWS EC2 instances can be differentiated via three purchasing models:
- On-demand instance
- Reserved instance
- Spot instance
At the beginning of Cloud technology, it was first defined by its properties of elasticity and supply of infrastructure with whatever configuration the consumer needs and whenever he needs. This was the primary logic behind on-demand instances.
You don’t need to pay any up-front cost, but only charges per hour plus how long you are going to run the AWS instance for. This purchasing model is very flexible, but it is also the most expensive one. If somebody requires dynamic throughput, the on-demand instance type can be the best choice for them.
If you know the exact duration for the instance to become available on AWS, accurate usage as per the instance types, and the geographical location of instances from where you can serve the content with low latency to your end users, you can go with reserved instances:
Reserved instances always start as on-demand instances but the only difference is the billing method. You have to pay a one-time fee to cut down the per hour charges at runtime. If you are going to use AWS EC2 instances all the time like 365x24x7, you will realize a drastic price reduction in billing.
The reserved instances are classified based on their utilization, for example, light utilization, medium utilization, and heavy utilization. The basic difference between these three types is their upfront cost and per hour billing. If you select a heavy utilization type, per the hour charges will be much less but the upfront cost will be higher than the light and medium utilization types.
Tip: After purchasing the reserved instance, you cannot change the platform, AZ, instance type, term period, and offering type.
Again, if you are going for light utilization, you have to pay a smaller upfront cost but the per hour charge will be increased compared to high utilization and medium utilization. The best use case is to run light and medium utilization type instances for those who often need to run a particular instance type, but not all the time.
However, after offering resources to end users over the globe, AWS has unused infrastructure in their datacenters. So AWS has decided to rent this infrastructure by bidding it. A user will come and bid for the instance, and they will get the instance resource as long as their bid is higher than the others:
In other words, in Spot instances, you can specify the maximum price based on the per hour charge you’ll pay and if there is space, you will get the instance. At any point in time, if you are outbid, your instance will be snatched away from you without any prior notice. That means you can utilize these kinds of resources to finish the process when it’s most economical. Spot instances can be best suited to web applications or web servers, where if one or more instances shuts down, the process won’t be affected.
Tip: The Spot instances console is the same as an on demand console except the configuration step in which a user will define the bid price.
Whenever you are going to launch an instance in any region and whatever the instance type you selecting, determine the hardware of the server/instance, which will be used in your virtual infrastructure. Each and every instance type has different RAM, CPU power, and storage capacities. Among these instance types, you have to choose the most suitable instance type on which you can start hosting your software or applications. AWS EC2 gives you consistent CPU power, regardless of its whole underlying hardware infrastructure/datacenter.
AWS EC2 reserves some of the resources from its pool for the host computer, such as the CPU, memory, and some instance storage for an appropriate instance. AWS EC2 will share the remaining resources of the existing host computer, such as network and disk, among other instances. So, if any instance on a host computer tries to utilize the capacity of shared resources, each instance will receive an equal part of those shared resources. And if the resource performance and usage is under-utilized, an instance can acquire a larger share of those shared resources as it can in that period of time.
In AWS EC2, each instance will provide you with higher performance or lower performance based on that instance type and shared resource. Let’s take an example. Say you select a high I/O instance type, which has a higher allocation of the shared pool of resources. Allocating a higher set of shared resources will also vary the I/O results of the instance type. For a general application that has a normal load, moderate I/O performance is sufficient. However, applications such as market trading will require a higher or more consistent I/O performance by considering an instance type that has a higher I/O performance output.
Available instance types
AWS has divided the instances based on common usage patterns, configuration families, and its configuration properties, as shown in the following image:
You can find out more about common instance categories at: http://aws.amazon.com/ec2/instance-types/
Popular use cases for instance categories
The various instance categories are as follows:
- General purpose instance: Data processing, small size databases, enterprise applications/portals like SAP, SharePoint, and so on.
- Compute-optimized instances: Batch processing, websites that have very high traffic, GNOME analysis, ads and media serving, computational fluid serving, and video encoding.
- GPU instances: Application/software and 2D/3D application streaming, rendering and engineering design, and so on.
- Memory-optimized: Applications with larger deployment and analysis such as SAP, GNOME assemble analysis, distributed memory caches, and so on.
- Storage-optimized: Scale out transactional databases, data warehousing, and Hadoop.
- t1.micro instances: Low traffic sites, getting hands on with AWS EC2 or for some free tier stuff.
AWS EC2 instance numbers and pricing
In general, you are limited to run a total of 20 on-demand or reserved instances and can request 100 Spot instances per region. If you are a new customer, the instance limit can be lower than the limit described. Certain instance types are more specific with numbers per region and can vary based upon the account and production instance request form. You can find more details regarding limits at the following URL:
Billing and pricing
On AWS, you will be charged for what you use and there are no minimum charges; in other words, they follow the pay-as-you-go model. Charges will be based on per hour usage of an instance type. Partial or semi partial instance hours consumed will be counted as full hours. For example, if you are using an instance for 55 minutes, you will be charged for 60 minutes. There is no data transfer charges between two Amazon services within the same region, for example, if you are transferring some data from AWS EC2 US West to AWS RDS US West. Charges are exclusive of applicable taxes and duties, including VAT and applicable sales tax in monthly billing.
AWS services, data transferred between multiple regions, and the usage of other AWS resources will be billed separately to AWS EC2. Billing originates when Amazon EC2 initiates the boot sequence of an AMI instance. The billing cycle stops when the instance terminates, which could ensue through a web services command, by running
shutdown -h or due to instance failure. To count the cost before initiating the new AWS resources you can check the estimate monthly billing at http://aws.amazon.com/calculator.
The calculator page will look like the following screenshot:
On the calculator, you can estimate your monthly billing based on your approximate services-based usage.