AWS/Cloud Practitioner Certificate

[Cloud Practitioner] Amazon EC2 (Module 2)

brightlightkim 2022. 5. 1. 14:33

  • AWS helps with server stuff
    • AWS built datacenters
    • AWS secured datacenters
    • AWS purchased servers
    • AWS installed servers
    • The servers are online and ready to use
  • AWS let you pay for what you use
    • Virtual Machine Technology
  • Multitenancy: Sharing underlying hardware between virtual machines
    • EC2 Instance is secured
      • one instance is separate from each other
  • Amazon EC2 configurations
    • Windows
    • Linux
    • Internal business apps
    • Web apps
    • Databases
    • Third-party software
  • Vertical scaling: Resizable
  • You control networking aspect of Amazon EC2

 

 

Amazon Elastic Compute Cloud (Amazon EC2)

Amazon Elastic Compute Cloud (Amazon EC2) provides secure, resizable compute capacity in the cloud as Amazon EC2 instances. 

Imagine you are responsible for the architecture of your company's resources and need to support new websites. With traditional on-premises resources, you have to do the following:

 

  • Spend money upfront to purchase hardware.
  • Wait for the servers to be delivered to you.
  • Install the servers in your physical data center.
  • Make all the necessary configurations.

By comparison, with an Amazon EC2 instance you can use a virtual server to run applications in the AWS Cloud.

  • You can provision and launch an Amazon EC2 instance within minutes.
  • You can stop using it when you have finished running a workload.
  • You pay only for the compute time you use when an instance is running, not when it is stopped or terminated.
  • You can save costs by paying only for server capacity that you need or want.

How Amazon EC2 works

1. Launch

First, you launch an instance. Begin by selecting a template with basic configurations for your instance. These configurations include the operating system, application server, or applications. You also select the instance type, which is the specific hardware configuration of your instance. 

 

As you are preparing to launch an instance, you specify security settings to control the network traffic that can flow into and out of your instance. Later in this course, we will explore Amazon EC2 security features in greater detail.

 

2. Connect

Next, connect to the instance. You can connect to the instance in several ways. Your programs and applications have multiple different methods to connect directly to the instance and exchange data. Users can also connect to the instance by logging in and accessing the computer desktop.

 

3. Use

After you have connected to the instance, you can begin using it. You can run commands to install software, add storage, copy and organize files, and more.

 

Different Types of EC2 Available

  • Each Amazon EC2 instance type is grouped under an instance family
    • optimized for certain types (flexibility)
  • General Purpose
    • General purpose instances provide a balance of compute, memory, and networking resources. You can use them for a variety of workloads, such as:
        • application servers
        • gaming servers
        • backend servers for enterprise applications
        • small and medium databases
    • Balanced resources
    • Diversed workloads
    • Web servers
    • Code repositories
  • Compute Optimized
    • Compute optimized instances are ideal for compute-bound applications that benefit from high-performance processors. 
    • Compute intensive tasks
    • Gaming servers
    • high performance computing (HPC)
    • Scientific modeling
  • Memory Optimized
    • Memory optimized instances are designed to deliver fast performance for workloads that process large datasets in memory.
    • Memory Intensive tasks
  • Accelerated Computing
    • Accelerated computing instances use hardware accelerators, or coprocessors, to perform some functions more efficiently than is possible in software running on CPUs. 
    • In computing, a hardware accelerator is a component that can expedite data processing. Accelerated computing instances are ideal for workloads such as graphics applications, game streaming, and application streaming.
    • Floating point number calculations
    • Graphics processing
    • Data pattern matching
    • Utilize hardware accelerators
  • Storage Optimized
    • Storage optimized instances are designed for workloads that require high, sequential read and write access to large datasets on local storage.
    • High performance for locally stored data

 

Amazon EC2 Pricing

  • On-Demand
    • On-Demand Instances are ideal for short-term, irregular workloads that cannot be interrupted. 
    • On-Demand Instances are not recommended for workloads that last a year or longer because these workloads can experience greater cost savings using Reserved Instances.
    • Only Pay for when the instance runs for
    • No upfront payment is needed
    • Don't need prior contract.
  • Amazon EC2 Savings Plan
    • Amazon EC2 Savings Plans enable you to reduce your compute costs by committing to a consistent amount of compute usage 
    • Low Cost Plan (1 or 3 year term)
    • 72% lower price
    • AWS Fargate...etc
    •  AWS Cost Explorer, a tool that enables you to visualize, understand, and manage your AWS costs and usage over time
  • Reserved Instances
    • Reserved Instances are a billing discount applied to the use of On-Demand Instances in your account. 
    • You can purchase Standard Reserved and Convertible Reserved Instances for a 1-year or 3-year term, and Scheduled Reserved Instances for a 1-year term. You realize greater cost savings with the 3-year option.
    • Predictable Usage
    • 75% discount (one or three years term)
    • 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 do one of the following:
      • Terminate the instance.
      • Purchase a new Reserved Instance that matches the instance attributes (instance type, Region, tenancy, and platform).
  • Spot Instances
    • 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.
    • Suppose that you have a background processing job that can start and stop as needed (such as the data processing job for a customer survey). You want to start and stop the processing job without affecting the overall operations of your business. 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. This might not pose any issues for your background processing job. However, in the earlier example of developing and testing applications, you would most likely want to avoid unexpected interruptions. Therefore, choose a different EC2 instance type that is ideal for those tasks.
  • Dedicated Hosts
    • 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

  • Scalability and Elasticity
  • Solve problems with on-premises

