AWS Cloud Practitioner ‐ Module 2 - rFronteddu/general_wiki GitHub Wiki

Objectives:

  • Describe the benefits of Amazon EC2 at a basic level: EC2 (Amazon Elastic Cloud) provides secure, resizable compute capacity in the cloud as Amazon EC2 instances. It is Highly flexible, Cost effective, and quick.
  • Identify the different Amazon EC2 instance types: General Purpose, Compute optimized, Memory optimized, Accelerated computing, Storage optimized.
  • Differentiate between the various billing options for Amazon EC2: On-Demand, Saving plans, Reserved, Spot instances, Dedicated host.
  • Summarize the benefits of Amazon EC2 Auto Scaling.
  • Summarize the benefits of Elastic Load Balancing.
  • Give an example of the uses for Elastic Load Balancing.
  • Summarize the differences between Amazon Simple Notification Service (Amazon SNS) and Amazon Simple Queue Service (Amazon SQS).
  • Summarize additional AWS compute options.

EC2 Characteristics

  • Multitenancy: Sharing underlying hardware between virtual machines. The hypervisor managed by AWS is responsible for coordinating (and isolating) this multitenancy.
  • EC2 instances are configurable (what runs on them) and resizable (stats of the virtual machine, can be extended/virtually scaled)
  • Virtual Scaling - On demand making EC2 instances bigger or smaller. You also control network access to EC2 instances(what requests make it through, if they are pub or private)

How EC2 works

  • Launch: Select template with basic configurations for your instance (operating system, application server, or applications). You also select the instance type, which is the specific hardware configuration of your instance. Specify security settings to control the network traffic that can flow into and out of your instance.
  • Connect: Next, connect to the instance. You can connect to the instance in several ways.
  • Use: Once connected to the instance, you can run commands to install software, add storage, copy and organize files, and more.

EC2 Instance types

EC2 instances are optimized for different tasks. When selecting an instance type, consider the specific needs of your workloads and applications. This might include requirements for compute, memory, or storage capabilities.

  • General Purpose: General purpose instances provide a balance of compute, memory, and networking resources (application servers | gaming servers | backends | small/medium DBs).
  • Compute optimized: Ideal for compute-bound applications that benefit from high-performance processors (high-performance backends | compute-intensive applications | dedicated gaming servers | optimized large batch processing | many transactions in a single group)
  • Memory optimized: Designed to deliver fast performance for workloads that process large datasets in memory (High performance DB
  • Accelerated computing: Use hardware accelerators, or coprocessors, to perform some functions more efficiently (floating-point number calculations | graphics processing | data pattern matching).
  • Storage optimized: Designed for workloads that require high, sequential read/write access to large datasets on local storage (data-warehouse | distributed file systems | high-frequency online transaction processing (OLTP)). Storage optimized instances are designed to deliver tens of thousands of low-latency, random input/output operations per second (IOPS)to applications.

Pricing options

  • On-Demand (per hour, second, ..): ideal for short-term, irregular workloads that cannot be interrupted. No upfront costs or minimum contracts apply. They run continuously until you stopped, and you pay for only the compute time you use. Used for developing and testing applications and running applications that have unpredictable usage patterns, not recommended for workloads that last a year or longer because these workloads can experience greater cost savings using Reserved Instances.
  • Reserved instances for predictable use: Reserved Instances are a billing discount applied to the use of On-Demand Instances in your account. There are two types: Standard Reserved Instances and Convertible Reserved Instances purchasable for 1-year or 3-year term (more savings). Standard Reserved Instances are a good fit if you know the EC2 instance type and size you need for your steady-state applications and in which AWS Region you plan to run them. You must state instance type and size, platform description (OS/arch), tenancy (default/dedicated), (optionally) availability zone which ensures capacity reservation. Convertible Reserved Instances are to run EC2 instances in different Availability Zones or different instance types. You trade in a deeper discount when you require flexibility to run your EC2 instances. At the end of a Reserved Instance term, you can continue using the Amazon EC2 instance without interruption. However, you are charged On-Demand rates until you terminate the instance or purchase/renew a new Reserved Instance that matches the instance attributes.
  • Saving plans (low price in exchange for committed use over time): Savings Plans reduce your EC2 instance costs when you make an hourly spend commitment to an instance family and Region for a 1-year or 3-year term. This term commitment results in savings of up to 72 percent compared to On-Demand rates. Any usage up to the commitment is charged at the discounted Savings Plans rate (for example, $10 per hour). Any usage beyond the commitment is charged at regular On-Demand rates. The savings with EC2 Instance Savings Plans are similar to the savings provided by Standard Reserved Instances. They are a good option if you need flexibility in your Amazon EC2 usage over the duration of the commitment term in a chosen Region regardless of Availability Zone, instance size, OS, or tenancy. Unlike Reserved Instances, you don't need to specify up front type and size, OS, and tenancy to get a discount. Further, you don't need to commit to a certain number of EC2 instances over a 1-year or 3-year term. Additionally, the EC2 Instance Savings Plans don't include an EC2 capacity reservation option.
  • Spot instances (discounted but AWS can reclaim the instances if they need them): Spot Instances are ideal for workloads with flexible start and end times, or that can withstand interruptions. Spot Instances use unused Amazon EC2 computing capacity and offer you cost savings at up to 90% off of On-Demand prices. If you make a Spot request and Amazon EC2 capacity is available, your Spot Instance launches. However, if you make a Spot request and Amazon EC2 capacity is unavailable, the request is not successful until capacity becomes available. The unavailable capacity might delay the launch of your background processing job. After you have launched a Spot Instance, if capacity is no longer available or demand for Spot Instances increases, your instance may be interrupted.
  • Dedicated host(for compliance): Dedicated Hosts are physical servers with Amazon EC2 instance capacity that is fully dedicated to your use. You can use your existing per-socket, per-core, or per-VM software licenses to help maintain license compliance. You can purchase On-Demand Dedicated Hosts and Dedicated Hosts Reservations. Of all the Amazon EC2 options that were covered, Dedicated Hosts are the most expensive.

Scaling

Amazon EC2 Auto Scaling provides scalability (beginning with only the resources you need and designing your architecture to automatically respond to changing demand by scaling out or in) in AWS. Amazon EC2 Auto Scaling enables you to automatically add or remove Amazon EC2 instances in response to changing application demand. By automatically scaling your instances in and out as needed, you can maintain a greater sense of application availability.

Two approaches: dynamic scaling and predictive scaling.

  • Dynamic scaling responds to changing demand.
  • Predictive scaling automatically schedules the right number of Amazon EC2 instances based on predicted demand.

To scale faster, you can use dynamic scaling and predictive scaling together. By adding Amazon EC2 Auto Scaling to an application, you can add new instances to the application when necessary and terminate them when no longer needed. When you create an Auto Scaling group, you can set the minimum number of Amazon EC2 instances. The minimum capacity is the number of Amazon EC2 instances that launch immediately after you have created the Auto Scaling group. Next, you can set the desired capacity at two Amazon EC2 instances even though your application needs a minimum of a single Amazon EC2 instance to run. If you do not specify the desired number of Amazon EC2 instances in an Auto Scaling group, the desired capacity defaults to your minimum capacity. The third configuration that you can set in an Auto Scaling group is the maximum capacity. For example, you might configure the Auto Scaling group to scale out in response to increased demand, but only to a maximum of four Amazon EC2 instances.

Directing Traffic with Elastic Load Balancing

Elastic Load Balancing is the AWS service that automatically distributes incoming application traffic across multiple resources, such as Amazon EC2 instances.

A load balancer acts as a single point of contact for all incoming web traffic to your Auto Scaling group. This means that as you add or remove Amazon EC2 instances in response to the amount of incoming traffic, these requests route to the load balancer first. Then, the requests spread across multiple resources that will handle them. For example, if you have multiple Amazon EC2 instances, Elastic Load Balancing distributes the workload across the multiple instances so that no single instance has to carry the bulk of it.

Although Elastic Load Balancing and Amazon EC2 Auto Scaling are separate services, they work together to help ensure that applications running in Amazon EC2 can provide high performance and availability.

Messaging and Queuing

To help maintain application availability when a single component fails, you can design your application through a microservices approach. In a microservices approach, application components are loosely coupled. In this case, if a single component fails, the other components continue to work because they are communicating with each other. The loose coupling prevents the entire application from failing. When designing applications on AWS, you can take a microservices approach with services and components that fulfill different functions. Two services facilitate application integration: Amazon Simple Notification Service (Amazon SNS) and Amazon Simple Queue Service (Amazon SQS).

  • Amazon SNS: is a publish/subscribe service. Using Amazon SNS topics, a publisher publishes messages to subscribers.
  • Amazon SQS: is a message queuing service. Using SQS, you can send, store, and receive messages between software components, without losing messages or requiring other services to be available. In Amazon SQS, an application sends messages into a queue. A user or service retrieves a message from the queue, processes it, and then deletes it from the queue. For decoupled applications and microservices, Amazon SQS enables you to send, store, and retrieve messages between components.

Additional Compute Services

If you have applications that you want to run in Amazon EC2, you must 1) Provision instances (virtual servers), 2) Upload your code, and 3) continue to manage the instances while your application is running.

