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!

Gottsy
질문됨 2년 전796회 조회
2개 답변
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.

profile pictureAWS
전문가
Uri
답변함 2년 전
  • 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.

Gottsy
답변함 2년 전
  • Do you have reserved concurrency on the Lambda function?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