A developer is building a video transcoding application where upload events are published to an Amazon SNS topic and fanned out to an Amazon SQS standard queue. A fleet of worker instances running on Amazon EC2 polls this queue to retrieve and transcode the videos. The transcoding process takes between to minutes per video depending on its file size. The SQS queue has a default Visibility Timeout of minutes. The developer notices that during peak usage, larger videos that require more than minutes to process are being transcoded multiple times by different EC2 worker instances.
Which of the following actions will resolve this issue and prevent duplicate transcoding?
- AConfigure the Amazon EC2 workers to poll the queue using long polling by setting the `WaitTimeSeconds` parameter of the `ReceiveMessage` API call to seconds to keep the connection open during transcoding.
- Configure the worker application to call the `ChangeMessageVisibility` API to extend the message visibility timeout during transcoding, or increase the queue's default Visibility Timeout to minutes.Cevap
- CConvert the SQS standard queue to an SQS FIFO queue and enable content-based deduplication to prevent duplicate message retrieval by other worker instances.
- DDecrease the default Visibility Timeout of the SQS queue to minute so that if a worker fails, other worker instances can immediately pick up the message and restart the transcoding.
Cevap
Configure the worker application to call the `ChangeMessageVisibility` API to extend the message visibility timeout during transcoding, or increase the queue's default Visibility Timeout to minutes.
The correct answer is to extend the visibility timeout dynamically using the `ChangeMessageVisibility` API or increase the default Visibility Timeout to a value larger than the maximum processing time. This ensures that the message remains hidden from other workers until the transcoding process completes and the worker deletes the message.
Adım Adım Çözüm
Anahtar Kavram
SQS Visibility Timeout Management
Alternatif Yöntem
Instead of a static visibility timeout, you can run a background thread within the worker that periodically calls `ChangeMessageVisibility` to heartbeat and extend the timeout in increments as long as the process is alive.
Tahmini Süre:2m 0s