2022-01-22 Chapter 6 - Elastic Compute Cloud (EC2)
February 12, 2022•1,296 words
service-ec2-001; Elastic Compute Cloud (EC2); Secure, resizable compute capacity in the cloud.
service-ec2-002; EC2 operates like a {{c1::virtual machine}} hosted in {{c1::an AWS data center}} rather than {{c1::your own data center}}.
service-ec2-003; There are four different pricing options for EC2: {{c1::On-Demand, Reserved, Spot and Dedicated}}.
service-ec2-004; On-demand instances offer flexibility because there are {{c1::no up-front costs}}. It's also useful for applications with {{c1::short-term, spiky or unpredictable}} workloads, or for {{c1::testing}}.
service-ec2-005; Reserved instances are reserved for {{c1::1 or 3 years}}. These are useful for {{c1::predictable}} usage or where it makes financial sense to {{c1::pay up-front to reduce overall costs}}.
service-ec2-006; There are two subsets of reserved instances: {{c1::scheduled RIs}} where reserved capacity is provisioned on a schedule and {{c1::convertible RIs}} where you can change to {{c1::a more expensive instance type}} if needed.
service-ec2-007; An EC2 instance reservation is {{c1::region}}-specific.
service-ec2-008; Spot instances are {{c1::unused}} capacity purchased at a discount of {{c1::up to 90%}}. Prices are set based on {{c1::supply and demand}}. These are useful for applications which have {{c1::flexible start and end times}}, and/or applications which are {{c1::cost-sensitive}}.
service-ec2-009; Examples of use cases for spot instances are {{c1::stateless}}, {{c1::fault-tolerant}} or {{c1::flexible}} workloads e.g. {{c1::big data & analytics}}, {{c1::image rendering}}, {{c1::genomic sequencing}}, {{c1::algorithmic trading engines}} or {{c1::test/development workloads}}.
service-ec2-010; Dedicated hosts are useful to meet {{c1::regulatory requirements}} or support {{c1::special per-socket, per-core or per-VM software licensing (e.g. Microsoft/Oracle)}} that may forbid multi-tenant virtualisation.
service-ec2-011; Dedicated hosts can be purchased {{c1::on-demand}} or {{c1::reserved}}.
service-ec2-012; AWS offer a {{c1::pricing calculator}} hosted at calculator.aws.
service-ec2-013; AWS provide a {{c1::command line interface}} (CLI).
service-ec2-014; You can set credentials (IAM access key ID and secret access key) to use with the AWS CLI using the command {{c1::[aws configure]}}.
service-ec2-015; The AWS CLI is supported on {{c1::Linux}}, {{c1::Windows}} or {{c1::MacOS}}.
service-ec2-016; Security groups are {{c1::virtual firewalls}} for EC2 instances. By default, all inbound traffic is {{c1::blocked}}. In order to communicate with EC2 instances via SSH/RDP/HTTP, you need to {{c1::open the correct port(s)}}. All outbound traffic is {{c1::allowed}}.
service-ec2-017; Changes to EC2 security groups take effect {{c1::immediately}}.
service-ec2-018; You can have {{c1::any number of}} EC2 instances within a security group.
service-ec2-019; You can have {{c1::multiple}} security groups attached to EC2 instances.
service-ec2-020; A bootstrap script (a.k.a. {{c1::user data}}) runs when an EC2 instance {{c1::first runs}}. This can be used to {{c1::automate the installation of applications or updates}}.
service-ec2-021; EC2 metadata is data about an EC2 instance, including {{c1::private IP address}}, {{c1::public IP address}}, {{c1::hostname}} and {{c1::security groups}}.
service-ec2-022; You can retrieve EC2 instance metadata from the command line by running a {{c1::HTTP GET request against 169.254.169.254/latest/meta-data}} .
service-ec2-023; You can retrieve EC2 instance user data (a.k.a. {{c1::bootstrap script}}) from the command line by running a {{c1::HTTP GET request against 169.254.169.254/latest/user-data}} .
service-ec2-024; You can attach three different types of virtual networking cards to EC2 instances: 1) {{c1::elastic network interface (ENI)}} for {{c1::basic day-to-day}} networking 2) {{c1::enhanced networking (EN)}} with single root I/O virtualisation (SR-IOV) for {{c1::high-performance}} or 3) {{c1::elastic fabric adaptor (EFA)}} to accelerate high performance computing (HPC) and machine learning applications.
service-ec2-025; An {{c1::elastic network interface (ENI)}} is a low-budget, high-availability virtual network card that allows the following options: private IPv4 addresses, a public IPv4 address, many IPv6 addresses, a MAC address and one or more security groups.
service-ec2-026; {{c1::Elastic network interfaces (ENIs)}} allow you to create a management network and use network and security appliances in your VPC. You can create dual-homed instance with workloads/roles on distinct subnets.
service-ec2-027; {{c1::Enhanced networking (EN)}} is for high-performance networking between 10 Gbps and 100 Gbps.
service-ec2-028; Two flavours of enhanced networking (EN) are {{c1::enhanced network adaptor (ENA)}} supporting network speeds of up to 100 Gbps for supported instance types and the {{c1::Intel 82599 virtual function (VF)}} interface, supporting networking speeds of up to {{c1::10 Gbps}} for supported {{c1::instance types}}. The latter is typically used on {{c1::older}} instance types. For almost all scenarios, {{c1::ENA}} is likely to be preferable over {{c1::VF}}.
service-ec2-029; {{c1::Elastic Fabric Adaptor (EFA)}} provides lower latency and higher throughput than {{c1::TCP transport}} traditionally used in cloud-based HPC systems.
service-ec2-030; Elastic Fabric Adaptor (EFA) can use {{c1::OS-bypass}}, allowing HPC and machine learning applications to {{c1::bypass the operating system kernel}} and {{c1::communicate directly}} with the EFA device. This is only supported on Linux as of July 2021. This offers significantly higher speed and lower latency.
service-ec2-031; An EC2 placement group is a {{c1::logical grouping}} of EC2 instances. Three types of EC2 placement groups are 1) {{c1::cluster}} 2) {{c1::spread}} and 3) {{c1::partition}}.
service-ec2-032; A cluster EC2 placement group is a grouping of instances in a single {{c1::availability zone}}. This allows low latency and high throughput. Only certain types of {{c1::instance}} can be launched into a cluster placement groups ({{c1::compute optimised, GPU, memory optimised and storage optimised}}).
service-ec2-033; AWS recommends {{c1::homogenous}} instances within cluster placement groups.
service-ec2-034; A spread EC2 placement group is a grouping of instances that are each placed on {{c1::distinct underlying hardware}}. These are recommended for applications that have {{c1::individual critical instances}} that should be kept {{c1::separate from one another}}.
service-ec2-035; A partition EC2 placement group is a distinct set of {{c1::racks}}. Each {{c1::rack}} has its own network and power source, and no two partitions within a placement group share a set of {{c1::racks}}, in order to isolate the impact of {{c1::hardware failure}}.
service-ec2-036; {{c1::Spread}} and {{c1::partition}} EC2 placement groups can span multiple {{c1::availability zones}}.
service-ec2-037; It's {{c1::not possible}} to merge EC2 placement groups.
service-ec2-038; It's possible to {{c1::move an existing instance}} into a placement group. It must be in the {{c1::stopped}} state before you can {{c1::move it}}.
service-ec2-039; To use spot instances, you decide on your {{c1::maximum spot price}}. The instance will be provisioned so long as the {{c1::spot price}} is below your {{c1::maximum spot price}}.
service-ec2-040; The hourly EC2 spot price varies depending on {{c1::capacity}} and {{c1::region}}.
service-ec2-041; If EC2 spot price goes above {{c1::the maximum}} you have two minutes to choose whether to {{c1::stop}} or {{c1::terminate}} your instances.
service-ec2-042; You may use an EC2 {{c1::spot block}} to stop spot instances from being {{c1::terminated}} even if the spot price exceeds your {{c1::maximum spot price}}. Currently it's possible to set spot blocks for between {{c1::1 and 6 hours}}.
service-ec2-043; EC2 spot instances are not useful for {{c1::persistent workloads}}, {{c1::critical jobs}} or {{c1::databases}}.
service-ec2-044; Spot requests can be {{c1::one-time}} or {{c1::persistent}}. {{c1::Persistent}} requests are valid between a given {{c1::date range}}. To terminate {{c1::persistent}} spot request instances, you must first cancel the request.
service-ec2-045; A {{c1::spot fleet}} is a collection of spot instances and (optionally) on-demand instances. It attempts to maintain a target number of instances, taking into account the {{c1::spot price}} and {{c1::capacity availability}} and following a given strategy. A {{c1::spot fleet}} can comprise multiple {{c1::launch pools}} which specify instance type, OS or AZ.
service-ec2-046; A {{c1::spot fleet}} can follow different strategies: 1) capacityOptimized where instances launching come from pool with {{c1::optimal capacity}} 2) lowestPrice where instances launching come from the pool with the {{c1::lowest price}} ({{c1::default}} strategy) 3) diversified where spot instances are distributed across {{c1::all pools}} or 4) InstancePoolsToUseCount where instances are distributed across {{c1::a given count of pools}}, in conjunction with lowestPrice.
service-ec2-047; You can attach a network interface to an instance when it's {{c1::running}} (hot attach), when it's {{c1::stopped}} (warm attach), or when the instance is being {{c1::launched}} (cold attach). You can detach secondary network interfaces when the instance is running or stopped. However, you can't detach the primary network interface.
service-ec2-048; The {{c1::Reserved Instance Marketplace}} is a platform that supports the sale of third-party and AWS customers' unused Standard Reserved Instances, which vary in term lengths and pricing options. For example, you may want to sell Reserved Instances after moving instances to a new AWS Region, changing to a new instance type, ending projects before the term expiration, when your business needs change, or if you have unneeded capacity.