DynamoDB and TTL

What is TTL?

Configuring TTL in DynamoDB

Things to watch out for in DynamoDB TTL

  • TTL attribute should be of type Number.
  • TTL attribute value should be in epoch timestamp and the timestamp should be a future date.
  • DynamoDB doesn’t guarantee instantaneous deletion of items when the time is exceeded but guarantees deletion within 48 hour time period.
  • Since instantaneous delete is not guaranteed, developers should take measures to filter out expired items.
  • Any change in TTL settings will take 1 hour to reflect the changes.
  • DynamoDB streams could be used for data recovery but the data would be available for the 24 hour window only.

Applications of DynamoDB TTL

  • User session management where you can set a session-timeout for the records to expire and delete.
  • OTP or temporary credential management.
  • Deletion historical records. Eg. if your application is bound to hold data from latest 7 days, anything older than 7 days have to be deleted.
  • Managing API Gateway web-socket connections which are orphaned or not active for example, in the last 10 minutes.




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