Aller au contenu principal

Lab : Optimisation des Coûts

Objectif​

Analyser une infrastructure AWS et proposer des recommandations d'optimisation avec justifications et estimations d'économies.

Scénario​

Contexte​

TechStartup Inc. dépense $15,000/mois sur AWS et souhaite réduire ses coûts de 30% sans impacter les performances.

Infrastructure Actuelle​

┌─────────────────────────────────────────────────────────────┐
│ INFRASTRUCTURE TECHSTARTUP │
├─────────────────────────────────────────────────────────────┤
│ │
│ COMPUTE ($8,500/mois) │
│ ───────────────────── │
│ • 10x m5.xlarge (production web) 24/7 $1,400 │
│ • 5x m5.large (production API) 24/7 $350 │
│ • 3x r5.2xlarge (production DB) 24/7 $900 │
│ • 5x m5.large (staging) 24/7 $350 │
│ • 8x c5.xlarge (batch processing) 24/7 $1,100 │
│ • 4x t3.large (dev) 24/7 $250 │
│ • 2x m5.xlarge (CI/CD runners) 24/7 $280 │
│ Autres (Lambda, misc) $3,870 │
│ │
│ STORAGE ($3,000/mois) │
│ ───────────────────── │
│ • EBS gp2 volumes 5 TB $500 │
│ • S3 Standard 20 TB $460 │
│ • EBS Snapshots 10 TB $500 │
│ • RDS Storage 2 TB $200 │
│ • Backup/Archive $1,340 │
│ │
│ NETWORK ($2,500/mois) │
│ ───────────────────── │
│ • NAT Gateways (3x) $300 │
│ • Data Transfer $2,000 │
│ • Load Balancers (5x) $200 │
│ │
│ AUTRES ($1,000/mois) │
│ ─────────────────── │
│ • CloudWatch, Secrets Manager, etc. │
│ │
│ TOTAL : $15,000/mois │
│ │
└─────────────────────────────────────────────────────────────┘

Métriques d'Utilisation​

RessourceCPU AvgMem AvgHeures actives
Web (prod)35%45%24/7
API (prod)40%50%24/7
DB (prod)65%70%24/7
Staging15%20%9h-18h weekdays
Batch80%60%2h/jour (nuit)
Dev10%15%9h-18h weekdays
CI/CD25%30%Variable

Partie 1 : Analyse des Coûts​

Exercice 1.1 : Identification des Problèmes​

Identifiez les 5 principales sources de gaspillage :

#RessourceProblèmeImpact Estimé
1??$?/mois
2??$?/mois
3??$?/mois
4??$?/mois
5??$?/mois
💡 Solution
#RessourceProblèmeImpact Estimé
1Staging 24/7Devrait être arrêté hors heures$250/mois
2Dev 24/7Idem, gaspillage nuit/weekend$180/mois
3Batch 24/7Ne tourne que 2h/jour$900/mois
4Web surdimensionnéCPU 35% → right-size$400/mois
5Pas de RI/SPTout en On-Demand$2,500/mois

Exercice 1.2 : Analyse par Tag​

Le tagging actuel est incomplet. Proposez une stratégie de tagging :

TagObligatoireValeurs Possibles
?Oui/Non?
?Oui/Non?
?Oui/Non?
?Oui/Non?
💡 Solution
TagObligatoireValeurs Possibles
EnvironmentOuiproduction, staging, development
ProjectOuiweb-app, api, batch, infra
OwnerOuiteam-frontend, team-backend, team-data
CostCenterOuiCC-PROD, CC-DEV, CC-OPS
AutoShutdownNontrue, false
ExpiryDateNonYYYY-MM-DD

Partie 2 : Plan d'Optimisation​

Exercice 2.1 : Right-Sizing​

Proposez de nouveaux types d'instances :

ActuelNouveauJustificationÉconomie
m5.xlarge (web)??$?
m5.large (staging)??$?
t3.large (dev)??$?
💡 Solution
ActuelNouveauJustificationÉconomie
10x m5.xlarge (web)10x m5.largeCPU 35% OK avec large$700/mois
5x m5.large (staging)3x t3.mediumStaging utilisé peu, burstable OK$280/mois
4x t3.large (dev)4x t3.mediumDev très sous-utilisé$100/mois

Exercice 2.2 : Scheduling​

Configurez l'arrêt automatique des environnements non-prod :

# Complétez le script de scheduling
# Staging : arrêt 18h, démarrage 9h (weekdays)
# Dev : arrêt 19h, démarrage 8h (weekdays)

# EventBridge rule pour arrêt staging à 18h
aws events put-rule \
--name stop-staging-evening \
--schedule-expression "cron(_______________)" \
--state ENABLED

# Lambda ou SSM Automation target
# ...
💡 Solution
# Arrêt staging à 18h UTC, Lun-Ven
aws events put-rule \
--name stop-staging-evening \
--schedule-expression "cron(0 18 ? * MON-FRI *)" \
--state ENABLED

