Home > Software design >  The best way for deferred execution in serverless
The best way for deferred execution in serverless

Time:04-01

I have serverless microservices using API gateway/lambda/dynamodb. We have a stream of measurements coming in from Kinesis and if an alarm condition is detected, it needs to be triggered after x seconds. What's the best way to trigger a task after x seconds in this case? X is configurable by the user for different conditions and cases.

CodePudding user response:

Maybe this can help How do I delay processing of AWS Kinesis messages?

  1. use SQS delay message
  2. delay x seconds in lambda, if it is not too long(max 15min for a lambda to run)

CodePudding user response:

As users need to control the timing, and you likely will be storing other data along with the timing - I'd suggest writing a record with a TTL to DynamoDB, and then creating a function triggered by the DynamoDB Stream associated with the table.

When the TTL expires, the record will be removed, and your function will receive a DELETE event - which you can use to process the alarm.

  • Related