Amazon EC2 (Elastic Compute Cloud) is AWS's virtual server service that lets you launch and manage compute instances in the cloud within minutes. Each EC2 instance is a virtual machine with a configurable amount of CPU, memory, storage, and networking capacity chosen from dozens of instance families — from general-purpose (t3, m6i) to compute-optimized (c6i) and memory-optimized (r6i). You pay only for what you use, by the second, and can start or stop instances at any time. EC2 integrates tightly with other AWS services: instances live inside VPCs for network isolation, attach EBS volumes for persistent storage, and sit behind Elastic Load Balancers for traffic distribution. The Azure equivalent is Azure Virtual Machines; the GCP equivalent is Compute Engine; OCI calls them Compute Instances. When would you use EC2? Use EC2 when you need full control over the operating system and runtime environment, when running long-running processes (batch jobs, background workers, traditional web servers), when your workload doesn't fit the stateless/short-execution model of serverless functions, or when you need specific hardware capabilities (GPUs, high-memory instances). Choose Lambda instead for short event-driven tasks; choose ECS/EKS instead when you want container-based workloads with orchestration. Common mistakes: running a single EC2 instance with no redundancy (always deploy across at least two Availability Zones behind a load balancer), not using Auto Scaling groups (your app will fall over under traffic spikes), and using On-Demand pricing for steady-state workloads when Reserved Instances or Savings Plans would cut costs by 30–70%.
Example: A startup launches an EC2 t3.medium instance to host their web application, then switches to a c6i.large when they need more CPU for video processing — all without touching physical hardware. Architecture use case: a web app uses an Application Load Balancer in front of an Auto Scaling group of EC2 instances spanning three Availability Zones, with an RDS Multi-AZ database in private subnets — providing high availability and automatic failover.
Category: cloud
Difficulty: basic