Scalability

Scalability involves beginning with only the resources you need and designing your architecture to automatically respond to changing demand by scaling out or in. As a result, you pay for only the resources you use. You don’t have to worry about a lack of computing capacity to meet your customers’ needs.

If you wanted the scaling process to happen automatically, which AWS service would you use? The AWS service that provides this functionality for Amazon EC2 instances is Amazon EC2 Auto Scaling.

Amazon EC2 Auto Scaling

If you’ve tried to access a website that wouldn’t load and frequently timed out, the website might have received more requests than it was able to handle. This situation is similar to waiting in a long line at a coffee shop, when there is only one barista present to take orders from customers.

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 are able to maintain a greater sense of application availability.

 

Within Amazon EC2 Auto Scaling, you can use 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.

 

Example: Amazon EC2 Auto Scaling

In the cloud, computing power is a programmatic resource, so you can take a more flexible approach to the issue of scaling. 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.

Suppose that you are preparing to launch an application on Amazon EC2 instances. When configuring the size of your Auto Scaling group, you might set the minimum number of Amazon EC2 instances at one. This means that at all times, there must be at least one Amazon EC2 instance running.

 

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. In this example, the Auto Scaling group has a minimum capacity of one Amazon EC2 instance.

 

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.

 

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.

 

Because Amazon EC2 Auto Scaling uses Amazon EC2 instances, you pay for only the instances you use, when you use them. You now have a cost-effective architecture that provides the best customer experience while reducing expenses.

Directing traffic with Elastic Load Balancing

Elastic Load Balancing

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

(Regional Construct)

 

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. 

 

Benefits:

  • High Performance
  • Cost-efficient
  • Highly available
  • Automatically scalable

 

Example:

And ELB solved this as well.

 

Low-demand period

Here’s an example of how Elastic Load Balancing works. Suppose that a few customers have come to the coffee shop and are ready to place their orders. 

If only a few registers are open, this matches the demand of customers who need service. The coffee shop is less likely to have open registers with no customers. In this example, you can think of the registers as Amazon EC2 instances.

High-demand period

Throughout the day, as the number of customers increases, the coffee shop opens more registers to accommodate them. In the diagram, the Auto Scaling group represents this.

 

Additionally, a coffee shop employee directs customers to the most appropriate register so that the number of requests can evenly distribute across the open registers. You can think of this coffee shop employee as a load balancer. 

 

Messaging and queuing

Monolithic applications and microservices

 

Applications are made of multiple components. The components communicate with each other to transmit data, fulfill requests, and keep the application running. 

Suppose that you have an application with tightly coupled components. These components might include databases, servers, the user interface, business logic, and so on. This type of architecture can be considered a monolithic application

In this approach to application architecture, if a single component fails, other components fail, and possibly the entire application fails.

 

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 Simple Notification Service (Amazon SNS)

Amazon Simple Notification Service (Amazon SNS) is a publish/subscribe service. Using Amazon SNS topics, a publisher publishes messages to subscribers. This is similar to the coffee shop; the cashier provides coffee orders to the barista who makes the drinks.

 

In Amazon SNS, subscribers can be web servers, email addresses, AWS Lambda functions, or several other options

 

EXAMPLE:

STEP1: Publishing updates from a single topic

Suppose that the coffee shop has a single newsletter that includes updates from all areas of its business. It includes topics such as coupons, coffee trivia, and new products. All of these topics are grouped because this is a single newsletter. All customers who subscribe to the newsletter receive updates about coupons, coffee trivia, and new products.

 

After a while, some customers express that they would prefer to receive separate newsletters for only the specific topics that interest them. The coffee shop owners decide to try this approach.

STEP2: Publishing updates from multiple topics

Now, instead of having a single newsletter for all topics, the coffee shop has broken it up into three separate newsletters. Each newsletter is devoted to a specific topic: coupons, coffee trivia, and new products.

 

Subscribers will now receive updates immediately for only the specific topics to which they have subscribed.

 

It is possible for subscribers to subscribe to a single topic or to multiple topics. For example, the first customer subscribes to only the coupons topic, and the second subscriber subscribes to only the coffee trivia topic. The third customer subscribes to both the coffee trivia and new products topics.

 

Although this example from the coffee shop involves subscribers who are people, in Amazon SNS, subscribers can be web servers, email addresses, AWS Lambda functions, or several other options.

 

Amazon Simple Queue Service (Amazon SQS)

Amazon Simple Queue Service (Amazon SQS) is a message queuing service

Using Amazon 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.

 

EXAMPLE: Fulfilling an order

