Donovan
Donovan

Reputation: 816

How is Amazon SQS visibility timeout implemented?

I was wondering how would an efficient implementation of the SQS visibility timeout looks like. Are the messages put in another queue and a worker sweeps over it and removes those that reached the timeout threshold?

Upvotes: 0

Views: 508

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269081

I would personally implement it by storing a timestamp that says when to make it visible.

  • During ReceiveMessage(), do not return any messages where timestamp < now
  • In the Management Console, show timestamp < now messages as In Flight
  • When timestamp >= now, do nothing!

While there would be a lot of timestamp comparisons, this would be no worse than checking a status code. Plus, there's no need to clear the timestamp when the time has past, so it is "efficient" in that no 'sweep' processes are required.

Amazon SQS is highly distributed across multiple servers and multiple Availability Zones, so it is most efficient to avoid any possible data update since it would need to be replicated amongst servers.

Upvotes: 1

Related Questions