Skip to content

Scalability: recap and quiz

  1. Scaling up and scaling out. A bigger machine is simple and stops at the largest one, more machines have no such ceiling but need work that can be split, and at equal capacity one shared queue waits less than several.
  2. Stateless services. Any instance can answer any request when nothing a request needs is remembered by one instance, so the state moves to a database, a shared store, the client or a queue.
  3. Session handling. A session can live in one instance with sticky sessions, in a shared store, or in a signed token, and each moves the difficulty: lost sessions, a lookup per request, or a token that is hard to revoke.
  4. Autoscaling. A policy adds instances to bring utilisation to a target and removes them when the load stays low, but capacity arrives after a delay, so a sudden spike is felt in full before it helps.
Idea The common mistake The correction
Scaling out Adding instances to the part that is easy to copy Find the bottleneck first: what the instances share sets the limit
Statelessness Keeping a user’s state in the memory of the instance that served them Put it where any instance can read it, or a removed instance takes it away
Sessions Relying on sticky sessions to avoid redesigning They lose sessions when an instance goes, and the Twelve-Factor App says never to rely on them
Autoscaling Expecting it to absorb a spike It reacts to load it has seen, and its capacity arrives after the start-up delay
Headroom Setting the target as high as possible to save money A group of 4 can survive losing one only below 75%, and a spike needs room until new instances serve

A checklist: before saying we will just scale it

Section titled “A checklist: before saying we will just scale it”
  1. What is the bottleneck? The component with the highest utilisation after the change, not the one that is easy to copy.
  2. Can the work be split? If an instance holds something no other instance has, adding instances does not help, and removing one loses it.
  3. How many instances at the peak? The peak over what one instance serves at the target. 1,500 requests per second on instances of 200, at 60%, is 13.
  4. How hot can it run? A group of N survives the loss of one only up to (N − 1) ÷ N of its capacity: 75% for 4.
  5. What if the load jumps? Shortfall times the reading interval plus the start-up delay is what is rejected. Decide whether to pay for spare capacity, schedule ahead, or throttle.
  6. What are the limits? A minimum for safety, a maximum for cost, and a scale-in delay long enough to avoid flapping.

Eight questions cover the whole module. Every option is explained, whether it is right or wrong.

Scalability: module quiz

This quiz needs JavaScript to check your answers.

Question 1 of 8

One API instance can serve 200 requests per second. The peak is 1,500 requests per second, and the group is to run at no more than 60% utilisation at the peak.

How many instances does the group need at the peak?

Enter a number and choose its unit.

instances
Question 2 of 8

A group of 4 identical instances must keep serving all its traffic after one of them fails.

What is the highest utilisation at which the group can run before the failure?

Choose one answer.

Question 3 of 8

Two designs have the same total capacity, 8 slots of 20 ms each. In one, a single machine has all 8 slots. In the other, two machines have 4 slots each, and requests are spread evenly between them. Both run at 80% utilisation.

In the queueing model of the Performance module, which has the shorter mean time in the system?

Choose one answer.

Question 4 of 8

A login handler stores the user's name in a variable in the memory of the instance that handled the login. The load balancer spreads requests evenly and at random across 4 instances.

On average, what share of the user's next requests reach the instance that knows who the user is?

Enter a number and choose its unit.

percent
Question 5 of 8

A shop keeps its sessions in a shared Redis store. The cookie holds only a random session identifier.

Which statement about this design is correct?

Choose one answer.

Question 6 of 8

An autoscaling group removes 10 of its 14 instances when a spike ends. Sessions are held in each instance's memory, and the load balancer uses sticky sessions. The users were spread evenly over the 14 instances.

What happens to the users' sessions?

Choose one answer.

Question 7 of 8

Traffic jumps to four times its usual level within seconds. An autoscaling group reacts to the jump.

Which settings make the group fall further behind the jump? Select all that apply.

Choose every answer that applies.

Question 8 of 8

A group of 4 instances serving 200 requests per second each is at 400 requests per second. Traffic jumps to 1,600. The policy reads the load every 5 seconds, orders the instances it needs at the end of the 5 seconds in which the jump arrived, and each new instance serves 90 seconds after it is ordered. The group rejects whatever it cannot serve.

How many requests are rejected before the new instances serve?

Enter a number and choose its unit.

requests

The next module, Load balancing, is about the part this module took for granted: the thing that spreads requests across the instances. You have already met its effects. It decides whether a group shares one queue or splits into several, whether a user returns to the same instance, and which instances are in the group when one is added or removed.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.