Suppose that the coffee shop has an ordering process in which a cashier takes orders, and a barista makes the orders. Think of the cashier and the barista as two separate components of an application.

 

First, the cashier takes an order and writes it down on a piece of paper. Next, the cashier delivers the paper to the barista. Finally, the barista makes the drink and gives it to the customer.

 

When the next order comes in, the process repeats. This process runs smoothly as long as both the cashier and the barista are coordinated.

 

What might happen if the cashier took an order and went to deliver it to the barista, but the barista was out on a break or busy with another order? The cashier would need to wait until the barista is ready to accept the order. This would cause delays in the ordering process and require customers to wait longer to receive their orders.

 

As the coffee shop has become more popular and the ordering line is moving more slowly, the owners notice that the current ordering process is time consuming and inefficient. They decide to try a different approach that uses a queue.

Recall that the cashier and the barista are two separate components of an application. A message queuing service such as Amazon SQS enables messages between decoupled application complements.

 

In this example, the first step in the process remains the same as before: a customer places an order with the cashier. 

 

The cashier puts the order into a queue. You can think of this as an order board that serves as a buffer between the cashier and the barista. Even if the barista is out on a break or busy with another order, the cashier can continue placing new orders into the queue. 

 

Next, the barista checks the queue and retrieves the order.

 

The barista prepares the drink and gives it to the customer. 

 

The barista then removes the completed order from the queue. 

 

While the barista is preparing the drink, the cashier is able to continue taking new orders and add them to the queue.

 

For decoupled applications and microservices, Amazon SQS enables you to send, store, and retrieve messages between components.

 

This decoupled approach enables the separate components to work more efficiently and independently. 

 

Additional Compute Services

EC2

  • Flexible
  • Reliable
  • Scalable

Patching Instances and Scaling in Highly 

Management in places

 

Other Services for Management Process >> Serverless or ECS

  • Serverless: You cannot see or access underlying instances
    • Lambda
      • one serverless compute option
      • allows you to upload your code and Lambda function
      • Trigger is detacted >> run in the environment
      • Run under 15 min (so not deep learning)
    • AWS Fargate
      • Serverless Compute Service for ECS or EKS
  • Amazon Elastic Container Service (AWS ECS)
    • Help it to run it as a scale
    • Container orchestration tools
      • Clusters (with containers) 
      • Docker Container
        • package for your code
  • Amazon Elastic Kubernetes Service (AWS EKS)
    • Use a different tooling
    • Container orchestration tools
      • Docker Container
        • package for your code

 

How to Choose Compute services:

  • Amazon EC2
    • Host traditional applications
    • Full access to the OS (Window Linux)
  • AWS Lambda
    • Host short running functions
    • Service-oriented applications
    • Event driven applications
    • No provisioning or managing servers
  • Amazon ECS or Amazon EKS
    • Run Docker container-based workloads on AWS
  • How to manage?
    • Amazon EC2
    • AWS Fargate

 

Serverless computing

Earlier in this module, you learned about Amazon EC2, a service that lets you run virtual servers in the cloud. If you have applications that you want to run in Amazon EC2, you must do the following:

  • Provision instances (virtual servers).
  • Upload your code.
  • 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.

Another benefit of serverless computing is the flexibility to scale serverless applications automatically. Serverless computing can adjust the applications' capacity by modifying the units of consumptions, such as throughput and memory. 

An AWS service for serverless computing is AWS Lambda.

 

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. 

  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.

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


Containers

Containers provide you with a standard way to package your application's code and dependencies into a single object. You can also use containers for processes and workflows in which there are essential requirements for security, reliability, and scalability.

EXAMPLE: One host with multiple containers

Suppose that a company’s application developer has an environment on their computer that is different from the environment on the computers used by the IT operations staff. The developer wants to ensure that the application’s environment remains consistent regardless of deployment, so they use a containerized approach. This helps to reduce time spent debugging applications and diagnosing differences in computing environments.

 

Tens of hosts with hundreds of containers

When running containerized applications, it’s important to consider scalability. Suppose that instead of a single host with multiple containers, you have to manage tens of hosts with hundreds of containers. Alternatively, you have to manage possibly hundreds of hosts with thousands of containers. At a large scale, imagine how much time it might take for you to monitor memory usage, security, logging, and so on.

 

Summary:

Container orchestration services help you to deploy, manage, and scale your containerized applications. Next, you will learn about two services that provide container orchestration: Amazon Elastic Container Service and Amazon Elastic Kubernetes Service.

 

Amazon Elastic Container Service (Amazon ECS)

Amazon Elastic Container Service (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 Elastic Kubernetes Service (Amazon EKS)

Amazon Elastic Kubernetes Service (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. A large community of volunteers maintains Kubernetes, and AWS actively works together with the Kubernetes community. As new features and functionalities release for Kubernetes applications, you can easily apply these updates to your applications managed by Amazon EKS.

AWS Fargate

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.

 

 

 

 

'AWS > Cloud Practitioner Certificate' 카테고리의 다른 글

[Cloud Practitioner] Cloud computing  (0) 2022.05.01