DEV Community

Cover image for Amazon EC2 Fundamentals
Md. Arafat Islam
Md. Arafat Islam

Posted on

Amazon EC2 Fundamentals

Introduction to EC2

Amazon Elastic Compute Cloud (EC2) is a highly configurable virtual server.

This is like a super flexible computer in the cloud. You can adjust its size and power to match your needs. It only takes a few minutes to set up and run. Almost everything on AWS uses EC2 in the background.

Before starting, we need to know,

What is an EC2 Instance?
An AWS EC2 instance is, in simple terms, a virtual computer in the cloud. It provides computing power that can run applications, process data, or serve client devices. Unlike a physical computer, it is highly scalable and customizable, allowing you to choose the operating system, storage, and performance level to meet your needs.

Key Setup Options for EC2 Instances

  1. Choose an Operating System (OS):
    • Pick your preferred OS using an Amazon Machine Image (AMI). Examples include Red Hat, Ubuntu, Windows, Amazon Linux, and SUSE.
  2. Pick the Right Instance Type:
    • Example:
      • t2.nano: Low-cost, small-scale instance.
        • $0.0065/hour ($4.75/month).
        • 1 virtual CPU (vCPU) and 0.5 GB memory.
      • C4.8xlarge: High-performance, large-scale instance.
        • 36 vCPUs, 60 GB memory, 10 Gbps speed. Image description
  3. Add Storage:
    • Options include SSD, HDD, or Virtual Magnetic Tape.
  4. Configure the Instance:
    • Set up Security Groups (like a firewall), Key Pairs (for access), and IAM Roles (to manage permissions).

EC2 Instance Families

What are Instance Families?
Instance families are different combinations of CPU, Memory, Storage, and Networking capacity.

Instance families allow you to choose the appropriate combination of resources to meet your application’s unique requirements.

Different instance families vary due to the hardware used to give them their unique properties.

Choosing the Right EC2 Instance Family for Your Needs

General Purpose

- A1, T2, T3, T3a, T4g, M4, M5, M5a, M5n, M6zn, M6g, M6i, Mac.

- Balance of compute, memory, and networking resources.
  Use-cases: Web servers, code repositories.
Enter fullscreen mode Exit fullscreen mode

Compute Optimized

- EC5, C4, C5a, C5n, C6g, C6gn.

- Ideal for compute-bound applications that benefit from
  high-performance processors.

- Use-cases: Scientific modeling, dedicated gaming servers,
  ad server engines.
Enter fullscreen mode Exit fullscreen mode

Memory Optimized

- ER4, R5, R5a, R5b, R5n, X1, X1e, High Memory, z1d.

- Fast performance for workloads that process large datasets in memory.

- Use-cases: In-memory caches, in-memory databases, real-time big data
  analytics.
Enter fullscreen mode Exit fullscreen mode

Accelerated Optimized

- P2, P3, P4, G3, G4ad, G4dn, F1, Inf1, VT1.

- Hardware accelerators or co-processors.

- Use-cases: Machine learning, computational finance, seismic
  analysis, speech recognition.
Enter fullscreen mode Exit fullscreen mode

Storage Optimized

- I3, I3en, D2, D3, D3en, H1.

- High sequential read and write access to very large datasets on
  local storage.

- Use-cases: NoSQL, in-memory or transactional databases, data
  warehousing
Enter fullscreen mode Exit fullscreen mode

EC2 Instance Types

An instance type is a combination of instance size and instance family:

A common pattern for instance sizes:

  1. nano
  2. micro
  3. small
  4. medium
  5. large
  6. xlarge
  7. 2xlarge
  8. 4xlarge
  9. 8xlarge
  10. ...

Image description

There are many exceptions to the pattern, eg.

- c6g.metal: A bare metal machine.

- C5.9xlarge: Does not follow the power-of-2 or even-numbered
  size convention.
Enter fullscreen mode Exit fullscreen mode

EC2 Instance Size

EC2 Instance Sizes generally double in price and key attributes

Image description

Dedicated Host vs Dedicated Instance

EC2 – Dedicated Host

Dedicated Hosts are single-tenant EC2 instances designed to let you Bring-Your-Own-License (BYOL) based on machine characteristics.

Here is the comparison between the dedicated host and the instance:

Image description

EC2 Tenancy

EC2 has three levels of tenancy:

Image description

Managing Cloud Resources: VPC, Elastic IPs, and Security Groups Explained

VPC (Virtual Private Cloud):
Think of a VPC as your own private space in the AWS cloud. It's like having your own section of the internet where you control who and what can access your resources. You can think of it as a private and secure data center, but in the cloud.

Image description

Elastic IPs:
An Elastic IP is a static IP address that you can attach to an AWS resource (like an EC2 instance). It’s like having a permanent address for your house, even if you switch houses (or servers). This way, your application or website always has the same address.

Image description

Security Groups:
A security group acts as a firewall for your AWS resources. It decides who is allowed to come in (ingress rules) and go out (egress rules) of your resources. For example:

  • Allowing only specific people to knock on your door (SSH access for admins).
  • Letting only certain apps talk to your server (e.g., web traffic on port 80 or 443).

Storage Options: Comparing EBS and Instance Store

When choosing storage for your Amazon EC2 instance, two popular options come to mind: Amazon Elastic Block Store (EBS) and Instance Store. Each has unique features and serves specific use cases. Let’s break down their key differences to help you decide which one suits your needs.

Elastic Block Store (EBS)
EBS is a highly durable, persistent storage solution. It works like an external hard drive attached to your EC2 instance. Here’s what makes EBS stand out:

  • Persistence: EBS volumes retain data even after the EC2 instance stops or is terminated.
  • Scalability: You can resize volumes easily without interrupting your workload.
  • Backup and Recovery: Snapshots can be taken and stored in Amazon S3 for quick recovery or cloning.
  • Use Case: Ideal for databases, application data, and workloads requiring long-term storage.

Instance Store
Instance Store is a temporary storage solution directly attached to the physical host of the EC2 instance. Its notable characteristics include:

  • Ephemeral Storage: Data is lost when the instance stops, terminates, or fails.
  • High Performance: Best for applications requiring fast, temporary storage, such as caches or buffers.
  • No Backups: There are no built-in backup options.
  • Use Case: Suitable for temporary files or data that can be regenerated if lost.

Key Differences at a Glance
Image description

Which Should You Choose?

  • Choose EBS if you need reliable, persistent storage for important data, like databases or logs.
  • Choose Instance Store if you need high-speed, temporary storage for disposable or transient data.

Top comments (0)