An SQS queue backlog is growing and messages are hours old. What do you do?
IntermediateScenarioScaling and performance
Answer
Situation read → Consumers are slower than producers. Either consumers are failing, too few, or something they depend on is slow.
What I'd do →
- Check queue metrics:
ApproximateNumberOfMessagesVisible,ApproximateAgeOfOldestMessage, and whether messages go to the DLQ. - Check consumers: are they running, erroring, or stuck on poison messages that keep returning after the visibility timeout?
- Scale consumers on queue depth with KEDA:
triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.ap-south-1.amazonaws.com/123456789012/orders
queueLength: "100"
awsRegion: ap-south-1
- Make sure the downstream (DB, API) can take the extra throughput; scaling consumers can overload it.
- Set a
maxReceiveCountredrive policy so poison messages go to a DLQ instead of blocking.
Why → Scaling on queue depth matches capacity to work; scaling on CPU doesn't.
Interview tip → Mention poison messages and visibility timeout; they cause backlogs with no capacity issue at all.
More on Scaling and performance
Traffic is expected to 10x for a sale next week. How do you prepare the platform?IntermediateThe HPA is configured but pods don't scale even though the app is slow. Why?BeginnerPods are Pending during a traffic spike because the cluster is out of capacity. What do you do now and long term?IntermediateThe database CPU is at 95% and the API is timing out. What's your approach?Intermediate"Too many connections" errors from Postgres after scaling the app out. How do you fix it?IntermediateLatency is fine on average but p99 is terrible. Where do you look?Advanced