Monday, May 1, 2017

EC2 Elastic Cloud Compute

EC2:

  • EC2 is a web service that provides resizable compute capability in the cloud. It reduced the time required to obtain and boot new servers into minutes, allowing us to quickly scale the capacity both up and down, as the computing requirements changes.
  • It is simply a Virtual Machine in the cloud, can be a Linux server, Windows server etc.,
  • It allows you to pay only for the capacity that we actually use, it provides the developers with the tools to build a failure resilient applications and isolate them from common failure scenarios.
Types of payment options for EC2:
  1. On Demand: It lets you pay fixed rate by hour with no commitment.
    Users with that want the low cost and flexibility of EC2 without any upfront payment or long term contract.
    Application with short term, spiky or unpredictable workloads that cannot be interrupted.
    Applications being developed or tested on EC2 for the first time.
  2. Reserved: Provides you with a capacity reservation with a significant discount on the hourly charge for an instance. 1 year or 3 year term.
    Applications with steady state or predictable usage.
    Applications that require reserved capacity.
    Users able to make upfront payments to reduce their total computing costs further.
  3. Spot pricing: Enables you to bid for whatever price you want for instance capacity, providing for even greater savings if the applications have flexible start and end times.
    Applications that are feasible at very low compute prices.
    Users with urgent computing needs for large amounts of additional capacity.
  4. Dedicated Hosts: Physical EC2 servers dedicated for your use. Dedicated hosts can help you reduce costs by allowing you to use your existing server bound software licenses. This can be paid by hourly price.
    Useful for regulatory requirements that may not support multi-tenant virtualisation.
    Great for licensing which does not support multi-tenancy or cloud deployments. For ex:-Oracle
    Can be purchased on demand(hourly).
    Can be purchased as a reservation for up to 70% off the on demand price. 
Diff. EC2 instances:
 

How to Remember them:
 

EBS:
Amazon EBS allows you to create storage volumes and attach them to EC2 instances. Once attached you can create a file system on top of these volumes, run a database or use them in any other way as a block device.
EBS are placed in a specific availability zone and are automatically replicated to protect from failure of a single component.

EBS Volume Types:

General Purpose SSD(GP2):- Bootable
  • General purpose, balances both price and performance.
  • Ratio of 3 IOPS per GB with upto 10000 IOPS and the ability to burst upto 3000 IOPS for extended periods of time for volumes under 1GB.
Provisioned IOPS SSD(101)- Bootable
  • Designed for I/O intensive applications such as large relational or NoSQL databases.
  • Use if you need more than 10000 IOPS.
  • Can provision upto 20000 IOPS per volume.
Throughput optimized HDD(ST1) - Not bootable
  • Big data
  • Data warehouses 
  • Log processing 
 Cold HDD(SC1)  - Not bootable
  • Lowest cost storage for in frequently accessed workloads
  • Used for File Server
Magnetic (Standard) - Bootable
  • Lowest cost per GB of all EBS types that is bootable. Magnetic volumes are ideal for workloads where data is accessed infrequently and applications where the lowest cost is important. 
Launching an EC2 Instance:
  • EC2 is available under the Compute section in the console. EC2 is area specific, so there are some types of instances that are not available in all the regions.
  1. Click on the launch instance to start the process of installation. The first step would be to choose between the different AMIs(Amazon Machine Images) which is a SnapShot of virtual machines. We have the flexibility to choose between the different Operating Systems. Different Types of virtualizations : http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html
  2. Next will give you the type of instance that we want depending on the need from DRMCGIFTPIX of which some are eligible for free trial. 
  3. In the configure instance section this is the main screen. In the advance section we can pass bootstrap scripts to the EC2 instance. One subnet is equal to one availability zone.
  4. In the add storage section, root volume is the bootable volume from where the OS loads. If the delete on termination is checked, when the EC2 instance is terminated this volume is deleted as well.
  5. In the add tags section we can specify the key and value for the tag which can be tagged to the EC2 instance. Tagging as much as possible helps to track who is using the instance there by helping in cost efficiency.
  6. In the configure security section, they are virtual files. Its a virtual  firewall. In the source section we can specify down to the IP address that we want to use to access the instance.
We will need to create a key pair. We have a public key and a private key, we can have same public key for multiple EC2 instances and have different private keys to instances.

Types of security groups (ex: SSH, HTTP, HTTPS etc.,): http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-rules-reference.html


Commands Used
-- yum install httpd -y -- used to install apache

