1 - Ec2
1 - Ec2
REFERENCE LINKS
Amazon EC2 - Cloud Compute Capacity - AWS
Amazon EC2 Documentation
1. Sign Up for AWS: Go to the AWS website and sign up for an account. AWS offers a free tier that
includes limited usage of EC2 instances.
2. Open the EC2 Dashboard: Once logged in, navigate to the EC2 Dashboard from the AWS
Management Console.
3. Launch an Instance:
○ Choose an Amazon Machine Image (AMI): Select a pre-configured template (e.g.,
Ubuntu, Windows Server).
○ Choose an Instance Type: Select the hardware configuration. For beginners, the
t2.micro instance type is a good start as it's free-tier eligible.
○ Configure Instance Details: Set the number of instances, network settings, and more.
○ Add Storage: Define the size and type of storage for your instance.
○ Add Tags: Assign metadata to your instance for easier management.
○ Configure Security Group: Set up firewall rules to allow specific traffic (e.g., SSH for
Linux, RDP for Windows).
○ Review and Launch: Review your settings and launch the instance. You’ll need to
create or select an existing key pair for SSH access.
4. Connect to Your Instance: Once the instance is running, you can connect to it using SSH (for
Linux instances) or RDP (for Windows instances). AWS provides a “Connect” button in the
console with instructions.
1. General Purpose: Balanced compute, memory, and networking resources. Ideal for web servers,
development environments. (e.g., t2, t3, m5)
2. Compute Optimized: High CPU performance. Suitable for compute-intensive applications. (e.g.,
c5, c6g)
3. Memory Optimized: Designed for memory-intensive tasks. Ideal for large databases and
memory analytics. (e.g., r5, x1)
4. Storage Optimized: High, sequential read and write access to large data sets. Suitable for big
data and data warehousing. (e.g., i3, d2)
5. Accelerated Computing: Use hardware accelerators, or co-processors, to perform functions
such as floating-point number calculations, graphics processing, or data pattern matching. (e.g.,
p3, g4)
Pricing Models
1. On-Demand Instances: Pay for compute capacity by the hour or second with no long-term
commitments.
2. Reserved Instances: Commit to using EC2 for a 1- or 3-year term to get a significant discount.
3. Spot Instances: Bid on unused EC2 capacity at reduced rates. Suitable for fault-tolerant and
flexible applications.
4. Savings Plans: Flexible pricing model offering lower prices in exchange for a commitment to a
consistent amount of usage (measured in $/hour) for a 1- or 3-year term.
Use Cases
1. Web Hosting: Host websites and web applications with the ability to scale resources based on
traffic.
2. Big Data: Process large datasets efficiently with high-performance computing resources.
3. Machine Learning: Train and deploy machine learning models using powerful GPU instances.
4. Game Development: Develop and host game servers with scalable compute resources.
5. Development and Testing: Set up isolated development and testing environments quickly and
cost-effectively.
Conclusion
Amazon EC2 is a powerful and flexible cloud computing service that provides scalable and resizable
compute capacity. It is suitable for a wide range of applications, from simple web hosting to complex
machine learning workloads. Understanding the basic concepts and features of EC2 can help you
leverage the full potential of cloud computing in your projects. Whether you are developing software,
processing big data, or running enterprise applications, EC2 provides the tools and resources you need to
succeed.
Response generated on 25May2024
Definition: Amazon Elastic Compute Cloud (EC2) is a web service provided by Amazon Web Services
(AWS) that offers scalable and resizable compute capacity in the cloud. It allows users to launch and
manage virtual servers, known as instances, to run applications and perform various computing tasks.
Benefits:
● Scalability: Easily scale up or down based on demand. EC2 instances can be launched or
terminated quickly, allowing for dynamic resource management.
● Cost Efficiency: Pay only for the compute capacity you use. With various pricing models like On-
Demand, Reserved, and Spot Instances, users can optimize costs.
● Flexibility: Wide variety of instance types and configurations to choose from, supporting different
operating systems and software packages.
● Reliability: Built on a highly reliable infrastructure with multiple geographic regions and
Availability Zones, ensuring high availability and fault tolerance.
Key Concepts
● Types: Instances are categorized based on their intended use cases and hardware
configurations:
○ General Purpose: Balanced CPU, memory, and network resources. Ideal for a variety of
applications.
○ Compute Optimized: High-performance processors for compute-intensive tasks.
○ Memory Optimized: Large memory capacities for memory-intensive applications.
○ Storage Optimized: High, sequential read and write access to large data sets.
○ Accelerated Computing: Use of hardware accelerators like GPUs.
Amazon Machine Images (AMIs): Pre-configured templates for your instances, including the operating
system, application server, and applications. AMIs provide the information required to launch an instance.
Instance Types: Different configurations of CPU, memory, storage, and networking capacity tailored for
specific workloads.
Regions and Availability Zones: AWS data centers are organized into regions (geographic locations)
and Availability Zones (isolated locations within each region). Using multiple Availability Zones improves
fault tolerance and disaster recovery.
Security Groups: Virtual firewalls that control the inbound and outbound traffic to instances. Security
groups allow you to define rules for which IP address ranges can access your instances.
Demo: Launching Your First EC2 Instance
Step-by-Step Guide:
Q&A Session:
Homework:
● Explore the AWS Management Console and familiarize yourself with the EC2 dashboard.
● Read the AWS documentation on EC2: Amazon EC2 Documentation.
Definition: High-performance block storage service designed for use with EC2 instances. EBS volumes
provide persistent storage that remains available even when the instance is stopped or terminated.
● General Purpose SSD (gp2, gp3): Balanced price and performance for a wide variety of
workloads.
● Provisioned IOPS SSD (io1, io2): High-performance storage for I/O-intensive applications like
databases.
● Throughput Optimized HDD (st1): Low-cost HDD for frequently accessed, throughput-intensive
workloads.
● Cold HDD (sc1): Lowest-cost HDD for infrequently accessed data.
Snapshots:
● Creating and managing EBS snapshots for backup and restore purposes.
● Snapshots are incremental, meaning that only the blocks that have changed since your last
snapshot are saved.
Elastic IP Addresses
Definition: Static IP addresses designed for dynamic cloud computing. An Elastic IP address is
associated with your AWS account and can be remapped to any instance in your account.
Benefits:
● Maintain a fixed IP address even when instances are stopped and restarted.
● Remap your Elastic IP address quickly to another instance in the event of an instance failure.
Auto Scaling
Definition: Auto Scaling automatically adjusts the number of EC2 instances in response to the demand
to maintain performance and minimize costs.
Components:
Benefits:
Load Balancing
Definition: Distributes incoming traffic across multiple EC2 instances, ensuring no single instance
becomes overloaded.
● Application Load Balancer (ALB): Best suited for HTTP and HTTPS traffic. Provides advanced
request routing features.
● Network Load Balancer (NLB): Handles TCP, UDP, and TLS traffic. Best for performance and
low latency.
● Classic Load Balancer (CLB): Legacy load balancer, suitable for basic load balancing needs.
Q&A Session:
Homework:
● On-Demand Instances: Pay by the hour or second, with no long-term commitments. Ideal for
short-term, unpredictable workloads.
● Reserved Instances: Significant discount for committing to use EC2 for a 1 or 3-year term. Ideal
for steady-state or predictable usage.
● Spot Instances: Bid on unused EC2 capacity for lower costs. Ideal for flexible, interruptible
workloads.
Placement Groups:
● Cluster Placement Groups: Low-latency network performance within a single Availability Zone.
Best for tightly coupled node-to-node communication.
● Spread Placement Groups: Instances spread across underlying hardware to reduce the risk of
simultaneous failures. Best for critical applications.
● Partition Placement Groups: Instances divided into logical segments called partitions. Best for
large distributed and replicated workloads.
Elastic Fabric Adapter (EFA): Network device that you can attach to your Amazon EC2 instance to
accelerate High-Performance Computing (HPC) and machine learning applications.
● IAM Roles: Use IAM roles for EC2 instances to securely manage permissions.
● Regular Updates: Regularly update and patch your instances to protect against vulnerabilities.
● Security Groups and Network ACLs: Implement security groups and network ACLs to control
inbound and outbound traffic.
● Encryption: Encrypt data at rest using EBS encryption and in transit using SSL/TLS.
● Monitoring and Logging: Monitor and log activity using AWS CloudTrail and Amazon
CloudWatch.
● Hosting Scalable Web Applications: Use EC2 instances to host web applications that can
scale based on demand.
● Big Data Processing: Process large datasets with tools like Hadoop and Spark.
● Machine Learning: Train and deploy machine learning models on powerful GPU instances.
● High-Performance Computing (HPC): Run HPC workloads that require significant
computational power.
Case Studies
● Discuss real-world case studies of companies using EC2 to solve complex problems and optimize
their IT infrastructure.
Q&A Session:
Homework:
● Explore instance purchasing options and determine which best suits different use cases.
● Implement security best practices on your EC2 instances.
● Use AWS Cost Explorer to analyze your EC2 usage and identify opportunities for cost
optimization.
This detailed write-up provides a comprehensive understanding of Amazon EC2, its features, best
practices, and real-world applications
Load balancing is essential for designing large-scale, high-availability applications. It helps distribute
incoming network traffic across multiple servers, ensuring no single server becomes a bottleneck. In the
context of Amazon Web Services (AWS), Elastic Load Balancing (ELB) automatically distributes incoming
application traffic across multiple EC2 instances, enhancing the availability and reliability of your
application.
The Application Load Balancer operates at the application layer (Layer 7) of the OSI model. It is designed
to handle HTTP and HTTPS traffic and provides advanced request routing based on the content of the
request.
Key Features:
● Content-based Routing: Routes requests based on the URL, host headers, HTTP headers, and
more.
● WebSocket Support: ALB supports WebSocket and HTTP/2 protocols.
● Security: Integration with AWS Certificate Manager (ACM) for SSL/TLS certificates, and AWS
WAF for web application firewall protection.
The Network Load Balancer operates at the transport layer (Layer 4). It is designed for handling TCP,
UDP, and TLS traffic, capable of processing millions of requests per second with low latency.
Key Features:
The Classic Load Balancer operates at both the application and transport layers. It provides basic load
balancing across multiple EC2 instances and is suitable for applications built within the EC2-Classic
network.
Key Features:
The Gateway Load Balancer operates at the network layer and is designed for deploying, scaling, and
managing virtual appliances such as firewalls, intrusion detection and prevention systems, and deep
packet inspection systems.
Key Features:
Conclusion
Load balancing is a fundamental technique for building scalable, high-availability applications. AWS
provides multiple load balancer options to suit different needs, including the Application Load Balancer,
Network Load Balancer, Classic Load Balancer, and Gateway Load Balancer. Each type of load balancer
offers unique features and benefits, making it suitable for different types of workloads.
Using AWS Elastic Load Balancing with Auto Scaling groups ensures your application can handle varying
levels of traffic while maintaining high availability and performance. Proper configuration and monitoring of
these services are essential for maintaining a robust and scalable application infrastructure.
NOTE:
- It is target groups which basically connect the ALB with the ASG. Target groups can have even more
registered targets other than ASG introduced. ALB can have multiple target groups attached. By default
there will be round robin load balancing between the targets.
- A typical application under ALB should be stateless and should not have user generated files and / or
DB within the EC2
Auto scaling group does not directly attach to the load balancer. We actually specify target groups
associated with load balancer and that tgt group is populated with the instances which are created due to
the ASG policies of scaling in and scaling out.