02 / 25 · Traffic and capacity
Auto scaling
Auto scaling changes capacity automatically when measured demand changes. A controller observes a signal, chooses a replica count and waits for new capacity to become ready. It is a delayed feedback loop, not instant unlimited capacity.
What you will practise
- Identify a useful scaling signal
- explain startup delay
- check downstream limits
Before you start: Replica, CPU usage and readiness.
About 5 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.
Download MP4CaptionsListen without the video
Download audioChapters and full transcript
Let us understand auto scaling. A shop manager sees a long checkout queue and opens another counter. Opening takes time: someone must arrive, sign in and prepare the till. Closing every quiet counter immediately would cause a new queue a minute later. The manager needs minimum staffing and patience, not just a rule that reacts to every small change. Auto scaling changes capacity automatically when measured demand changes. A controller observes a signal, chooses a replica count and waits for new capacity to become ready. It is a delayed feedback loop, not instant unlimited capacity.
Follow the normal path. The application serves visitors while metrics record utilization and request behavior. Select a signal related to the constrained resource, not simply the easiest chart. The controller compares the observed signal with a configured target and computes a desired replica count within minimum and maximum limits. SeatSpot traffic grows before a popular sale. Manual scaling may arrive too late, while leaving peak capacity running all day wastes resources. Automatic control can help, provided start-up delay and dependency limits are included.
Now change one condition. The controller requests more replicas. Scheduling, image download, initialization and health checks take time. Desired capacity and ready capacity can differ. A common misunderstanding is this: Automatic scaling is instant. Observation, scheduling, image startup and readiness all take time. Think about this. CPU is low while requests wait on a database. Should CPU scaling be your only signal? Pause the video and make your prediction. No. CPU can be low during I/O waits. Inspect latency, concurrency, database waits and the actual constrained resource.
Let us reason with a concrete example. Four replicas average 80% CPU. The target is 50%, assuming similar replicas and CPU-bound work. A simplified estimate is ceil(4 × 80 / 50) = 7 replicas. This is a teaching estimate; real controllers apply tolerances, readiness handling and other policies. Check whether seven replicas can start, whether their total database connections fit, and whether latency improves. A replica recommendation is not proof the system is safe. These figures are teaching examples, not production guarantees.
Turn the idea into a design decision. Only ready replicas should receive normal traffic. If nodes or quotas are exhausted, a controller cannot create the missing physical capacity by itself. More application copies can increase database connections. Limit aggregate concurrency so solving an application bottleneck does not create a database outage. When you try the practice task, look for this result. Seven is a simplified recommendation, not seven instantly ready or safe servers.
Check your understanding. After demand falls, stabilization prevents rapid shrinking and regrowth. Drain work before removing replicas and keep enough minimum capacity for the next burst. Here is a challenge. A queue receives 120 jobs/second. Each worker handles 20. How many workers stop backlog growth, and why might you need more? Pause before the answer. Six workers match the average under ideal assumptions. More are needed to drain existing backlog and tolerate failures or variable duration, within downstream safety limits. Monitor oldest-job age, not just queue size. For an interview, choose metrics, minimums, maximums and stabilization. Say what you would measure, not only which tool you would buy.
Start with an everyday picture
A shop manager sees a long checkout queue and opens another counter. Opening takes time: someone must arrive, sign in and prepare the till. Closing every quiet counter immediately would cause a new queue a minute later. The manager needs minimum staffing and patience, not just a rule that reacts to every small change.
Why SeatSpot needs this
SeatSpot traffic grows before a popular sale. Manual scaling may arrive too late, while leaving peak capacity running all day wastes resources. Automatic control can help, provided start-up delay and dependency limits are included.
Trace one step at a time
Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.
Observe demand
The application serves visitors while metrics record utilization and request behavior. Select a signal related to the constrained resource, not simply the easiest chart.
Read all six mechanism steps
Observe demand
The application serves visitors while metrics record utilization and request behavior. Select a signal related to the constrained resource, not simply the easiest chart.
Choose a target
The controller compares the observed signal with a configured target and computes a desired replica count within minimum and maximum limits.
Request capacity
The controller requests more replicas. Scheduling, image download, initialization and health checks take time. Desired capacity and ready capacity can differ.
Wait for readiness
Only ready replicas should receive normal traffic. If nodes or quotas are exhausted, a controller cannot create the missing physical capacity by itself.
Check dependencies
More application copies can increase database connections. Limit aggregate concurrency so solving an application bottleneck does not create a database outage.
Scale down carefully
After demand falls, stabilization prevents rapid shrinking and regrowth. Drain work before removing replicas and keep enough minimum capacity for the next burst.
Pause and make a prediction
CPU is low while requests wait on a database. Should CPU scaling be your only signal?
Correct a common misunderstanding
Claim to question: Automatic scaling is instant.
Better explanation: Observation, scheduling, image startup and readiness all take time.
Work a scaling recommendation
- Start with four replicas at 80% CPU and a 50% target.
- Calculate 4 × 80 / 50 and round up.
- List startup time, cluster quota and database-connection limits.
Check what you can explain
This is your self-check, not an automated grade. Try again without the diagram tomorrow.
0 of 3 goals checked. Choose one remaining idea to practise next.
Teach it back
Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.
Engineering model and trade-offs
Choose a signal related to the bottleneck: CPU for CPU-bound work, queue age/backlog for asynchronous jobs, or concurrency for request workers. Low CPU does not prove health when threads are waiting on a database.
Set minimum/maximum replicas, readiness checks and scale-down stabilization. A controller can request replicas while the cluster lacks nodes or the account lacks quota. Application scaling and infrastructure scaling are different loops.
New instances can amplify database connections or cold-cache misses. Warm up carefully, bound aggregate concurrency and alert when desired capacity cannot become ready. Scheduled pre-scaling may suit a known ticket-sale time.
Work through an example
Four replicas average 80% CPU. The target is 50%, assuming similar replicas and CPU-bound work.
Reason with the numbers
A simplified estimate is ceil(4 × 80 / 50) = 7 replicas. This is a teaching estimate; real controllers apply tolerances, readiness handling and other policies.
Make a decision
Check whether seven replicas can start, whether their total database connections fit, and whether latency improves. A replica recommendation is not proof the system is safe.
Implementation sketch
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata: {name: seatspot}
spec:
scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: seatspot}
minReplicas: 2
maxReplicas: 8
metrics:
- type: Resource
resource:
name: cpu
target: {type: Utilization, averageUtilization: 60}Illustrative Kubernetes configuration. CPU utilization needs CPU requests on containers and a working metrics pipeline. It does not provision a cluster or guarantee a latency objective.
Where this is used
- Traffic with changing demand and predictable start-up characteristics.
- Worker pools with measurable backlog and safe downstream concurrency.
Common mistakes
- Scaling on CPU while the database is the real bottleneck.
- Ignoring cold starts, quotas and node capacity.
- Rapid scale-down that repeatedly destroys useful warm capacity.
Practise a reasoned answer
Answer aloud or write notes before opening the reference. These prompts teach reasoning and trade-offs; they are not claimed questions from a particular company.
Why can autoscaling make an outage worse?
Choose a practice depth
- Foundation
- Describe the observe-decide-wait loop.
- Practical
- Choose metrics, minimums, maximums and stabilization.
- Advanced
- Explain quota exhaustion, feedback delay, cold-cache effects and overload protection.
Self-check rubric
- State the required user outcome and the relevant invariant.
- Explain the normal path and one failure path.
- Name a cost or consistency/latency trade-off.
- Say what you would measure or test before trusting it.
For deeper practice, connect this topic to the previous lesson and identify a shared bottleneck. A longer answer is not automatically a better answer.
Try it before viewing the solution
A queue receives 120 jobs/second. Each worker handles 20. How many workers stop backlog growth, and why might you need more?
Check one key idea
Your explanation and interview notes
Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.
Loading your local notes…
Official references and next reading
The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.