What is Amazon EC2?
EC2 rents you virtual computers in the cloud, ready in about a minute, billed by the second.
Amazon Elastic Compute Cloud (EC2) gives you virtual servers, called instances. You choose how much CPU and memory you want and which operating system to run, and you get a machine you fully control: install anything, run anything, keep it on as long as you like.
Buying a physical server is like buying a house: big upfront cost, and you're stuck with it. EC2 is like renting an apartment by the second. Need a bigger place for a busy weekend? Move up. Done? Hand back the keys and stop paying.
Lambda or EC2?
| Lambda | EC2 | |
|---|---|---|
| You manage | Just your code | The whole OS: patches, software, scaling |
| Runs | Only when triggered, up to 15 minutes | As long as you want |
| Best for | Event-driven tasks, APIs | Long-running apps, custom software, full control |
EC2 is the oldest and most flexible way to run things on AWS. Many other services, like RDS and ECS, run on EC2 behind the scenes.
Key takeaways
- EC2 instances are virtual servers you fully control.
- You pick CPU, memory, OS, and storage, and pay per second while it runs.
- Choose EC2 over Lambda for long-running apps or when you need full control of the machine.
Check your understanding
Pick an answer to see the explanation.
1. You need to run a game server 24/7 with custom software. Which fits best?