Tuesday, December 31, 2019

EC2-I-Whitepaper


Clustered Placement Group: Within the same AG, when low network latency /high throughput required. They are always in the same AZ and region. Only certain instances can be launched in to a clustered placement group. Cannot spread multiple AZs.
Spread Placement Group: Individual critical EC2 instances. Each instances are placed on different underlying hardware. For application that have a small number of instances and that should kept separate from each other to have least impact from failure.They can spam in multiple AZ’s within the same region. Max  7 running instances per AZ. Here the VMs are on different hypervisor , its alowed to use different instance type.
-Max 7 instances per AZ in a group allowed.
-Not supported for dedicated hosts or instances option.
Portioned placement group: Each partition within a placement group has its own set of racks. Each rack has its own network and  power  sources. No two partitions within a placement group share the same racks allowing you to isolate the impact of hardware failure within your application.Every instance has replica.
Multiple EC2 instances HDFS, HBase, Cassandra . They can spam in multiple AZ’s within the same region.

The name specified for placement group must be unique within my aws account.
Only certain types of instances can be launched in a placemen group. (Compute Optimized/ GPU/memory/Storage optimized).
-Recommended homogeneous instances within clustered placement groups.
-Placement groups can’t be merged
-You can’t move an existing instance into a placement group. You can create an AMI from existing instance. And launch a new instance from AMI into a placement group.

EC2:
On Demands
Reserved : 1/3 yrs contract
Spot : Stock Market. If I terminate the instances it will be charged for any hour in which the instatnce Run, amzn does not charge for partial hours for every single instances,
Dedicated Hosts: When regultatory compliance reqiored or server bound licensing neede,
Instance Typs: FIGHT DRMCPX ZAU
If IP address is changed use, Elastic IP address
EBS:
A virtual  hard disk in cloud
Ec2 instances : You must turn on termination protection.
EBS bacled instances. Root EBS volume to be deleted when the instance in terminated. Additionaly attached volume wont be deleted by default.
I can detach additional EBS volume without stopping the instance.
An EBS volume can be attached to only one instance at a time, but multiple volumes can be attached to a single instance
EBS root volume can be encrypted.
Root volume persists when the instance stops but deleted when instance terminates.
Data on any other ebs volume persists during termination.

Security Group:
-Stateful.
All inbound traffic is blocked by default. All Outbound traffic is allowed.
Change to security group takes effect immediately
You can any number of Ec2 instances running within a security group.
You can have multiple security group attached to  the Ec2 instances.
Network access control list Block IP addresses

EBS Types:
General purpose to throughput optomised HDD.
Provioson IOPS SSD : data base 4 GB to 16 TB
General purpose SSD: 1 GB to 16 TB
For less frequently workloads: Lowest cost : Cold HDD

Smapshot Exists in S3 and is incremental.
For cosnsistencey stop the instances before taking a snapshots.
AMI can be created from both volume and snapshots.
You can change EBS volume on the fly including size and storage types.
EBS Volume will always be in the same AZ as the EC2.
To migrate EC2 volume from one AZ to another, take a snapshot and create AMI from the snapshot . Use AMI to launch EC2 insances in a new AZ.
Instance Profile:
- An instance profile is a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts.

- With IAM roles for Amazon ECS tasks, you can specify an IAM role that can be used by the containers in a task.
 - Amazon EC2 instance profiles provide credentials to EC2 instances.

Instance Store volume /Ephermal Storage:
Temporary block level storage for your instace. When we terminate the instance, Instance store is also gets lost. It resides to the diska that are physically located on the same node.
Instance Store volume can be added only to the selected instance. Not available for all types of instances.
Instance store can only be in running or terminated states.
Instance store size depneds on the instance type selected at the time of launc of instance.
Bootsrap Script: Run when Ec2 isntance starts. Useful for installation software and updates.
Cloud HSM : Used for EC2 encryption.
Instance metadata :  Data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories, for example, host name, events, and security groups.
User data: You can also use instance metadata to access user data that you specified when launching your instance. 
/latest/meta-data
/latest/user-data
http://169.254.169.254/latest/meta-data
The Instance Metadata Query tool allows you to query the instance metadata without having to type out the full URI or category names.

- Instances are backed up using AMIs.
ELB:
When there is huge traffic, network load balancer suits best for high performance.
Classic load balancer gives both option https/s and tcp (application and netwok) level balancer   .

EC2 Auto Scaling:
-If connection draining is enabled, Auto Scaling waits for in-flight requests to complete or timeout before terminating instances.
Instance/Terminating Scaling In Logic:
1> If there are instances in multiple availability zones, select the AZa with maximum number if instances. 
2> Then it select the instance with oldest launch confiIguration will be terminated.
3> If there are multiple instances using the oldest launch config, choose the instances which is closest to  next billing hours.
Cooldown period
- The health check grace period allows a period of time for a new instance to warm up before performing a health check (300 seconds by default)
-With a cooldown period in place, the Auto Scaling group launches an instance and then suspends scaling activities due to simple scaling policies or manual scaling until the specified time elapses. (The default is 300 seconds.) 
  
Both the ALB and NLB support WebSockets. However, only the ALB supports HTTP/HTTPS listeners. The NLB only supports TCP, TLS, UDP, TCP_UDP.
- The CLB does not support WebSockets.
- A “Layer-4 Load Balancer” is not suitable, we need a layer 7 load balancer for HTTP/HTTPS.

Life Cycle Hooks: Adding life cycle hooks to Auto scaling group puts the instance into waiting state. During this time you can perform custom activities to retreive critical operational data from a stateful instance.

Instance Launch: Pending -> Pending wait-  pre launch  custom action > In Service.
In Service Launch: Pending -> Pending wait-  pre terminate custom action  > Terminated.


No comments:

Post a Comment