AWS EC2 – Elastic Compute Cloud

AWS EC2 – Elastic Compute Cloud

AWS Elastic Cloud Computing or EC2

Hello Friends, I am going to cover AWS Elastic Cloud Computing (a.k.a. EC2) virtual server in this blog. We have already published other blogs in this aws series, feel free to visit those and learn more about AWS Cloud platform and its services.

Let’s begin …

What is EC2

There are three mail pillars in IT infrastructure, Compute, storage and Network. EC2 is the backbone of AWS computing. Using EC2 you can spin up new VMs/Servers in seconds across multiple Availability Zone. The term Elastic signifies that EC2 instances can be scale up and down based on the computing requirements.

In short,

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the AWS cloud. This eliminates need of investing up front in hardware. It helps to develop, deploy and manage applications faster with less cost.

Types of EC2 Instances

AWS offers to provision instances based on the requirement of your applications. It can be a simple php application, or a news portal, or a consumer website or a graphic intensive application. Your pick of a correct EC2 instance for optimized performance is one of the key success factor from the application perspective. Here are the different categories to choose from.

General purpose instances are T2, M5, M4 instances and some other M class instances which now belongs to old generation instances. This type of instances is ideal for small to mid-size application.

Compute optimized instances are the C5, C4 instances where the applications demand compute intensive instance.

Memory optimized instance belongs to X1e, X1 & R4 category. For any kind of large-scale in-memory application X1e & X1 are the perfect fit. R4 are mainly for memory intensive applications like for datamining, data analysis etc.

Storage optimized instance are marked as H1, I3 & D2. The typical usage for a storage optimized application is for large-scale data processing application, like HDFS , Elasticsearch, Data Warehouse etc.

Accelerated Computing belongs to P3, P2, G3 & F1 category. These are highly expensive instances and hence need to choose wisely. This type of instances is ideal for graphic intensive, 3D rendering Machine learning purpose.

There are sub-categories under each instance type as depicted in the above figure. We see there are two parts of the nomenclature, first part i.e. C4 is compute optimize purpose instance that you choose 4th generation C family and then you have the options to select the instance size of that family. AWS provides sizing options int-shirt sizing style, i.e. small, medium, large , extra-large, 2* extra-large etc.

Now, let’s discuss few of terminologies in EC2 paradigm. Please visit our Talk section for the video describing all these with a hands-on demo.

AMI – Amazon Machine Image

As the name suggests, it’s the image of Amazon instance. To launch any instance in AWS you need to specify an AMI. AWS has public AMIs available on their marketplace, from which you can launch an instance as per your requirement. You can have your own AMIs as well as per your company needs. Say you launch an AMI of Amazon Linux, and after the instance is ready , you have installed and configured certain software which are required for your project. Then you create an AMI from this instance and make use of this AMI when you need to launch similar instances. Good thing is that you can share your AMIs with other AWS accounts, even across AWS regions.

Metadata & User Data

  • EC2 Instance Metadata- Instance metadata is data about your instance that you can use to configure or manage the running instance. You can access the metadata of the instance through http://169.254.169.254/latest/meta-data within the instance. You can get the ami id, EC2 hostname, public/private ip, security group, block device mapping of the instance and many more information.
  • EC2 User Data – User data is data provided by user. What does that mean? Suppose you want to bootstrap your EC2 instance by passing certain commands, say installing the updates, running some scripts etc. This information can be passed in the user data section at the time of the instance launch. This helps to build a generic image (AMI) from that instance for future use. To retrieve the user data from the running instance use http://169.254.169.254/latest/user-data.

Security Groups

To serve traffic in and out of EC2 instance we need to define Security groups. Security groups allows to control the access in instance level. This acts as like a firewall. You can control network traffic for specific protocol, ports etc. When a Security group is created there is no in-bound rule and all out-bound traffic by default allowed. What is Elastic IP-EIP

EIP is a static public IPv4 address which is reachable from internet.

