Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 17: Scaling

17.7 What happens when traffic increases

Why a rush needs scaling before you are awake

example.com is one t3.micro at breakfast. Then a crowd arrives in the same few minutes. CPUUtilization climbs. The page gets slow. If the only plan is you opening the console and setting desired from 1 to 2, and you are asleep, nothing changes. Desired stays 1. The site is "running" and visitors wait.

These are pictures of that rush. They are not diagrams of anyone's private systems, and they are not outage counts.

Rush What people do at once The scaling lesson
Flipkart Big Billion Day, or an Amazon sale day A sale opens and a huge number of people open the shop together Shopping traffic is a spike, not a slow Tuesday. More copies of the front servers, not a story about their warehouses
Paytm in the first days after salary is credited People pay, transfer, and recharge in the same week Payments get a calendar spike. A person who only adds a server by hand will miss the hour they are not at the desk
Netflix when a new film or series drops Many people press play in the same evening Video is a rush of viewers. One bigger box is vertical. More servers in front of the same title is horizontal
Zomato or Swiggy at dinner Orders jump in the same hour Food apps are busy on a clock. Scheduled capacity can be ready at 19:00. A surprise hour still needs an alarm
IRCTC when tatkal opens A fixed clock time, and a crowd trying to book the same minute Travel booking is a thundering herd. Ten minutes of "I will add a server now" is already late
Exam result day Students refresh the result page together Education sites are quiet all year and slammed on one morning
An Instagram reel that spreads Views jump. The app gets more requests Social traffic does not book an appointment. If you are asleep, only a policy adds the next server

example.com is the lab version of the same shape. One server at about 90% CPU, or two at about 45% each, is the arithmetic from section 17.2.

Requests arrive. A second server appears. load balancer Server A in service Server B joins Dots are requests. B fades in, then new requests can land on either server.

Requests arrive at one busy server. A second server then appears, and new requests split between the two.

What the alarm does, with numbers

  1. More users. CPU on the one server climbs.
  2. Average CPU stays greater than 70 for two periods of 5 minutes. The worked pair is 82, then 91.
  3. cpu-high-lab becomes ALARM.
  4. SNS sends the email if the subscription is Confirmed. You can be asleep. The mail waits. The policy does not.
  5. The lab's simple policy adds 1. Desired goes from 1 to 2. A second t3.micro launches. If the target group is attached, the load balancer can use it.
  6. A simple policy does not add a third server just because the alarm stays in ALARM. Step scaling (section 17.11) can: after the new instance is warm, if CPU is still above 70, add 1 again. Desired goes from 2 to 3. Maximum 3 means it will not become 4.
  7. When the rush ends, average CPU at or under 30 for two periods fires the low alarm. Scale-in removes the extra server: 3 to 2, then 2 to 1. Minimum 1 keeps one machine so the site still has a server.

Quiet, then 2, then 3 if it is still hot, then back to 1. That is the night. Your hand is not in it.

Lab

Chala, on paper.

  1. Pick Flipkart or Amazon sale day. Write "asleep, desired stays 1, the shop is slow."
  2. Pick Paytm in salary week, or Netflix when a new series drops. Write the same sentence.
  3. Pick Zomato or Swiggy at dinner, IRCTC tatkal, exam result day, or an Instagram reel.
  4. For that third rush, write "alarm fires, SNS email, desired 1 to 2."
  5. Write "CPU still above 70 after the new server is warm."
  6. Write "step scaling sets desired 2 to 3."
  7. Write "maximum 3, so it does not become 4."
  8. Write "CPU falls, scale-in returns desired toward 1."