There Is More than One Way to Schedule a Task

Photo by Nick Hillier via Unsplash
  • Seconds — A restaurant’s in-store device is unreachable. If it’s not back online soon, change their status to offline.
  • Hours — A customer orders tonight’s dinner on their way to work. We should perform more actions closer to that time.
  • Days — A restaurant is closing for a couple of weeks over the holidays. Take them offline now and bring them back online later.

DynamoDB TTL

This is often one of the first that solutions people come up. You should be familiar with it from reading Yan’s article, but I’ll summarise. The idea is that you add a task to a DynamoDB table and set the TTL timestamp to be the time at which the task should be performed. DynamoDB then deletes the item at that time which triggers a Lambda function via DynamoDB Streams.

SQS Delay Queues

SQS Queues have an attribute called DelaySeconds that lets you specify a delay between 0 and 900 seconds (15 minutes), creating a Delay Queue. When set, any message sent to the queue will only become visible to consumers after the configured delay period.

SQS Message Timers

Delay queues are only good if the same delay should be applied to every message. If you need to vary the delay, you can set the DelaySeconds value on individual messages instead, which AWS calls Message Timers.

SQS Visibility Timeout

When a consumer receives a message, the message remains in the queue but is invisible for the duration of its visibility timeout, after which other consumers will be able to see the message. Ideally, the first consumer would handle and delete the message before the visibility timeout expires.

Step Functions

Step Functions can have a state that pauses the execution for a specified number of seconds or until an absolute time. The accuracy is within a second and executions can be paused for up to a year, providing heaps of flexibility.


I hope I’ve shown that not only are there many ways to schedule messages with AWS services but that they all have their pros and cons. There is no right or wrong answer. Just make sure you understand your particular problem, read the documentation, and design your solution within the limitations. Keep in mind that those limitations can and probably will change over time.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store