What Is EC2?
At its core, EC2 is a service that allows you to rent virtual computers in the cloud. AWS owns massive data centers filled with powerful custom hardware, think warehouses packed with servers. Instead of buying and maintaining your own hardware, you can rent virtual servers from AWS, known as EC2 instances.
When you launch an EC2 instance, you're directly using the service. This gives you full control over the virtual machine, including:
- Choosing the operating system
- Configuring networking and security
- Installing and managing software
- Scaling resources up or down as needed
EC2 also serves as the underlying infrastructure for many other AWS services. This means we're often using EC2 indirectly when we use services like:
- Amazon ECS (Elastic Container Service): When you run containers on ECS, they're often hosted on EC2 instances, especially if you're using the EC2 launch type.
- Amazon EMR (Elastic MapReduce): This big data processing service uses EC2 instances to create clusters for running Hadoop, Spark, and other big data frameworks.
- AWS Elastic Beanstalk: This Platform as a Service (PaaS) offering automatically handles the deployment of your applications, using EC2 instances to host your code.
- Amazon RDS (Relational Database Service): While RDS abstracts away much of the database management, it uses EC2 instances to run the database engines.
- Amazon SageMaker: This machine learning platform uses EC2 instances for training and hosting models.
So we can setup EC2 instances directly, or use service that use EC2 under the hood.
Regions & AZs
Virtual Machines
A Virtual machine is a space that simulates a complete computer, where we can run an operating system, software, and code.
Servers
Virtual machines run on a real machine, a piece of hardware, a compute server. When you rent some compute in the cloud, you're usually just getting a VM inside a large powerful computer. Although you can rent out the entire computer if you like. These AWS servers are large and powerful, and custom built for the cloud.
But these servers aren't alone. They're connected to other hardware for things like storage and networking.
Data Centers
Data Centers are basically warehouses full of this hardware that can be rented by us on-demand.
Availability Zones
An Availability Zone (AZ) is some number of data centers, all located close to each other. We think of an AZ as a single unit, a "logical data center", but it's made up of many physical data centers.
Regions
Regions contain at least two Availability Zones for redundancy. Within a region, AZs are physically separated by a meaningful distance, many kilometers from any other AZ, although all are within 100 km (60 miles) of each other. And they are all linked to each other with the low-latency, high-bandwidth, private AWS network.
And we already know that regions are the places in the world where most of our infrastructure is hosted.
Hosting Considerations
When we're setting up something like an EC2 instance, it will exist within a single availability zone, within a single region. For the most part, it doesn't really matter which AZ we choose, but we'll talk more about that later when we get to horizontal scaling and load balancing.