Bezpieczne wdrożenia canary i rollback
Wdrażaj zmiany w systemach serverless bez przestojów. Poznaj aliasy Lambda, ważone przekierowywanie ruchu, wdrożenia canary w CodeDeploy oraz automatyczny rollback po wystąpieniu alertów.
Bezpieczne wdrożenia canary i rollback to bezpłatna lekcja Serverless Backend with AWS Lambda & API Gateway na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Serverless Backend with AWS Lambda & API Gateway, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Serverless Backend with AWS Lambda & API Gateway zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
The Risk of Big-Bang Deploys
Switching all traffic to new code at once means a bug hits every user instantly. Progressive deployments shift traffic gradually so problems surface on a small slice first.
Lambda Versions and Aliases
Publishing a Lambda creates an immutable version. An alias is a pointer (like live) you can move between versions, enabling controlled cutovers.
Weighted Aliases
An alias can split traffic between two versions by weight, sending, say, 10% to the new version and 90% to the old.
aws lambda update-alias \
--function-name api --name live \
--function-version 12 \
--routing-config '{"AdditionalVersionWeights":{"11":0.9}}'Canary Deployments
A canary sends a small percentage of traffic to the new version, waits, then promotes the rest if healthy. CodeDeploy automates this for Lambda.
Deployment Preferences in SAM
SAM exposes this via DeploymentPreference, choosing a canary or linear pattern.
AutoPublishAlias: live
DeploymentPreference:
Type: Canary10Percent5Minutes
Alarms:
- !Ref ErrorAlarmLinear Deployments
A linear pattern shifts traffic in equal increments over time (e.g. 10% every minute), giving a slower, steadier rollout than a single canary step.
CloudWatch Alarms as Gates
Attach alarms (error rate, latency) to the deployment. If an alarm fires during the shift, the deployment is considered failed.
Automatic Rollback
When an alarm trips, CodeDeploy automatically moves the alias back to the previous version, restoring known-good code with no manual action.
Pre and Post Traffic Hooks
Lifecycle hook Lambdas run before and after traffic shifts, letting you run smoke tests and abort the deploy if they fail.
Blue/Green vs Canary
Blue/green stands up a full second environment and switches over; canary shifts a percentage within one environment. For Lambda, weighted aliases make canary the simpler, cheaper default.
Best Practices
Deploy safely:
- Always deploy behind an alias
- Start with a small canary percentage
- Gate on meaningful alarms
- Run smoke tests in pre-traffic hooks
Quick Check
Test your safe-deployment knowledge.
Recap
You learned progressive delivery:
- Versions are immutable; aliases point to them
- Weighted aliases and canaries shift traffic gradually
- SAM DeploymentPreference automates canary/linear patterns
- Alarms gate the rollout and trigger automatic rollback
Ucz się Serverless Backend with AWS Lambda & API Gateway dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 12
- Lekcje
- 48
Często zadawane pytania
Czy lekcja „Bezpieczne wdrożenia canary i rollback” jest bezpłatna?
Tak — pełny tekst „Bezpieczne wdrożenia canary i rollback” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Serverless Backend with AWS Lambda & API Gateway, przejdź na CoddyKit PRO. Kurs Serverless Backend with AWS Lambda & API Gateway zawiera 4 lekcji w sumie.
Co nauczysz się w „Bezpieczne wdrożenia canary i rollback”?
Wdrażaj zmiany w systemach serverless bez przestojów. Poznaj aliasy Lambda, ważone przekierowywanie ruchu, wdrożenia canary w CodeDeploy oraz automatyczny rollback po wystąpieniu alertów. Ćwiczysz Serverless Backend with AWS Lambda & API Gateway z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Serverless Backend with AWS Lambda & API Gateway?
Nie wymagamy żadnego doświadczenia. Serverless Backend with AWS Lambda & API Gateway w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Bezpieczne wdrożenia canary i rollback”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Serverless Backend with AWS Lambda & API Gateway?
Tak. Każda lekcja Serverless Backend with AWS Lambda & API Gateway zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- CodeCommit i CodeBuild
- CodePipeline na potrzeby wdrożeń
- Automatyzacja wdrożeń serverless
- Bezpieczne wdrożenia canary i rollback