Containers, serverless, auto scaling and load balancing

Where the servers go: containers on instances you own or on capacity AWS owns, functions with no instances at all, and the two mechanisms that make a fleet follow demand instead of the other way round.

Lesson 4 of 11 in objective 3. Cloud technology and services, part of AWS Certified Cloud Practitioner (CLF-C02).

Ways to run code, ordered by how much of the machine is still yours. From AWS runs the host to You run the host: AWS Lambda (a function per event; nothing of yours runs between invocations), then AWS Fargate (containers on capacity AWS owns; you declare vCPU and memory per task), then ECS or EKS on EC2 (AWS schedules the containers; the instances underneath are yours to size and patch), then EC2 with a runtime you installed (the instance, its image, and the orchestration too). AWS runs the host AWS Lambda a function per event; nothing of yours runs between invocations AWS Fargate containers on capacity AWS owns; you declare vCPU and memory per task ECS or EKS on EC2 AWS schedules the containers; the instances underneath are yours to size and patch EC2 with a runtime you installed the instance, its image, and the orchestration too You run the host
Ways to run code, ordered by how much of the machine is still yours.

Serverless means somebody else has the server

AWS Lambda runs a function in response to an event — an object arriving in a bucket, a message on a queue, an HTTP request — and scales out to run many invocations concurrently without being asked. You supply the code and AWS supplies everything under it, there is a maximum run time per invocation of fifteen minutes, and you are billed only for the time the code actually runs.

That last property is the whole economics, and it cuts both ways. Nothing happening costs nothing, which makes Lambda excellent for work that arrives in unpredictable bursts: five thousand photo uploads in a minute and then an hour of silence. A process that is busy all day is usually cheaper on a container or an instance, so "serverless is cheaper" is not the fit test. Short, event-driven and stateless is.

Two questions hide inside every container question

The first is who orchestrates: Amazon ECS is AWS's own container orchestrator, and Amazon EKS is managed Kubernetes, which is the answer when a team already has Kubernetes skills or manifests it wants to keep. The second is who owns the servers: with an EC2 capacity provider the container instances are yours to choose, patch and count, while AWS Fargate runs the tasks on capacity AWS owns and you declare only the vCPU and memory each task needs.

The two questions are independent, which is why "ECS on Fargate" and "EKS on EC2" are both perfectly ordinary sentences and why a question has to be read for which half it is really about. A requirement that says the team does not want to choose, patch or pay for instances is answering the second question and says nothing about the first. Container images themselves live in Amazon ECR.

Load balancing, separated by how deep the request is read

Elastic Load Balancing spreads requests across healthy targets in several Availability Zones and stops sending traffic to anything failing its health check. The three types differ in what they can see. Only the Application Load Balancer parses HTTP, so only it can send requests whose path begins with /api to one target group and everything else to another; that content-based routing is what a question about one hostname and two back ends is asking for.

A Network Load Balancer forwards connections by port at very high throughput and never sees a path, because it does not parse HTTP at all. A Gateway Load Balancer exists to put security appliances transparently in the traffic path. And Amazon Route 53 is not a load balancer in this sense: DNS resolves a name before the request is made, so the resolver cannot know a URL path, and weighted records split traffic by proportion rather than by content.

Three load balancers, and how far into the traffic each one looks. Application — Reads: HTTP and HTTPS; Routes on: Path, host header, HTTP header, method; Reach for it when: A web application or containers behind one hostname. Network — Reads: TCP and UDP connections; Routes on: Port, at very high throughput and very low latency; Reach for it when: Extreme throughput, or a static IP address per zone. Gateway — Reads: Whatever passes through it; Routes on: Nothing — it inserts an appliance into the path; Reach for it when: Third-party firewalls and inspection appliances Application Network Gateway Reads HTTP and HTTPS TCP and UDP connections Whatever passes through it Routes on Path, host header, HTTP header, method Port, at very high throughput and very low latency Nothing — it inserts an appliance into the path Reach for it when A web application or containers behind one hostname Extreme throughput, or a static IP address per zone Third-party firewalls and inspection appliances
Three load balancers, and how far into the traffic each one looks.

Scaling on a clock, on a metric, or on a forecast

EC2 Auto Scaling can be driven manually, on a schedule, dynamically from a metric such as average processor use or request count, or predictively from a forecast. The distinction the exam leans on is that a dynamic policy is by definition a REACTION: the alarm fires after the load appears, and the new instances still need minutes to boot and pass health checks, so the earliest arrivals get the slow application anyway.

When the pattern is known in advance — idle overnight, hammered between 08:00 and 10:00 every weekday for three years — a scheduled action puts the capacity in service before the users arrive and removes it afterwards. A mature configuration usually runs both: the scheduled action for the pattern you know and a dynamic policy as the safety net. The point of all of it is elasticity in both directions, and the second direction is where the money is.

What starts the scaling action, and when the capacity is actually there. Scheduled — What triggers it: The clock; Capacity arrives: Before the load does; Fits: A pattern that has been the same for years. Dynamic — What triggers it: A metric crossing a threshold; Capacity arrives: Minutes after the load, once instances boot and pass health checks; Fits: The day that is not like the others. Predictive — What triggers it: A forecast built from history; Capacity arrives: Ahead of the forecast peak; Fits: Recurring load with a shape worth learning Scheduled Dynamic Predictive What triggers it The clock A metric crossing a threshold A forecast built from history Capacity arrives Before the load does Minutes after the load, once instances boot and pass health checks Ahead of the forecast peak Fits A pattern that has been the same for years The day that is not like the others Recurring load with a shape worth learning
What starts the scaling action, and when the capacity is actually there.

Worth carrying in

AWS Lambda
Event-driven functions, concurrent by default, fifteen minutes maximum per invocation, billed while running.
AWS Fargate
Containers on capacity AWS owns. Declare vCPU and memory; no instances in your account.
Amazon ECS
AWS's own container orchestrator. Runs tasks on EC2 or on Fargate.
Amazon EKS
Managed Kubernetes. The answer when the team already has Kubernetes.
Amazon ECR
The registry the container images live in.
Application Load Balancer
HTTP and HTTPS. Routes on path, host and header to different target groups.
Network Load Balancer
TCP and UDP by port. Extreme throughput, and a static IP address per Availability Zone.
Gateway Load Balancer
Inserts third-party appliances — firewalls, intrusion detection — into the traffic path.
EC2 Auto Scaling
Manual, scheduled, dynamic and predictive scaling of a group of instances.

What the exam does with this

Objective
3. Cloud technology and services
Share of the exam
34% (the whole objective)
Questions in this lesson
4
Signed for by a person
0

Partly checked. None of the 4 questions here has been read against the cited source by a person. 4 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.

Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.

Questions in this lesson

Drill this lesson

A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.

Practise Containers, serverless, auto scaling and load balancing

The rest of objective 3