Q71 — AWS DOP-C02 Ch.3
Question 71 of 100 | ← Chapter 3
A company runs an application on Amazon EC2 instances in an Auto Scaling group. The application processes messages from an Amazon Simple Queue Service (SQS) queue.
- A. Create an AWS Lambda function. Publish per-instance queue message metrics using SQS ApproximateNumberOfMessagesVisible and Auto Scaling Group InstanceCount properties. Configure the Lambda function to publish a custom metric. Schedule an Amazon EventBridge rule hourly to invoke the Lambda function. Create a target tracking scaling policy for the Auto Scaling group using the custom metric.
- B. Create an AWS Lambda function. Publish per-instance queue message metrics using SQS ApproximateNumberOfMessagesVisible and Auto Scaling Group InstanceCount properties. Configure a CloudWatch Logs subscription filter on application logs targeting the Lambda function. Create a target tracking scaling policy for the Auto Scaling group using the custom metric.
- C. Create a target tracking scaling policy for the Auto Scaling group. In the policy, use the SQS ApproximateNumberOfMessagesVisible metric and the Auto Scaling Group InstanceCount property with CloudWatch Metric Math to compute the number of messages per instance. Use the computed metric to scale. ✓
- D. Create an AWS Lambda function that logs the SQS ApproximateNumberOfMessagesVisible metric to a CloudWatch Logs log group. Schedule an Amazon EventBridge rule to run the Lambda function every 5 minutes. Create a metric filter to count log events from the CloudWatch Logs log group. Create a target tracking scaling policy for the Auto Scaling group using the custom metric.
Correct Answer: C. Create a target tracking scaling policy for the Auto Scaling group. In the policy, use the SQS ApproximateNumberOfMessagesVisible metric and the Auto Scaling Group InstanceCount property with CloudWatch Metric Math to compute the number of messages per instance. Use the computed metric to scale.
Explanation
This question tests optimizing Auto Scaling groups to rapidly process SQS queue messages. AWS documentation states that target tracking scaling policies support scaling based on custom or service metrics. Option C uses SQS’s ApproximateNumberOfMessagesVisible metric and divides it by the current instance count using CloudWatch Metric Math (e.g., messages / instances) to compute per-instance load—directly driving scaling decisions. This approach requires no additional components (e.g., Lambda, log subscriptions) and leverages native CloudWatch functionality. Compared to other options requiring custom code or complex orchestration, Option C satisfies the requirement for minimal operational overhead.