• Home
  • EC2 infrastructure on AWS

Amazon Elastic Compute Cloud (EC2) is a core service provided by AWS (Amazon Web Services) that allows users to run virtual machines (called instances) in the cloud. EC2 gives developers and system administrators flexible, scalable computing resources to deploy, manage, and scale applications.

Here’s a breakdown of the key components and architecture of EC2 infrastructure:

1. EC2 Instances

  • Virtual Servers: EC2 instances are virtual servers that run applications. Users can choose different instance types based on performance requirements (CPU, memory, storage, networking).
  • AMI (Amazon Machine Image): Pre-configured images with an OS, application server, and apps. You can create custom AMIs or use predefined ones (e.g., for Windows, Linux).
  • Instance Types: Different configurations like compute-optimized, memory-optimized, storage-optimized, etc. Examples:
    • t2.micro: General purpose, low-cost instances (used for small workloads).
    • m5.large: Balanced CPU and memory for standard use.
    • c5.xlarge: Compute-optimized for CPU-heavy tasks.

2. Elastic Block Store (EBS)

  • Persistent Storage: Provides durable block-level storage volumes for use with EC2 instances.
  • Volume Types: Various types like SSD (General Purpose and Provisioned IOPS) and HDD (Throughput-Optimized, Cold HDD) to suit different workloads.
  • Snapshots: You can take backups (snapshots) of EBS volumes and store them in Amazon S3.

3. EC2 Auto Scaling

  • Dynamic Scaling: Automatically adjusts the number of EC2 instances to match demand. You can define scaling policies to add or remove instances based on metrics like CPU usage.
  • Elastic Load Balancing (ELB): Distributes incoming traffic across multiple EC2 instances, improving fault tolerance and scalability.

4. Security

  • Security Groups: Virtual firewalls that control inbound and outbound traffic for EC2 instances. You define rules based on IP addresses and port numbers.
  • Key Pairs: SSH keys used to securely access EC2 instances.
  • IAM Roles: AWS Identity and Access Management roles allow you to assign granular permissions to EC2 instances (e.g., granting permission to read/write to S3).

5. Networking

  • Virtual Private Cloud (VPC): Isolated cloud networks where EC2 instances run. You can define subnets, route tables, and gateways.
  • Elastic IP Addresses: Static public IPs for EC2 instances that need to be reached via the internet.
  • Private IP Addresses: Internal IP addresses within the VPC for communication between instances.

6. Elastic Load Balancer (ELB)

  • Distributes Traffic: A managed service that automatically distributes incoming application or network traffic across multiple EC2 instances.
  • Types:
    • Application Load Balancer (ALB): Works at Layer 7 (HTTP/HTTPS) for routing web traffic.
    • Network Load Balancer (NLB): Operates at Layer 4 (TCP/UDP) for high-performance, low-latency traffic.
    • Gateway Load Balancer (GLB): Combines auto-scaling and load balancing for security appliances like firewalls.

7. Elastic IP Addresses

  • Static IP: A persistent, public IP address that you can assign to your EC2 instances for consistent internet-facing IP.

8. Placement Groups

  • Cluster Placement Group: Places instances close to each other in a low-latency network for high-performance computing.
  • Spread Placement Group: Distributes instances across distinct hardware to reduce simultaneous failure risks.
  • Partition Placement Group: Divides instances into partitions, so failure in one partition does not affect others.

9. EC2 Spot Instances

  • Low-Cost, Variable Availability: Spot instances allow users to bid for unused EC2 capacity at a lower price but can be interrupted by AWS if demand spikes. Useful for batch jobs or flexible applications.

10. Monitoring and Logging

  • Amazon CloudWatch: Provides monitoring for EC2 instances and other AWS services. You can track metrics like CPU utilization, disk reads/writes, and network traffic.
  • CloudTrail: Logs all API calls made to your AWS infrastructure, including EC2. This is useful for auditing and troubleshooting.

11. Pricing Models

  • On-Demand: Pay per second/minute with no long-term commitment.
  • Reserved Instances: Commit to using instances for 1 or 3 years in exchange for a lower price.
  • Spot Instances: Use unused EC2 capacity at a discount, though instances can be terminated when demand increases.
  • Dedicated Hosts: Physical servers dedicated to your use, giving more control over hardware for licensing or compliance.

12. Other Services Integrating with EC2

  • Amazon RDS: Managed relational databases can be deployed with EC2 to host applications.
  • Amazon S3: Object storage used to store large amounts of data, accessible by EC2 instances.
  • AWS Lambda: Event-driven, serverless compute service that can offload smaller tasks or microservices from EC2 instances.

Example of EC2 Architecture:

Imagine you are building a web application on AWS using EC2:

  • Front-End Instances: Your web servers could run on a fleet of EC2 instances behind an Application Load Balancer (ALB).
  • Auto Scaling: Auto Scaling Groups ensure that as traffic increases or decreases, more or fewer EC2 instances are provisioned automatically.
  • Security: The EC2 instances are in a secure VPC, and security groups define who can access your instances.
  • Back-End: You could run a relational database like Amazon RDS or use a NoSQL service like DynamoDB. Elastic Block Store (EBS) could be attached to store application data.
  • Monitoring and Alerts: CloudWatch monitors the health of your EC2 instances, while CloudTrail logs all API interactions.

This infrastructure provides scalability, flexibility, and reliability for your application, while allowing you to control costs based on actual usage.

By Aijaz Ali

Leave Comment