I have to set up a management on an AWS process. To keep things simple I have some clients that sends me heartbeat, let's say every 5 minutes, via SOAP requests to my SOAP server deployed on an Elastic Beanstalk NodeJS app. Every time I receive a heartbeat, I store the last time I received it on a DynamoDB table by updating a field on the table.
I now need to create a process that, if I haven't received an heartbeat in the last 30 minutes, does stuff (updates another tables, calls Lambda functions, etc). I don't know now how many clients I will have, but they will be pontentially growing with time, and connected to my server 24/7.
I was hoping on something like an event that triggers a Lambda function (or posts a message on a SNS topic) after those 30 minutes that that specific row in the table is not updated, but I don't know how to get this last part to work. This event should be checking every row in the document.
How would you do it?
Thank you!
You can use DynamoDB with TTL, DynamoDB Streams and AWS Lambda for this. No need for cron
.
When you create a new row or update an existing row, set that row's TTL to 30 minutes in the future.
When that 30 minutes is reached, it will fire up a DynamoDB stream which you can use as a trigger for a Lambda function.
This Lambda function can then do the custom processing that you want to do (i.e. updates another tables, calls Lambda functions, etc).
Take note that the original DynamoDB row will be deleted when its TTL expires. If you need to keep that record, you can let the Lambda function recreate it and set a new TTL to another 30 minutes in the future.
References:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With