Security Groups:
  • Security groups helps you attach them to the EC2 there by creating a firewall to the instance. HTTP for instance allows you to access the public IP address using the web browser and this can be limited down to the IP address.
  • As soon as we make any change to the security group the effect kicks in immediately.
  • All inbound traffic is Blocked by default.
  • All Outbound Traffic is allowed by default.
  • You can have any number of EC2 instances within a security group.
  • You can have multiple security groups attached to EC2 instances.
  • Security Groups are StateLess.
    -> If you create an inbound rule allowing traffic in, that traffic is automatically allowed back out again.
  • You cannot block a specific IP addresses using security Groups, instead use Network Access Control Lists.
  • You can specify allow rules, but not deny rules.
Volume & Snapshot Lab:
  • Snapshot is a point in time photograph of harddisk. Everytime we take a new snapshot only the data that is changed is stored.
  • Volumes exist on EBS(Elastic Block Storage). Volume is a virtual harddisk attached to the EC2 instance.
  • Snapshots exist on S3.
  • Snapshots are point in time copies of volumes.
  • Snapshots are incremental, this means that only the block that have changed since your last snapshot are moved to S3.
Commands used on IOS Terminal:
 CHMOD 400 MyEC2Key.pem -- Encrypts the key to make it possible to SSH to EC2 instance.
ssh ec2-user@31.229.**.*** -i MyEC2Key.pem -- to ssh into the ec2 instance using the key
sudo yum update - to get all the updates
sudo su - get the root level access
yum install httpd -y -- to install Apache on the instance to make the instance a web server
cd /var/www/html -- to go into html directory.
nano index.html -- create a small text editor file
service httpd start -- to start apache
-- Now after starting the web server we enter the public IP address of the EC2 instance we can access the html file we created.

SSH into the EBS volumes:
Follow above to actually SSH into the EC2 instance, from then:
lsblk -- will give the information about the volumes that are attached to the EC2 instance and the volumes that are available.
mkfs -t ext4 /dev/xvdb -- will create a file system
mkdir /hello -- will create a new folder
mount /dev/xvdb /hello -- the new volume other than root volume will be attached to this folder
cd /hello -- goto hello
nano test.html  -- create a html file named test.
umount /dev/xvdb -- unmount from the folder /hello

Exam Tips :
  • EBS Volumes can be changed on the fly(except for magnetic standard).
  • Best practice to stop the EC2 instance and then change the volume.
  • You can change volume types by taking a snapshot and then using the snapshot to create a new volume.
  • If you change a volume on the fly you must wait for 6 hours before making another change.
  • You can scale EBS volumes up only.
  • Volumes must be in the same AZ as the EC2 instances.
EFS (Not an exam imp topic):
  • Amazon Elastic File System(EFS) is a file storage service for Amazon EC2 instances. Amazon EFS is easy to use and provides a simple interface that allows you to create and configure file systems quickly and easily. With Amazon EFS, storage capacity is elastic, growing and shrinking automatically as you add and remove files, so your applications have the storage they need, when they need it.
  • Supports the Network File System version 4(NFSv4) protocol.
  • You only pay for the storage you use.
  • Can scale upto the petabytes.
  • Can support thousands of concurrent NFS connections
  • Data is stored accross multiple AZ's within a region
  • Read after write consistency.
  • The basic difference b/n EFS and EBS is that once we can mount any number of instances on one EFS using a load balancer and EBS can only support one EC2 instance.

CLI Commands - Developers Associate Exam :
  1. aws ec2 describe-instances -- This basically tells us about all the EC2 instances that we have running.
  2. aws ec2 describe-images -- Returns all the images that are available to provision 
  3. aws ec2 terminate-instances -- terminates the instances.
  4. aws ec2 run-instance -- create instances/launch instances
  5. aws ec2 start-instance-- used to start an existing instance.
Getting Instance Metadata:
  • curl http://169.254.169.254/latest/meta-data/ -- to get all the available details
  • curl http://169.254.169.254/latest/meta-data/public-ipv4 -- will give the public IP Address for the EC2 instance.
  • For a developer when he wants to access the public ip for the instance and echo we use this command as a variable and echo it.
Elastic Load Balancers: 
  • Elastic Load Balancer is a virtual appliance that spreads the load of the traffic across the different web servers.
  •  Two types : Application Load Balancer(layer 7); Classic Load Balancer (layer 4).
  • Instances monitored by ELS are reported as : InService , or OutofService.
  • Health checks check the instance health by talking to it.
  • Have their own DNS name. You are never given an IP address.
  • Read the ELB FAQs for Classic Load Balancers.
