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).
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.
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.
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
- Routing
/apisomewhere else is an Application Load Balancer, because only it parses HTTP. A Network Load Balancer never sees the path and DNS answers before a path exists. - ECS against EKS answers WHO ORCHESTRATES; EC2 against Fargate answers WHO OWNS THE SERVERS. Read the requirement for which of the two halves it is actually about.
- A known daily pattern is scheduled scaling. A dynamic policy reacts after the load arrives and its instances still take minutes to be useful, which is exactly the complaint in the stem.
- Lambda is billed only while the code runs, so it wins on spiky work and usually loses on a process that is busy all day. "No servers to manage" alone does not decide it.
- 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
- Whenever a user uploads a photo, a three-second job must produce three thumbnails from it. Uploads are wildly uneven: nothing for an hour, then five thousand in a minute. The team does not want to run, patch or scale servers, and wants to pay only when photos actually arrive. What should they use? machine-checked
- One hostname must serve two different back ends: requests whose path starts with /api go to a container service, and everything else goes to a static web tier. The decision has to be made by reading the HTTP path of each request. Which service does this? machine-checked
- A team has containerised its application and wants to keep the container image as its unit of deployment. It does not want to choose, patch, scale or pay for EC2 instances to host those containers. What should it use? machine-checked
- A payroll application is idle overnight and is hammered every weekday between 08:00 and 10:00. The pattern has been the same for three years. The team wants the extra capacity in place before the users arrive, not several minutes after a processor alarm has fired. Which Auto Scaling approach fits best? machine-checked
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
- Ways in: console, CLI, SDKs and infrastructure as code
- Regions, Availability Zones and edge locations
- EC2 and choosing an instance type
- Containers, serverless, auto scaling and load balancing — you are here
- Relational, NoSQL and in-memory databases, and moving them
- VPCs, subnets, traffic controls and private connectivity
- Object storage and the S3 storage classes
- Block, file and hybrid storage, lifecycle rules and backup
- Machine learning and analytics services
- Messaging, integration and business applications
- Developer tools, end-user computing, front end and IoT