The term “serverless” means that your code runs on servers, but you do not need to provision or manage these servers. With serverless computing, you can focus more on innovating new products and features instead of maintaining servers. Furthermore serverless computing scales automatically. Serverless computing can adjust the applications' capacity by modifying the units of consumptions, such as throughput and memory.

AWS Lambda

AWS Lambda is a service that lets you run code without needing to provision or manage servers. While using AWS Lambda, you pay only for the compute time that you consume. Charges apply only when your code is running. You can also run code for virtually any type of application or backend service, all with zero administration. For example, a simple Lambda function might involve automatically resizing uploaded images to the AWS Cloud. In this case, the function triggers when uploading a new image.

How AWS Lambda works image

1 You upload your code to Lambda. 2 You set your code to trigger from an event source, such as AWS services, mobile applications, or HTTP endpoints. 3 Lambda runs your code only when triggered. 4 You pay only for the compute time that you use. In the previous example of resizing images, you would pay only for the compute time that you use when uploading new images. Uploading the images triggers Lambda to run code for the image resizing function.

Containers

In AWS, you can also build and run containerized applications.

Two services provide container orchestration in AWS: Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS).

  • Amazon ECS: is a highly scalable, high-performance container management system that enables you to run and scale containerized applications on AWS. Amazon ECS supports Docker containers. Docker is a software platform that enables you to build, test, and deploy applications quickly. AWS supports the use of open-source Docker Community Edition and subscription-based Docker Enterprise Edition. With Amazon ECS, you can use API calls to launch and stop Docker-enabled applications.
  • Amazon EKS: is a fully managed service that you can use to run Kubernetes on AWS. Kubernetes is open-source software that enables you to deploy and manage containerized applications at scale.
  • AWS Fargate: is a serverless compute engine for containers. It works with both Amazon ECS and Amazon EKS. When using AWS Fargate, you do not need to provision or manage servers. AWS Fargate manages your server infrastructure for you. You can focus more on innovating and developing your applications, and you pay only for the resources that are required to run your containers.