Exam Tips:
SDK Default Regions:
  • Default Region - US-EAST-1
  • Some have default regions (Java).
  • Some do not (Node.js).

Lambda (Not imp for Exam):
-> AWS Lambda is a compute service where you can upload your code and create a Lambda function. AWS lambda takes care of provisioning and managing the servers that you use to run the code. You dont have to worry about operating systems, patching, scaling, etc. You can use Lambda in the following ways:
  • As an event-driven compute service where AWS Lambda runs your code in response to events. These events could be changes to data in an Amazon S3 bucket or an Amazon DynamoDB table. 
  • As a compute service to run the code in response to HTTP requests using Amazon API Gateway or API calls made using AWS SDKs.
Languages that can be used :
  • Node.js
  • Java
  • Python
  • C#
Pricing:
  • Number of requests: First 1 million request are free. $0.20 per 1 million requests thereafter.
  • Duration : Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 100ms. The price depends on the amount of memory you allocate to your function. You are charged $0.00001667 for GB-second used.
  • No Servers!
  • Continous Scaling
  • Super Cheap!
Exam Tips EC2:
  1. Know the differences between;
  • On Demand 
  • Spot 
  • Reserved
  • Dedicated Hosts
     2. Remember with Spot instances;
  • If you terminate the instance, you pay for the hour.
  • If AWS terminates the spot instance, you get the hour it was terminated in for free.

19 comments:

  1. Cloud technology is the leading technology in the current IT, since every domain has numerous data available to store and manage. Your blog is unique and gave useful information about the cloud technology. Thanks for sharing the excellent info. Keep updating
    Regards:
    Best Institute for Cloud Computing in Chennai
    Salesforce Training in Chennai

    ReplyDelete
  2. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    AWS Training In Chennai

    ReplyDelete
  3. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
    hadoop-training-institute-in-chennai
    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  4. It was an excellent article to hear from you which is very useful. Thank you for sharing. This is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
    AWS Lambda Training

    ReplyDelete
  5. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Amazon Web Services Training in Bangalore

    ReplyDelete
  6. Thanks for sharing this post. I got nice information from this blog and you have put a fresh spin on this topic and programming is something everyone serious now.I enjoy reading through your article post, I wanted to write a little comment to support you and wish you a good continuation.

    aws training in bangalore

    selenium training in bangalore

    ReplyDelete
  7. Nice work, your blog is concept oriented ,kindly share more blogs like this
    AWS Online Course

    ReplyDelete
  8. it is very excellent blog and useful article thank you for sharing with us , keep posting learn more AWS Online Training Hyderabad

    ReplyDelete
  9. I always enjoy reading quality articles by an individual who is obviously knowledgeable on their chosen subject. Ill be watching this post with much interest. Keep up the great work, I will be back
    Data Science training in Chennai
    Data science online training

    ReplyDelete
  10. I usually appreciate reading through high quality content articles through a person who's certainly educated on the selected topic. Sick end up being viewing this particular Digital Ocean vs Aws publish along with a lot curiosity. Continue the truly amazing function,

    ReplyDelete
  11. It is really a great work and the way in which you are sharing the knowledge is excellent.
    Aws Training in Hyderabad

    ReplyDelete
  12. Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging

    AWS Online Training
    AWS Certification Training
    AWS Certification Course Online
    AWS Training
    AWS Online Course

    ReplyDelete



  13. Quick up the best offer of AWS DevOps Training in Chennai from Infycle Technologies, Excellent software training in Chennai. A massive place to learn other technical courses like Power BI, Cyber Security, Graphic Design and Animation, Block Security, Java, Oracle, Python, Big data, Azure, Python, Manual and Automation Testing, DevOps, Medical Coding etc., with outstanding training with experienced trainers with a fresh environment with 100+ Live Practical Sessions and Real-Time scenario after the finalisation of the course the trainee will able to get through the interview in top MNC’s with an amazing package for more enquiry approach us on 7504633633, 7502633633.

    ReplyDelete
  14. Nice post you covered all importent points like What is EC2 in aws?,EC2 instances can be created using the AWS management console etc

    ReplyDelete
  15. Thanks for sharing this post. I got nice information from this blog. Please visit our website:- AWS solution architect course

    ReplyDelete