AWS also supports IP6 for recent and new EC2 instances. To use an EIP it should be allocated to the AWS account. There is a soft limit of EIP allocation is 5 per AWS account. EIPs can be attached to a NIC or instances. EIPs can be associate and disassociate and re-associate with the instances as per the requirements. But even disassociated EIPs remain under the AWS accounts incur a small amount of charges unless it has been released back to the ip pool explicitly.

Pricing Model as per usage

There are different pricing offering from AWS to optimise your cost for EC2 instances based on utilization period. AWS provide three different categories, which are On-demand, Reserved and Spot instances. Different pricing strategy for different EC2 instances help to optimize TCO for IT project. For example, Production environment requires EC2 instances for many years, whereas for Development environment you may need the servers for very short time e.g. 6 months. Also there may be certain non-critical jobs running in Development environment which require a good amount of compute power, though the span of running jobs is not very long. Now you may want to analyse Infrastructure cost of this kind of engagement considering below options.

On–demand EC2 Instances For this type of plan, you don’t have to pay any upfront cost. That means you can purchase compute capacity with no upfront commitment and you will pay the pricing at hourly or per second rates just like pay as you go model.

Reserved EC2 Instances When you are sure that certain number of instances going to run for a considerable amount of time, this is te best option to minimize cost, as Reserved EC2 instances is much cheaper than other pricing model. You can choose your payment over a 1 or 3 year term according to your application demand.

Spot Instances It’s sale timing with the lowest bid friend. That means, if AWS have some spare instances and your bid is the lowest then you can get the instance with a huge discount, sometimes the discount is even 90%.  But is there any risk? Yes, risk is if someone bid at the lower price than yours then you will be kicked out. So if you are going to opt for spot instance you have to be aware of the consequences.

Dedicated Hosts This type of EC2 instances can have dedicated hardware for your usage only. Hence, there is no noisy neighbour situation for your application. Though, this is costliest option amongst all.

Let’s summarize few highlights of EC2 as following

  • Preconfigured templates for your instances, known as Amazon Machine Images (AMIs), that package the bits you need for your server (including the operating system and additional software)
  • Various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types
  • Secure login information for your instances using key pairs (AWS stores the public key, and you store the private key in a secure place)
  • Storage volumes for temporary data that’s deleted when you stop or terminate your instance, known as instance store volumes
  • Persistent storage volumes for your data using Amazon Elastic Block Store (Amazon EBS), known as Amazon EBS volumes
  • Virtual networks you can create that are logically isolated from the rest of the AWS cloud, and that you can optionally connect to your own network, known as virtual private clouds (VPCs)
  • PCI DSS Compliance

EC2 Best Practices

Before I conclude today’s blog, let’s discuss few best practices on EC2

  • By this time, I believe that you have got the idea about AWS Availability Zone and Region. You must choose the Region carefully where you can optimise the latency & the cost.
  • Please note that user data can only be executed at the time of instance launch, so you should plan accordingly and DO NOT store any sensitive data like password in user-data, as it is not encrypted.
  • Instance type based on use should be selected carefully, it can save you a good $ if you plan wisely.

Hope, you enjoy this post and learn about AWS EC2 instances a bit. Request you to create a free AWS account and do hands-on. Please do visit other blogs under AWS series, I am sure that you will like those too.  Don’t forget to watch our EC2 Video in Talk section where you can find hands on demo. In my next blog, I shall cover a real implementation of one Usecase with EC2 & S3 together.

Please keep visiting and Happy reading, guys 😊

 

Author: Dhrubo

I am passionate about sharing Knowledge , Information and wisdom what ever way is possible. This is small contribution to our society from my part. I am a Programmer and love to architect and modernize IT infrastructure / solution / applications for my clients.

I am sharing my experience what I have gained so far via CTT and will keep doing so in regular basis. This is the whole purpose of founding this Knowledge Center for Cloud Technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.