# Démarrage staging à 9h UTC, Lun-Ven
aws events put-rule \
--name start-staging-morning \
--schedule-expression "cron(0 9 ? * MON-FRI *)" \
--state ENABLED

# Arrêt dev à 19h UTC, Lun-Ven
aws events put-rule \
--name stop-dev-evening \
--schedule-expression "cron(0 19 ? * MON-FRI *)" \
--state ENABLED

# Démarrage dev à 8h UTC, Lun-Ven
aws events put-rule \
--name start-dev-morning \
--schedule-expression "cron(0 8 ? * MON-FRI *)" \
--state ENABLED

Économie staging : 14h/jour × 5 jours × 4 semaines = 280h/mois (vs 720h) → Réduction ~60% = $210/mois

Économie dev : 13h/jour × 5 jours × 4 semaines = 260h/mois → Réduction ~65% = $160/mois

Exercice 2.3 : Spot Instances​

Identifiez les workloads candidats pour Spot :

WorkloadCandidat Spot ?Justification
Web (prod)??
Batch processing??
CI/CD runners??
💡 Solution
WorkloadCandidat Spot ?Justification
Web (prod)❌ NonCritique, ne peut pas être interrompu
Batch processing✅ OuiExécution courte, peut reprendre, 60-90% économie
CI/CD runners✅ OuiTolérant aux interruptions, jobs peuvent retry

Économies Spot :

  • Batch : $1,100 × 70% = $770/mois d'économie
  • CI/CD : $280 × 65% = $180/mois d'économie

Exercice 2.4 : Reserved Instances / Savings Plans​

Calculez la couverture optimale :

Workload stable 24/7 (candidat RI/SP) :
- Production web : 10 instances → ?
- Production API : 5 instances → ?
- Production DB : 3 instances → ?

Calcul économie avec 1-year Savings Plan (-30%) :
💡 Solution

Workload stable (après right-sizing) :

  • Web : 10x m5.large = ~$700/mois
  • API : 5x m5.large = ~$350/mois
  • DB : 3x r5.2xlarge = ~$900/mois

Total éligible RI/SP : $1,950/mois

Avec Compute Savings Plan 1-year (-30%) :

  • Économie : $1,950 × 30% = $585/mois

Engagement mensuel : $1,365/mois (vs $1,950)

Partie 3 : Optimisation Storage​

Exercice 3.1 : Migration gp2 → gp3​

EBS gp2 actuel : 5 TB = $500/mois
Migration vers gp3 : calcul économie
💡 Solution

gp2 pricing : $0.10/GB/mois = 5000 × $0.10 = $500/mois

gp3 pricing : $0.08/GB/mois = 5000 × $0.08 = $400/mois

Économie : $100/mois (20%)

Plus : gp3 offre 3000 IOPS de base gratuits vs gp2 qui scale avec la taille.

Exercice 3.2 : S3 Lifecycle Policies​

Proposez des règles de lifecycle pour S3 :

ClasseAprèsDonnéesÉconomie
Standard0 joursActivesRéférence
????
????
💡 Solution
ClasseAprèsDonnéesCoût/GB
Standard0 jours< 30 jours$0.023
Standard-IA30 jours30-90 jours$0.0125
Glacier90 jours> 90 jours$0.004

Estimation avec 20 TB :

  • Si 30% actif, 40% IA, 30% archive
  • Standard : 6 TB × $0.023 = $138
  • IA : 8 TB × $0.0125 = $100
  • Glacier : 6 TB × $0.004 = $24
  • Total : $262/mois vs $460 = $198 économie (43%)

Partie 4 : Synthèse​

Exercice 4.1 : Tableau Récapitulatif​

Complétez le tableau des économies :

CatégorieActionÉconomie/mois%
ComputeRight-sizing$??%
ComputeScheduling$??%
ComputeSpot$??%
ComputeSavings Plans$??%
Storagegp2→gp3$??%
StorageS3 Lifecycle$??%
TOTAL$??%
💡 Solution
CatégorieActionÉconomie/mois% du total
ComputeRight-sizing$1,0807.2%
ComputeScheduling$3702.5%
ComputeSpot (batch+CI)$9506.3%
ComputeSavings Plans$5853.9%
Storagegp2→gp3$1000.7%
StorageS3 Lifecycle$1981.3%
TOTAL$3,28321.9%

Coût initial : $15,000/mois Coût optimisé : $11,717/mois Économie : $3,283/mois soit ~22%

Pour atteindre 30%, actions supplémentaires :

  • Revoir architecture (serverless ?)
  • Négocier EDP avec AWS
  • Optimiser data transfer

Livrable Final​

Document à Produire​

  1. Analyse de l'existant avec identification des gaspillages
  2. Stratégie de tagging complète
  3. Plan d'optimisation détaillé avec calculs
  4. Tableau récapitulatif des économies
  5. Recommandations prioritaires (quick wins vs long terme)

Critères d'Évaluation​

CritèrePoints
Analyse correcte des gaspillages/20
Stratégie de tagging/15
Calculs d'économies/25
Plan actionnable/25
Qualité du document/15
Total/100

Semaine suivante : MODULE 15 - CloudFormation