AWS – Compute – EC2

Reading Time: 6 minutes

In the previous post, we have seen an overview of services offered by AWS under Compute category. Below is some of the key information about EC2

EC2 – Key Points

  • You can run a maximum of 20 On-Demand instances per instance family.
  • You can purchase a maximum of 20 Reserved instances.
  • You can request Spot instances as per your dynamic spot limit per region.
  • EC2 Supports various operating systems like, Amazon Linux, Red Hat Enterprise Linux, Open SUSE, Oracle Linux, Gentoo Linux, Ubuntu, Fedora, Debian, Free BSD and Windows server.
  • EC2 instances are billed when they are in running state, We can stop/terminate an instance to stop paying for it.
  • All EC2 instances are charged either by hour/second. You may choose to be charged by second in Linux instances.
  • Both inbound and outbound Data transfers between the instances in different regions are charged.
  • Data transfers between instances in the same regions are charged if one of the instance is in a different availability zone or one of the instance is configured with public or elastic IP address

EC2 – Instance Types

EC2 instance come in various types depending upon you computation needs. below are some of the EC2 instance families and their purpose

EC2 Instances By Category and Family

EC2 Instance Family by Use Case.

EC2 – Billing and Provisioning

EC2 Instances can be provisioned in 4 ways

On Demand:

  • Pay as you go with no commitment required
  • Low cost option with no upfront cost
  • Can be scaled automatically depending upon workloads

Reserved:

  • Instance capacity will be reserved for 1 to 3 years.
  • Standard instances will be charged even when the service is not in use.
  • Scheduled instances will be provisioned for specific periods of time and charged monthly for atleast one year.
  • Could get good discounts of payed upfront.
  • Can switch AZs within same region.
  • Linux instances can be changed to a different instance types but windows cannot.
  • Customers can sell their reservations on amazon market place
  • Can be used in auto-scaling groups and placement groups.

Spot:

  • Customers can bid for instances based on the region’s bid price
  • Low hourly compute cost.
  • Will be started automatically if the bid price matches
  • Cannot use encrypted volumes

Dedicated Hosts and Instances:

  • Physically dedicated EC2 servers
  • Isolated from other instances
  • Very expensive when compared to others
  • Billing is per host
  • Dedicated instances have lesser visibility than dedicated hosts in terms of sockets, cores, Host ID etc.

Creating an EC2 Instance

Choose an AMI :

  • AMI (Amazon Machine Image) is a template that contains the software configuration (operating system, application server, and applications) required to launch your instance. You can select an AMI provided by AWS, or from the user community, or from the AWS Marketplace; or you can select one of your own AMIs.
  • AMIs also contains a block device mapping that specifies the volumes to be attached to the instance when it’s launched.
  • AMI’s are regional. However, you can copy an AMI across multiple regions using CLI , AWS API or the AWS console.

Choose and Configure an Instance Type:

  • Amazon EC2 provides a wide selection of instance types optimized to fit different use cases.
  • Instances are virtual servers that can run applications. They have varying combinations of CPU, memory, storage, and networking capacity, and give you the flexibility to choose the appropriate mix of resources for your applications.
  • You can choose to auto assign a Public IP or use the default subnet in any availability zone within the region.
  • You can add an instance to a placement group to get higher networking throughput.
  • Instances can be assigned to IAM roles that enables users in that role access the AWS resources.
  • Instances can be protected from termination. Default option is to stop the instance but not terminate them
  • Choose to run the run the instance as shared, dedicated instance or dedicated host. Default option is to run as shared instance.

Add Storage:

  • You can ttach additional EBS volumes and instance store volumes to your instance, or edit the settings of the root volume. You can also attach additional EBS volumes after launching an instance, but not instance store volumes.
  • Non Root volumes can be encrypted. Root volumes launched from an encrypted AMI can be encrypted.
  • Windows instances can join a directory and are also provided with an option for elastic GPU.

Add Tags:

  • A tag consists of a case-sensitive key-value pair. For example, you could define a tag with key = Name and value = Webserver.
    A copy of a tag can be applied to volumes, instances or both.
    Tags will be applied to all instances and volumes.

Configure Security Groups:

  • A security group is a set of firewall rules that control the traffic for your instance.
  • You can add rules to allow specific traffic to reach your instance. For example, if you want to set up a web server and allow Internet traffic to reach your instance, add rules that allow unrestricted access to the HTTP and HTTPS ports.
  • You can create a new security group or select from an existing one.

Access EC2 Instance:

  • You can securely access an EC2 instance using Key Pairs.
  • A Key pair consist of a Public key that AWS stores and a private Key that you store on the host machine from which you want to access the EC2 instance.
  • Using the private key you can SSH to the EC2 instance.

Monitoring EC2 instances

  • By Default EC2 status checks ate performed every minute and return pass/fail/OK/Impaied/StatusCheckFailed_System/StatusCheckFailed_instance.
  • when the status is “StatusCheckFailed_System” it needs AWS involvement to fix the issue and when the status is “StatusCheckFailed_instance” you need to fix the instance.
  • You can create Amazon CloudWatch alarms to monitor EC2 instances and automatically take actions on the instances in case of an errors.
  • Actions can be Recover/Reboot/Stop/Terminate instance.

Migrating EC2 Instances

  • You can import/export EC2 instances as images using VM/import/export tool. that allows you to convert EC2 instances to VMware, Microsoft or XEN Vms.
  • Through AWS VM connector plugin an existing VM can be converted to S3 and then to an EC2 AMI.

Share
Close Menu