AWS
Heroku vs AWS: 10 Most Important Differences You Must Know!
What is AWS? Amazon web service is a platform that offers flexible, reliable, scalable,...
An EC2 instance is nothing but a virtual server in Amazon Web services terminology. It stands for Elastic Compute Cloud. It is a web service where an AWS subscriber can request and provision a compute server in AWS cloud.
An on-demand EC2 instance is an offering from AWS where the subscriber/user can rent the virtual server per hour and use it to deploy his/her own applications.
The instance will be charged per hour with different rates based on the type of the instance chosen. AWS provides multiple instance types for the respective business needs of the user.
Thus, you can rent an instance based on your own CPU and memory requirements and use it as long as you want. You can terminate the instance when it’s no more used and save on costs. This is the most striking advantage of an on-demand instance- you can drastically save on your CAPEX.
In this tutorial, you will learn-
Let us see in detail how to launch an on-demand EC2 instance in AWS Cloud.
Step 1) In this step,
Here is the EC2 dashboard. Here you will get all the information in gist about the AWS EC2 resources running.
Step 2) On the top right corner of the EC2 dashboard, choose the AWS Region in which you want to provision the EC2 server.
Here we are selecting N. Virginia. AWS provides 10 Regions all over the globe.
Step 3) In this step
Step 1) In this step we will do,
Step 1) In the next step, you have to choose the type of instance you require based on your business needs.
Step 1) No. of instances- you can provision up to 20 instances at a time. Here we are launching one instance.
Step 2) Under Purchasing Options, keep the option of 'Request Spot Instances' unchecked as of now. (This is done when we wish to launch Spot instances instead of on-demand ones. We will come back to Spot instances in the later part of the tutorial).
Step 3) Next, we have to configure some basic networking details for our EC2 server.
Below,
Here I have selected an already existing VPC where I want to launch my instance.
Step 4) In this step,
Step 5) In this step,
Step 6) In this step,
Step 7) In this step, you have to do following things
Step 8) In this step,
Step 9) In this step,
Step 10) In this step,
Step 1) In this step we do following things,
Step 1) In this step
Step 1) In this next step of configuring Security Groups, you can restrict traffic on your instance ports. This is an added firewall mechanism provided by AWS apart from your instance's OS firewall.
You can define open ports and IPs.
Step 1) In this step, we will review all our choices and parameters and go ahead to launch our instance.
Step 2) In the next step you will be asked to create a key pair to login to you an instance. A key pair is a set of public-private keys.
AWS stores the private key in the instance, and you are asked to download the private key. Make sure you download the key and keep it safe and secured; if it is lost you cannot download it again.
Step 3) Once you are done downloading and saving your key, launch your instance.
An EIP is a static public IP provided by AWS. It stands for Elastic IP. Normally when you create an instance, it will receive a public IP from the AWS's pool automatically. If you stop/reboot your instance, this public IP will change- it'dynamic. In order for your application to have a static IP from where you can connect via public networks, you can use an EIP.
Step 1) On the left pane of EC2 Dashboard, you can go to 'Elastic IPs' as shown below.
Step 2) Allocate a new Elastic IP Address.
Step 3) Allocate this IP to be used in a VPC scope.
Step 4) Now assign this IP to your instance.
Step 5) In the next page,
Step 6) Come back to your instances screen, you'll see that your instance has received your EIP.
Step 7) Now open putty from your programs list and add your same EIP in there as below.
Step 8) In this step,
Add your private key in putty for secure connection
Once done click on "Open" button
Once you become familiar with the above steps for launching the instance, it becomes a matter of 2 minutes to launch the same!
You can now use your on-demand EC2 server for your applications.
A spot Instance is an offering from AWS; it allows an AWS business subscriber to bid on unused AWS compute capacity. The hourly price for a Spot instance is decided by AWS, and it fluctuates depending on the supply and demand for Spot instances.
Your Spot instance runs whenever your bid exceeds the current market price. The price of a spot instance varies based on the instance type and the Availability Zone in which the instance can be provisioned.
When your bid price exceeds the market spot price of the instance called as the ‘spot price,' your instance stays running. When the spot price overshoots the bid price, AWS will terminate your instance automatically. Therefore, it is necessary to plan the spot instances in your application architecture carefully.
In order to launch a spot instance, you have to first create a Spot Request.
Follow the steps below to create a Spot Request.
Spot instance launch wizard will open up. You can now go ahead with selecting the parameters and the instance configuration.
The first step for spot instance is to "Find instance types."
Step 1) Select an AMI- an AMI is a template consisting of the OS platform and software to be installed in the instance. Select your desired AMI from the existing list. We are selecting Amazon Linux AMI for this tutorial.
Step 2) Capacity Unit- a Capacity Unit is your application requirement. You may decide to launch an instance based on the instance type, vCPU or custom configuration like your choice of vCPU/memory/storage requirements. Here we are selecting an Instance.
If you wish to customize the capacity, you can add your choice of
Step 3) Target Capacity depicts how many spot instances you wish to maintain in your request. Here we are selecting one.
Step 4) Bid Price – this is the maximum price we are ready to pay for the instance. We are going to set a particular price per instance/hour. This is the simplest to calculate based on our business requirement. We will see ahead how we should determine the bid price so that our bid price always remains high and doesn't exceed the spot price so that our instance keeps running.
just below the bid price you can see a button of Pricing History. Click on that as shown below.
Here in Pricing History, we can see a graph depicting instance pricing trends with historical data. You can select the parameters and get an idea of the pricing of our desired instance over a period of time.
Thus, from the chart below, we can see that the instance type that we are planning to provision lies in the pricing range of $0.01xx, and it seems that Availability Zone 'us-east 1a' has the lowest price.
cont. to step 4.
So let's come back to our step of quoting a bid price.
For the sake of maintaining our instance always available and if it falls within our budget, we can quote a higher bid price. Here we have quoted a slightly higher price of $0.05.
You can see some trends in the wizard itself.
Step 5) Once we are done looking at the trends and quoting our bid price, click on next.
Our next step is to configure the instance, in this step of the wizard, we'll configure instance parameters like VPC, subnets, etc.
Let's take a look.
Step 1) Allocation Strategy – it determines how your spot request is fulfilled from the AWS's spot pools. There are two types of strategies:
For this tutorial, we'll select Lowest Price as our allocation strategy.
Step 2) Select the VPC- we'll select from the list of available VPCs that we have created earlier. We can also create a new VPC in this step.
Step 3) Next we'll select the security group for the instance. We can select an already existing SG or create a new one.
Step 4) Availability Zone- we'll select the AZ where we want to place our instance based on our application architecture. We are selecting AZ- us-east-1a.
Step 5) Subnets- we are going to select the subnet from our list of already available list.
Step 6) Public IP- we'll choose to assign the instance a public IP as soon as it launches. In this step, you can choose if you want AWS to assign it an IP automatically, or you want to do it manually later. You can enable/ disable 'Auto assign Public IP' feature here likewise.
Step 7) Key pair- A key pair is a set of public-private keys.
AWS stores the private key in the instance, and you are asked to download the private key. Make sure you download the key and keep it safe and secured; if it is lost you cannot download it again.
After selecting public IP, here we are selecting a key which we already have created in our last tutorial.
Once we are done configuring our spot instance request in the 2 steps earlier in our wizard, we'll take a look at the overall configuration.
After we are done reviewing, we can proceed with the launching by clicking the Launch button as shown below.
Once we select Launch, we can see a notification about the request getting created.
The spot request creation wizard will close, and the page will automatically direct back to the EC2 Dashboard.
You can see as shown below that the State of our request is 'open' which means that it is getting evaluated from the AWS's side. AWS EC2 will check if the required instance is available in its spot pool.
After a couple of minutes, you can see that the state is changed to 'active', and now our spot request is successfully fulfilled. You can note the configuration parameters below.
Summary:
Thus, we saw in detail how to create an on-demand EC2 instance in this tutorial. Because it is an on-demand server, you can keep it running when in use and 'Stop' it when it's unused to save on your costs.
You can provision a Linux or Windows EC2 instance or from any of the available AMIs in AWS Marketplace based on your choice of OS platform.
If your application is in production and you have to use it for years to come, you should consider provisioning a reserved instance to drastically save on your CAPEX.
Here, we saw how to create a Spot Instance request successfully by determining our bid price.
Spot instances are a great way to save on costs for instances which are not application critical. A common example would be to create a fleet of spot instances for a task such as image processing or video encoding. In such cases, you can keep a cluster of instances under a load balancer.
If the bid price exceeds the spot price and your instance is terminated from AWS's side, you can have other instances doing the processing job for you. You can leverage Auto scaling for this scenario. Avoid using Spot instances for business critical applications like databases etc.
AWS Certified Solutions Architect - Associate 2018
What is AWS? Amazon web service is a platform that offers flexible, reliable, scalable,...
{loadposition top-ads-automation-testing-tools} AWS is Amazon's cloud computing platform that...
What is AWS certification? AWS Certification helps professionals to build credibility and...
Before AWS Lambda function, let's understand: What is Serverless? Serverless is a term that...
What is DigitalOcean? DigitalOcean is a simple cloud service provider. It has a simple set-up and...
What is Cloud Computing? Cloud computing is a term referred to storing and accessing data over the...