Unlocking the Power of AWS EC2: Everything You Need to Know
What is EC2
AWS Elastic Compute Cloud (EC2) is a web service that allows to run virtual servers in a cloud. EC2 is an request made to AWS to provide virtual server in public cloud with scalability feature.
E- Elastic —> The VM can scale up or down based on demand
C- Cloud —> Offers virtual servers in public or private cloud
C- Compute —> Virtual server with RAM, CPU, and storage
Why we need EC2
In today's world, without EC2, managing servers is difficult because:
They need regular upgrades
They require security updates
Servers must be up and running smoothly
The EC2 instance feature in AWS handles all these tasks automatically, making it a great choice for businesses and developers. This automation makes server management easier and lowers the costs of maintaining physical servers. Because of this, EC2 is popular for its efficiency and cost-effectiveness.
Types of EC2 instances
Instance Type | Definition | Suitable For | Instance Family |
General Purpose | Offers a balance of compute, memory, and network resources. | Web servers, development environments, small databases. | T3, M5 |
Compute Optimized | Designed for applications requiring high compute power. | Batch processing, high-performance web servers, scientific modeling. | C5, C6g |
Memory Optimized | Designed for applications needing large amounts of memory. | big data analytics, real-time processing. | R5, X1 |
Storage Optimized | Optimized for high, sequential read and write access to large datasets. | Data warehousing, big data workloads. | I3, D2 |
Accelerated Computing | Uses hardware accelerators for functions like floating-point calculations, graphics processing. | Machine learning, video processing, gaming. | P3, G4 |
Region & Availability zone in AWS
Region
A region in AWS is a geographic location where AWS services are available. Regions are designed to provide high availability and fault tolerance by spreading services across multiple zones.
Example: Let's say you have customers in Asia. You can choose to deploy your AWS resources in the "Asia Pacific (Mumbai)" region. This reduces latency and provides better performance for your users in that area.
Availability Zone (AZ):
An Availability Zone is a distinct location within a region that is engineered to be isolated from failures in other AZs. Each AZ has its own power, cooling, and networking infrastructure, ensuring high availability and fault tolerance.
Example: Imagine you set up your application in the "US East (N. Virginia)" region, which has several AZs like us-east-1a, us-east-1b, and us-east-1c. You can put your web servers in us-east-1a and your database servers in us-east-1b. If something goes wrong in us-east-1a, your database servers in us-east-1b will still work, keeping your application running.
Practical - Deploy Jenkins on an EC2 instance and access it from Google.
Step 1: Launch an EC2 Instance
Step 2: Connect to the EC2 Instance using Mobaxterm for Linux or Putty for Windows with the public IP
Step 3: Update packages with sudo apt update
Step 4: Install Java, which is needed for Jenkins, using sudo apt install openjdk-17-jdk
Step 5: Install Jenkins with sudo apt install jenkins
Step 6: Check if Jenkins is enabled with systemctl status jenkins
Step 7: Allow Jenkins port in the security group (inbound rules)
Step 8: Make sure Jenkins is accessible from Google.