AWS DevOps Cost Optimization 2 — Questions and Answers
Question 1: A DevOps team runs nightly integration tests on a fleet of EC2 instances that take 2 hours to complete. Which purchasing option minimizes cost for this predictable workload?
- On-Demand Instances
- Spot Instances with a defined duration (Correct answer)
- Reserved Instances (1-year, no upfront)
- Dedicated Hosts
Correct answer: Spot Instances with a defined duration
Spot Instances with a defined duration (now called Spot blocks) are ideal for batch jobs with a known completion time, offering up to 70% savings over On-Demand.
Question 2: Which AWS CodePipeline configuration reduces cost when multiple source changes happen in quick succession?
- Increase the pipeline polling interval to 30 minutes
- Enable pipeline execution mode set to QUEUED (Correct answer)
- Use a single pipeline stage for all actions
- Enable parallel action execution across all stages
Correct answer: Enable pipeline execution mode set to QUEUED
QUEUED execution mode causes CodePipeline to queue subsequent runs and deduplicate rapid changes, reducing unnecessary pipeline executions and associated costs.
Question 3: A team stores all CodeBuild build logs and artifacts indefinitely in S3. What is the most cost-effective way to manage this data over time?
- Enable S3 Intelligent-Tiering on the bucket
- Apply S3 Lifecycle policies to transition old artifacts to S3 Glacier and expire them after 90 days (Correct answer)
- Enable S3 Requester Pays on the bucket
- Use S3 Reduced Redundancy Storage for all artifacts
Correct answer: Apply S3 Lifecycle policies to transition old artifacts to S3 Glacier and expire them after 90 days
S3 Lifecycle policies automate transitioning infrequently accessed artifacts to cheaper storage classes and deleting them after a retention period, directly reducing storage costs.
Question 4: Which strategy best reduces AWS CodeBuild costs for a project with many small, frequent builds?
- Switch to the largest available compute type to finish builds faster
- Enable CodeBuild caching for dependencies and Docker layers (Correct answer)
- Run all builds sequentially to avoid parallel billing
- Increase build timeout to avoid retries
Correct answer: Enable CodeBuild caching for dependencies and Docker layers
CodeBuild caching stores downloaded dependencies and Docker layers between builds, significantly reducing build duration and therefore billable build minutes.
Question 5: A company uses AWS Lambda in its CI/CD pipeline for custom approval logic. Lambda is invoked thousands of times per day. Which configuration change can reduce Lambda costs?
- Increase the Lambda memory to maximum to reduce duration
- Use Provisioned Concurrency for all functions
- Right-size Lambda memory using AWS Lambda Power Tuning (Correct answer)
- Convert Lambda functions to container image format
Correct answer: Right-size Lambda memory using AWS Lambda Power Tuning
AWS Lambda Power Tuning finds the optimal memory setting that balances execution duration and cost, often finding a sweet spot that minimizes total compute cost.
Question 6: An ECS-based deployment pipeline runs tasks that scale up and down frequently. Which compute option minimizes idle costs while maintaining rapid scaling?
- EC2 launch type with On-Demand instances always running
- Fargate Spot for stateless pipeline tasks (Correct answer)
- Dedicated EC2 Reserved Instances for ECS
- EC2 launch type with Savings Plans
Correct answer: Fargate Spot for stateless pipeline tasks
Fargate Spot runs ECS tasks on spare AWS capacity at up to 70% discount, and stateless pipeline tasks can handle the possibility of interruption and restart.
Question 7: A team wants to reduce the cost of storing Docker images used in their CodePipeline deployments. What is the most cost-effective approach?
- Store all images in S3 instead of ECR
- Configure ECR Lifecycle Policies to delete untagged and old images automatically (Correct answer)
- Use Docker Hub instead of ECR for all images
- Compress all Docker images before pushing to ECR
Correct answer: Configure ECR Lifecycle Policies to delete untagged and old images automatically
ECR Lifecycle Policies automatically clean up untagged images and old image versions, reducing the total GB stored and lowering ECR storage costs.
A DevOps team runs nightly integration tests on a fleet of EC2 instances that take 2 hours to complete.
Which purchasing option minimizes cost for this predictable workload?