Can we use Step function AWS over setTimeout for scheduling

0 votes

I wish to create API service where any client can pass his HTTP request and time in seconds after which the HTTP request should be executed. This is what I could think of

  1. First create a lambda with nodeJS and use setTimeout to wait
  2. Second create a step function to wait for x number of seconds would call my lambda to execute HTTP request

So, what are the pros and cons of each. setTimeout looks easy to implement and with no obvious flaws. What is the reason I should choose stepfunction?

Apr 20, 2018 in AWS by DragonLord999
• 8,450 points
1,565 views

2 answers to this question.

0 votes

These are some of the pointers that hit me when I saw your question:

  1. Lambda can timeout. Whereas StepFunctions can wait for e.g. a year also.
  2. Lambda will cost for the time it is waiting but StepFunction will not.
  3. There is a limit on concurrent executions for lambda totalling to 1000 whereas a StepFunction can have maximum 1,000,000 open executions.

Refer this for more info:
https://docs.aws.amazon.com/step-functions/latest/dg/limits.html#service-limits-state-machine-executions
https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#per-function-concurrency

answered Apr 20, 2018 by Meci Matt
• 9,460 points
0 votes

I think you have a few things that you need to work through first:

1) Activities behave as an SQS queue, to which you basically say "hey gimme the next activity". They don't support any sort of "gimme the activity for this execution ARN I happen to know" or any way to get a "specific" activity.
1.a) You can get around this by having a poller that polls for your activities when they get into the scheduled state by the Step Function. You need to then store the activity information (like a unique key you setup) in a way that your true "handler" can get its data (and its subsequent taskToken).
1.b) Your true handler then gets its nod from your ECS scheduled thing, looks up its key in the database, does the work, and then uses the taskToken to inform.
1.c) There are variations of this that you could do in a crazy parallel/Wait kinda way, to avoid the ECS guy having to get at the poller database... you'd basically just do that part first and then with the taskToken in hand you would kickoff the ECS stuff.

Beyond the above - which I think would be your true blocker and much harder part - It sounds like you are requesting two new timeout settings: 

1) "ScheduledTimeoutSeconds" - how long it can wait in a scheduled state (before an Activity poller gets it) after which it would throw an error
2) "ActivityTimeoutSeconds" - how long it can take to actually handle, not including scheduling time, after which it would throw an error
 

answered Aug 20, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

0 votes
1 answer
+1 vote
1 answer

Can we use AWS Public DNS as Domian name to enable https on our instance

I don't believe you can get a ...READ MORE

answered Aug 23, 2018 in AWS by Priyaj
• 58,020 points
969 views
0 votes
1 answer

How can I just increase the size of my root disk on AWS EC2 for use with Elastic Beanstalk?

This can be done using the following ...READ MORE

answered Nov 12, 2018 in AWS by Archana
• 5,640 points
3,265 views
0 votes
0 answers

Is there any way, where I can use one IP for 2 AWS instances?

Is there any way, where I can ...READ MORE

Sep 18, 2020 in AWS by anonymous
• 19,610 points
511 views
0 votes
1 answer
+5 votes
2 answers

Can we migrate the AWS Cognito users between the user pools?

Yes, it is possible that this scenario ...READ MORE

answered Apr 13, 2018 in AWS by Cloud gunner
• 4,670 points
10,569 views
0 votes
1 answer
0 votes
1 answer
+2 votes
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP