Auto Scaling e bilanciamento del carico
Renda il backend basato su EC2 resiliente ed elastico combinando gli Auto Scaling Group con un Application Load Balancer per gestire il traffico variabile.
Auto Scaling e bilanciamento del carico è una lezione AWS for Backend Developers (EC2, S3, RDS, Lambda) gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento AWS for Backend Developers (EC2, S3, RDS, Lambda), e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso AWS for Backend Developers (EC2, S3, RDS, Lambda) include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
From One Server to Many
One EC2 instance is a single point of failure. Backends run an Auto Scaling Group of instances behind a load balancer that spreads requests across them.
The Launch Template
An ASG needs a recipe for the instances it spins up. A launch template defines the AMI, instance type, and startup configuration.
Anatomy of an Auto Scaling Group
An Auto Scaling Group holds a minimum, desired, and maximum count. It keeps the desired number running and replaces unhealthy instances on its own.
Health Checks
The ASG runs health checks: when an instance fails, it terminates that one and launches a replacement, holding the fleet at the desired size.
Why a Load Balancer?
A load balancer gives clients one stable endpoint while spreading requests across healthy instances. The ALB works at HTTP and routes by path or host.
Listeners and Target Groups
Two ALB pieces: a listener watches a port (like 80) for connections, and a target group is the pool of instances it forwards to.
Connecting the ASG to the ALB
The ASG auto-registers its instances with the target group, so new instances start getting traffic and terminated ones are removed — no manual wiring.
Scaling Policies
A scaling policy adjusts the desired count by metric. Target tracking is simplest: hold average CPU near, say, 50% and AWS adds or removes instances to keep it.
A Python Scaling Simulation
This snippet models target tracking — comparing current CPU to the target to compute the new instance count.
current_cpu = 80
target_cpu = 50
current_count = 4
desired = round(current_count * current_cpu / target_cpu)
print('Scale to', desired, 'instances')Multi-AZ for High Availability
Spread the ASG across multiple Availability Zones. If one AZ goes down, instances in the others keep serving and the ALB stops routing to the failed zone.
Cost and Cooldowns
Scaling out costs money, and rapid up-down thrashing wastes it. A cooldown pauses further scaling so the fleet stabilizes before reacting again.
Quick Check
A traffic spike hits your fleet — what does target tracking do, and how does the ALB keep responses flowing?
Recap: Elastic, Resilient Backends
Recap: launch templates define instances, Auto Scaling Groups self-heal around min/desired/max, and an ALB with target-tracking and multi-AZ adds elasticity and resilience.
Impara AWS for Backend Developers (EC2, S3, RDS, Lambda) con un tutor IA — gratis
Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.
- Corsi
- 12
- Lezioni
- 48
Domande Frequenti
La lezione «Auto Scaling e bilanciamento del carico» è gratuita?
Sì — il testo completo di «Auto Scaling e bilanciamento del carico» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso AWS for Backend Developers (EC2, S3, RDS, Lambda), passa a CoddyKit PRO. Il corso AWS for Backend Developers (EC2, S3, RDS, Lambda) include 4 lezioni in totale.
Cosa imparerò in «Auto Scaling e bilanciamento del carico»?
Renda il backend basato su EC2 resiliente ed elastico combinando gli Auto Scaling Group con un Application Load Balancer per gestire il traffico variabile. Eserciti AWS for Backend Developers (EC2, S3, RDS, Lambda) con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare AWS for Backend Developers (EC2, S3, RDS, Lambda)?
Non è richiesta alcuna esperienza precedente. AWS for Backend Developers (EC2, S3, RDS, Lambda) su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Auto Scaling e bilanciamento del carico»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione AWS for Backend Developers (EC2, S3, RDS, Lambda)?
Sì. Ogni lezione AWS for Backend Developers (EC2, S3, RDS, Lambda) include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Introduzione ad AWS per il backend
- Avvio della prima istanza EC2
- Connessione e gestione di base di EC2
- Auto Scaling e bilanciamento del carico