DEV Community

Cover image for EC2 Essentials: Your Gateway to Cloud Computing
Lindiwe
Lindiwe

Posted on

EC2 Essentials: Your Gateway to Cloud Computing

Knowing how to use Elastic Compute Cloud (EC2) is fundamental to understanding how the cloud works. This article will introduce you to the essentials of EC2, highlighting its key features and advantages, so you can confidently leverage its capabilities to enhance your applications and infrastructure.

Buckle up and learn

So what is Amazon EC2? Well, EC2 is the most popular AWS offering definitely used everywhere. It is the way to do Infrastructure as a Service on AWS.EC2 is not just one service, it is composed of many things at a high level.
It mainly consists of the following capabilities:

  1. You can rent virtual machines -> EC2 instances.

  2. Storing data on virtual drives (EBS volumes)

  3. Distributing load/traffic across machines(Elastic Load
    Balancers)

  4. Scaling the services using an EC2 auto-scaling group(ASG)

The cloud is to be able to rent these compute whenever you need, on-demand and EC2 is just that. Here are the EC2 sizing and configuration options we can choose for the virtual servers we rent from AWS:

• Choose any of these Operating Systems (OS): Linux, Windows
or Mac OS
• How much compute power & cores (CPU)
• How much random-access memory (RAM)
• How much storage space:
i. Network-attached (EBS & EFS)
ii. Hardware (EC2 Instance Store)

• Type of network you want to attach to your EC2 instance
-Network card: speed of the card, Public IP address

• Handle firewall rules with security groups
• Bootstrap script (to configure the instance at first
launch)~EC2 User Data

EC2 User Data

  • It is possible to bootstrap our instances using an EC2 User Data script.
  • Bootstrapping means launching commands when a machine starts.
  • That script is only run once at the instance's first start.
  • EC2 user data is used to automate boot tasks such as:
    1. Installing updates
    2. Installing software
    3. Downloading common files from the internet
    4. Anything you can think of but the more you add in your EC2 user data script the more your instance has to do at boot time.
  • The EC2 User Data script runs as the root user, meaning any command you provide will have sudo rights.

Examples of EC2 instance types you will come across

ec2 instance types
Happy cloud exploring!
I’d love to hear your thoughts, so please share them in the comment section.

Top comments (4)

Collapse
 
respect17 profile image
Kudzai Murimi

Great Job!
I'm curious, how would you recommend optimizing EC2 costs for a growing application that experiences unpredictable traffic spikes? Would using a mix of reserved instances, spot instances, and auto-scaling be an effective strategy, or are there other cost-saving techniques that work better in such scenarios?

Collapse
 
lindiwe09 profile image
Lindiwe

Thank you for your question @respect17 ! Optimizing EC2 costs for a growing application with unpredictable traffic spikes can be challenging, but a solid strategy can make a difference.

Using a mix of Reserved Instances, Spot Instances, and Auto Scaling is often an effective approach:
Auto Scaling Groups: Implementing Auto Scaling helps your application dynamically adjust capacity based on demand. This is crucial for unpredictable traffic, allowing you to run only the resources needed at any time, avoiding over-provisioning.

Reserved Instances: If you have a predictable baseline of usage, purchasing Reserved Instances (RIs) can significantly reduce costs for that portion of your compute needs. They require a commitment of 1 or 3 years for consistent instance configurations (type and Region).

Spot Instances: For unexpected traffic spikes, Spot Instances allow you to request unused EC2 capacity, often at a lower cost than On-Demand Instances. However, they can be interrupted, so ensure your application can handle interruptions or has a fallback mechanism (like Auto Scaling launching On-Demand instances when Spot instances are unavailable).

In addition, consider using Savings Plans for flexibility, right-sizing instances, and utilizing AWS Compute Optimizer for cost recommendations. Combining these strategies can achieve a balance between cost savings and reliability, ensuring your application remains responsive to fluctuating demands. If you have more questions, feel free to ask!

Collapse
 
devnenyasha profile image
Melody Mbewe

Great breakdown of EC2! It's a solid guide to effectively leverage EC2. 🌩️

Collapse
 
lindiwe09 profile image
Lindiwe

Thank you Melody!
I’m glad you found the breakdown helpful.