Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm in the process of migrating an existing NodeJS application to run as a Lambda function. So far I've identified that the main function which sends an HTTP POST request can be placed into a Lambda function, however, this function is invoked via a For Loop in which after each iteration has a random delay. The For Loop's iteration count is defined by a user request.

The only way I can think of is having a normal NodeJS process that runs the "Loop" which invokes the lambda. But this defeats the purpose of the serverless/auto-scaling architecture I am trying to create.

Am I able to replace the below for loop & random delay with a serverless/auto-scaling solution?

  for (let i = 0; i < userTasks; i++) {
    httpRequestLambda();
    await delay(); // delay can be anywhere from 5 Seconds to 20 Minutes 
  }
question from:https://stackoverflow.com/questions/65928007/aws-lambda-multiple-invocations-with-a-random-delay

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
273 views
Welcome To Ask or Share your Answers For Others

1 Answer

These are following options you can schedule AWS Lambda;

  1. Schedule AWS Lambda Functions Using CloudWatch Events

  2. Schedule AWS Lambda Functions Using EventBridge

Overview of option 1) and option 2) is also available on this AWS blog with AWS web-console screen-shots.

  1. Schedule a Serverless Workflow with AWS Step Functions and Amazon CloudWatch. You can also add delay as mentioned in this sample Task Timer project.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...