Amazon EC2
EC2 is a virtual server in AWS where you run an operating system and application directly. It provides the compute slot for long-lived workloads by letting you launch instances and attach disks and networks as needed.
▶Architecture Diagram
🔍 StructureDashed line animations indicate the flow direction of data or requests
When a process has to stay alive for hours after deployment, the server still has to keep running even when there is little traffic. If you rely only on physical machines or fixed-capacity servers, you cannot expand fast when traffic jumps and you keep paying for idle capacity when it falls.
In the past, launching an application meant purchasing physical servers and setting up racks, power, and networking. If capacity forecasts were wrong, it immediately led to over-investment or provisioning delays — which is why on-demand virtual server allocation models like EC2 emerged.
EC2 lets you spin up virtual servers on demand and choose CPU and memory via instance types. Typically, instances are placed inside a VPC, an ALB distributes requests, and EBS provides disk — creating an always-on compute environment.
EC2 and ECS both run applications but with different focuses. EC2 is the choice when you want to manage the server itself, while ECS focuses on container-level deployment and orchestration. If you need direct control over the OS, runtime, and long-running processes, EC2 is the right fit.
Commonly Compared Concepts
Lambda
Serverless Function Execution
Both run code, but Lambda executes briefly only when requests arrive, while EC2 keeps a server running continuously.
ECS (Container)
Container Orchestration
Both serve as application runtimes, but ECS standardizes container operations while EC2 gives you direct control over the server.
Fargate
Serverless Container Execution
Both run applications, but EC2 requires you to manage the server directly while Fargate is a container execution environment where server management is abstracted away.
Well-suited for web servers, long-running batch jobs, and stateful applications that require a persistent server. Not a good fit when container-level deployment matters more or you only need short, request-driven execution.