# Amazon EC2

> Virtual computers you rent by the hour, in any size, and switch off when done.

- Level: Basic
- Topics: AWS
- URL: https://tidbit.legios.com.ar/amazon-ec2/
- In Spanish: [Amazon EC2](https://tidbit.legios.com.ar/es/amazon-ec2/)

**EC2** (Elastic Compute Cloud) is the AWS service for renting virtual machines, called **instances**. You choose an operating system (Linux or Windows), a size (how many CPU cores, how much RAM), press launch, and about a minute later you have a computer you can log into and run anything on: a website, a database, a game server, a script that runs once a night.

You pay by the second while the instance is running and nothing for the machine while it is stopped. Sizes go from tiny (one shared core, half a gigabyte of RAM, a fraction of a cent per hour) to huge machines with hundreds of cores or several GPUs for training AI models. Instance types have names like `t3.micro` or `m7g.large`: the letters say what the family is good for, the suffix says how big it is.

An instance lives in one Availability Zone of a Region, its disk is usually an Amazon EBS volume, and its permissions come from an IAM role. EC2 is the most classic piece of AWS: when something cannot run as a container or as an AWS Lambda function, it ends up on an EC2 instance.

## An analogy

Renting a car instead of buying one. You pick the size you need today (a compact for errands, a truck for moving house), pay for the hours you drive, and return it. Tomorrow you can take a different one.

## Keep in mind

- An instance is a virtual machine; you choose the OS, the CPU and the RAM.
- Billing is per second while running; a stopped instance only pays for its disk.
- Families: `t` and `m` for general work, `c` for compute, `r` for memory, `p` and `g` for GPUs.
- Spot instances are the same machines at a steep discount, with the risk of being reclaimed.

## Go deeper

- [What is Amazon EC2? (official docs)](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)
- [Amazon EC2](https://aws.amazon.com/ec2/)

## Related terms

- [Cloud computing](https://tidbit.legios.com.ar/cloud-computing/): Renting computers over the internet instead of buying your own.
- [Virtual machine](https://tidbit.legios.com.ar/virtual-machine/): A complete computer made of software, running inside a real one.
- [Operating system](https://tidbit.legios.com.ar/operating-system/): The base software that runs a device and lets every app share its hardware.
- [Linux](https://tidbit.legios.com.ar/linux/): A free, open source operating system that runs most of the internet's servers.
- [Cores and threads](https://tidbit.legios.com.ar/cpu-cores-and-threads/): Why a CPU is really several processors, and why it can juggle even more tasks.
- [RAM](https://tidbit.legios.com.ar/ram/): The computer's short-term memory: fast, small and wiped when you turn it off.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
