Cloud Technology and Services · Topic 3 of 11

EC2, Auto Scaling and Load Balancing

Learn Amazon EC2 instance types, AMIs, Auto Scaling groups and Elastic Load Balancing options, and when each fits, for the Cloud Practitioner exam.

  • 4 min
  • Includes a diagram
In a nutshell
  • EC2 gives resizable virtual servers. You choose the operating system, size and storage.
  • An AMI is a template used to launch instances.
  • Instance families: general purpose, compute optimized, memory optimized, storage optimized and accelerated computing.

What it is

Amazon Elastic Compute Cloud (EC2) provides virtual servers, called instances, that you can launch in minutes. You choose the size, the operating system and the storage, and you pay for the time they run.

Two helper services make EC2 more useful. Auto Scaling adds or removes instances automatically, and Elastic Load Balancing spreads traffic across them.

EC2 is the most flexible compute option, and it also gives you the most responsibility, because you manage the guest operating system.

UserstrafficLoad balancerspreads requestsEC2 instancesin an Auto Scaling group

How it works

Launching an instance

To launch an instance you pick an Amazon Machine Image (AMI), which is a template holding the operating system and software. You then pick an instance type, storage, network settings and a key pair for secure login.

An AMI can be reused to launch many identical servers, so it also acts as a way to copy a configuration.

Instance type families

Instance types are grouped into families by the kind of work they suit.

FamilyBest forExample use
General purposeBalanced central processing unit (CPU), memory and networkWeb servers, small databases
Compute optimizedHigh processing powerBatch jobs, gaming servers, scientific modelling
Memory optimizedLarge amounts of memoryIn memory databases, big caches
Storage optimizedFast access to local storageData warehouses, high volume transaction systems
Accelerated computingGraphics processors or special chipsMachine learning, graphics rendering

A name such as m5.large has a family and generation (m5) and a size (large). Larger sizes in a family have more CPU and memory.

How you pay

EC2 offers several purchasing options, such as On Demand, Savings Plans, Reserved Instances and Spot. They are explained in the Billing, Pricing, and Support chapter.

Auto Scaling

Amazon EC2 Auto Scaling keeps the right number of instances running. You define an Auto Scaling group with a minimum, a desired and a maximum number of instances.

It can add instances when demand rises and remove them when it falls. It also replaces instances that fail a health check.

Scaling approachIdea
DynamicReact to a measure such as CPU use
ScheduledChange capacity at known times
PredictiveUse past patterns to scale ahead of demand

Scaling out and in this way delivers elasticity and saves cost, because you do not pay for idle servers.

Elastic Load Balancing

Users send HTTP and HTTPS traffic to an Application Load Balancer, which forwards it to healthy EC2 instances in two Availability Zones inside an Auto Scaling group, and sends no traffic to an instance that fails its health check. Elastic Load Balancing (ELB) distributes incoming traffic across targets such as EC2 instances in several Availability Zones. If a target is unhealthy, the load balancer stops sending traffic to it.

TypeWorks atChoose when
Application Load BalancerApplication layer, Hypertext Transfer Protocol (HTTP) and its secure form HTTPSRouting by URL path or host name
Network Load BalancerTransport layer, Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)Very high performance or static IP addresses
Gateway Load BalancerNetwork layerRunning third party security or inspection appliances
InternetusersApplication Load BalancerHTTP and HTTPSTarget groupweb servers in two AZs

Together, Auto Scaling and load balancing give high availability and elasticity. The load balancer sends traffic to healthy instances, while Auto Scaling changes how many exist.

Customer duties on EC2

Under the shared responsibility model, you patch the guest operating system, manage security groups and protect your data on EC2.

What to remember for the exam

  • EC2 gives resizable virtual servers. You choose the operating system, size and storage.
  • An AMI is a template used to launch instances.
  • Instance families: general purpose, compute optimized, memory optimized, storage optimized and accelerated computing.
  • Auto Scaling keeps capacity matched to demand and replaces unhealthy instances.
  • An Auto Scaling group has minimum, desired and maximum sizes.
  • Elastic Load Balancing spreads traffic across healthy targets in multiple AZs.
  • The Application Load Balancer is for HTTP and HTTPS. The Network Load Balancer is for TCP and UDP with high performance.
  • You manage patching of the guest operating system on EC2.
Exam tip

Memory heavy work such as large in memory databases points to memory optimized instances. Graphics processor (GPU) or machine learning work points to accelerated computing.

Common mistakes

Thinking Auto Scaling needs a load balancer. They work well together, but each one can be used alone.

Confusing the load balancers. Path based routing for web traffic is an Application Load Balancer feature.

Choosing the largest instance "to be safe". Right sizing and scaling out save money.

Forgetting that EC2 requires patching. AWS does not patch your instances for you.

Watch out

A load balancer spreads traffic but does not create servers. Auto Scaling is the feature that changes how many instances exist.

Check yourself

  • What does an Auto Scaling group do when an instance becomes unhealthy?

    It replaces it, keeping the group at the desired number of instances.

  • Which load balancer routes HTTP traffic by URL path?

    The Application Load Balancer.

  • Which instance family suits large in memory databases?

    Memory optimized.

Topic 3 of 11 in Cloud Technology and Services

Test yourself on Cloud Technology and Services

The full AWS CLF-C02 question bank has 832 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.