By using AWS re:Post, you agree to the Terms of Use
/Lambda function won't run in parallel via State Machines/

Lambda function won't run in parallel via State Machines

0

I am sure I am missing some basic info but my setup is as follows:

I have 1 lambda function and I have 2 State Machines. Each state machine is calling the same lambda function twice in sequence (30 sec pause between calls) Then I have rules setup to trigger the state machines every minute.

Each state machine is passing different params to the lambda function so I am trying to get to a situation where my Lambda function is called every 30 seconds with 1 set of params (from statemachine 1), and the same lambda function is called with a different set of params (via statemachine 2) every 30 seconds.

Looking at the lambda function logs it looks like the state machines will not run the lambda function until the other state machine has completed its entire execution (ie calling the lambda function twice). I would expect that the two state machines would run independently of each other.

Is there some limitation because they are all calling the same lambda function? Or is there some setup issue or is this just how it works?

Thanks!

2 Answers
0

State machine executions are independent of each other. The most probable reason for what you are describing is that the state machines do not start at the same time. Look at the state machine logs to see when they start and when they invoke the functions.

EXPERT
answered 4 months ago
  • I don't expect the state machines to start at the same time but I expect that they should not be "blocking each other". Its clear from the logs that the execution of State machine 1 is only starting once the entire execution of State Machine 2 completes (ie 2 lambda calls) . So the timing is all offset and extended, ie instead of each state machine running every minute they are being delayed because of the other state machine running. I am sure there is some setup issue? Does it matter if the state machines or rules share the same resources? I dont think I created new resources for everything

0

It turns out that I need to modify the Step functions to have InvocationType: event. I understood that that allows asynchronous execution of lambda functions WITHIN a single state machine but one machine would have no impact on the operations of another state machine.

Seems that's not the case and they do impact each other. Changing the invocationtype solves the problem. Although it is not ideal as I would like the function calling to be sequential within the state machine.

answered 4 months ago
  • Do you have reserved concurrency on the Lambda function?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions