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.

Virtual Machine

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.

Server

But these servers aren't alone. They're connected to other hardware for things like storage and networking.

Hardware

Data Centers

Data Centers are basically warehouses full of this hardware that can be rented by us on-demand.

Data Center

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.

Availability Zone

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.

Region

And we already know that regions are the places in the world where most of our infrastructure is hosted.

World Map

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.

Show timestamps
00:00
Essentially, an EC2 instance most of the time anyway is gonna be a virtual machine running
00:05
inside a much bigger more powerful piece of hardware from AWS.
00:09
And technically we can rent the entire piece of hardware not just a virtual machine within the
00:14
server. But for the most part like ninety nine percent of the time you're gonna be renting a
00:18
virtual machine that's setting up an EC2 instance is renting a virtual machine. Here's my
00:21
picture of a virtual machine. It's where we run the operating system. Right? We get choose our
00:26
different operating systems our software the code that we run on those things. It is a complete
00:31
virtualized computer within AWS's servers and AWS puts a lot of time and effort into building
00:37
some of the best hardware for cloud infrastructure. So it is on a really powerful piece of
00:42
hardware that we are running uh most of the time pretty small virtual machine. We can choose the
00:46
specs. We could we could have a more powerful or a less powerful virtual machine depending on how
00:50
much we wanna spend. But we get the virtual machine. It's inside their hardware.
00:54
Their hardware isn't just servers. They also have a lot of storage hardware for S3, for EBS,
00:59
They have a lot of uh routing hardware and networking hardware.
01:03
So they got all this custom built hardware for cloud computing.
01:07
That they then put in a data center which is basically just a big warehouse full of all this
01:11
hardware that they're managing. So just imagine a big warehouse full of hardware and you're
01:15
renting just a tiny little piece of that. Then we have this idea of availability zones. So with
01:20
AWS an availability zone they want you to think of as a logical data center. So when we think of
01:25
a data center we think of a big building big warehouse full of all these different bits of
01:29
hardware. AWS has an availability zone which is going to consist of multiple of these physical
01:34
locations but we think of it as just this logical data center. But they just have redundancy
01:38
everywhere and they're they're scaling. So they need a lot of different data centers set up. But
01:44
the availability zone is our logical data center. Then we're gonna come back to regions now
01:48
because a region that physical place in the world. Remember we have all these different regions
01:53
US-east-1, US-west-2. So all these regions have multiple availability zones in them. So within
02:00
a region you're gonna have two or more availability zones which are logical data centers.
02:05
Within each availability zone you have a you have a few different data centers within the data
02:10
center. You have a bunch of hardware and so on. So This is really important because each region is
02:16
basically divided into different availability zones different
02:19
logical data centers that all have their own networking and hardware.
02:23
They're all linked by AWS's backbone network but all of these availability zones are some
02:28
distance apart from each other. So this protects us from certain disasters.
02:32
Like if there was a power outage uh or a natural disaster like an earthquake or something, that
02:37
meant that an availability zone was offline completely. We couldn't access our servers or storage
02:42
or anything in that AZ, then these are all separated from each other far enough apart that the
02:48
other availability zones should be fine. So if I have an S3 bucket set up in US-West-2, my
02:54
data is distributed across multiple AZs. If one AZ just goes down for whatever reason I can still
03:00
access my files in S3 because it still exists in other places. There's a lot of redundancy
03:04
built in to AWS. And when we get to more advanced stuff in the future setting up our own private
03:09
networks and horizontally scaling and dealing with redundancy on our own we're gonna make sure
03:13
that we have different subnets in each availability zone and that when we horizontally scale out
03:18
our applications that we put different infrastructure in different availability zones just in
03:22
case any disaster happens. And we're gonna start working with EC2 instances now. And not only
03:27
do we have to select a region for an EC2 instance but we also select an availability zone
03:32
for that EC2 instance. And that's about as far down as we go but we're gonna have to specify
03:37
which AZ we want. So if we were hosting in North Virginia we would have six different
03:41
availability zones that we could choose from right here. And if we're hosting in you know Canada
03:46
central we only have three availability zones. And for the most part it doesn't really matter
03:50
which AZ you put a piece of infrastructure on. But this is a decision we're gonna have to make.
03:54
And in the future we're gonna do this more intentionally when we
03:57
scale and add redundancy to our applications and our