Tracking Async Lambda execution on AWS
I am trying to build a process that invokes AWS lambda, which then utilizes AWS SNS to send messages that trigger more lambdas. Each such triggered lambdas write an output file to S3. The process is as depicted below -

My question is this - How can I know that all lambdas are done with writing files? I want to execute another process that collects all these files and does merging. I could think of two obvious ways -
- Constantly monitor s3 for as many output files as SNS messages. Once, total count reaches, invoke the final merging lambda.
- Use a db as sync source, write counts for that particular job/session and keep monitoring it till the count reaches SNS messages count.
Both solutions require constant polling, which i would like to avoid. I want to do this in an event driven manner. I was hoping for Amazon SQS would come to my rescue with some sort of "empty queue lambda trigger", but SQS only supports lambdas triggering on new messages. Is there any known way to achieve this in an event driven manner in AWS? Your suggestions/comments/answers are much appreciated.
java amazon-web-services architecture aws-lambda amazon-sqs
|
show 5 more comments
I am trying to build a process that invokes AWS lambda, which then utilizes AWS SNS to send messages that trigger more lambdas. Each such triggered lambdas write an output file to S3. The process is as depicted below -

My question is this - How can I know that all lambdas are done with writing files? I want to execute another process that collects all these files and does merging. I could think of two obvious ways -
- Constantly monitor s3 for as many output files as SNS messages. Once, total count reaches, invoke the final merging lambda.
- Use a db as sync source, write counts for that particular job/session and keep monitoring it till the count reaches SNS messages count.
Both solutions require constant polling, which i would like to avoid. I want to do this in an event driven manner. I was hoping for Amazon SQS would come to my rescue with some sort of "empty queue lambda trigger", but SQS only supports lambdas triggering on new messages. Is there any known way to achieve this in an event driven manner in AWS? Your suggestions/comments/answers are much appreciated.
java amazon-web-services architecture aws-lambda amazon-sqs
1
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
any other alternatives?
– Jay
Oct 31 '18 at 19:17
1
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49
|
show 5 more comments
I am trying to build a process that invokes AWS lambda, which then utilizes AWS SNS to send messages that trigger more lambdas. Each such triggered lambdas write an output file to S3. The process is as depicted below -

My question is this - How can I know that all lambdas are done with writing files? I want to execute another process that collects all these files and does merging. I could think of two obvious ways -
- Constantly monitor s3 for as many output files as SNS messages. Once, total count reaches, invoke the final merging lambda.
- Use a db as sync source, write counts for that particular job/session and keep monitoring it till the count reaches SNS messages count.
Both solutions require constant polling, which i would like to avoid. I want to do this in an event driven manner. I was hoping for Amazon SQS would come to my rescue with some sort of "empty queue lambda trigger", but SQS only supports lambdas triggering on new messages. Is there any known way to achieve this in an event driven manner in AWS? Your suggestions/comments/answers are much appreciated.
java amazon-web-services architecture aws-lambda amazon-sqs
I am trying to build a process that invokes AWS lambda, which then utilizes AWS SNS to send messages that trigger more lambdas. Each such triggered lambdas write an output file to S3. The process is as depicted below -

My question is this - How can I know that all lambdas are done with writing files? I want to execute another process that collects all these files and does merging. I could think of two obvious ways -
- Constantly monitor s3 for as many output files as SNS messages. Once, total count reaches, invoke the final merging lambda.
- Use a db as sync source, write counts for that particular job/session and keep monitoring it till the count reaches SNS messages count.
Both solutions require constant polling, which i would like to avoid. I want to do this in an event driven manner. I was hoping for Amazon SQS would come to my rescue with some sort of "empty queue lambda trigger", but SQS only supports lambdas triggering on new messages. Is there any known way to achieve this in an event driven manner in AWS? Your suggestions/comments/answers are much appreciated.
java amazon-web-services architecture aws-lambda amazon-sqs
java amazon-web-services architecture aws-lambda amazon-sqs
asked Oct 31 '18 at 16:39
JayJay
67794184
67794184
1
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
any other alternatives?
– Jay
Oct 31 '18 at 19:17
1
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49
|
show 5 more comments
1
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
any other alternatives?
– Jay
Oct 31 '18 at 19:17
1
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49
1
1
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
any other alternatives?
– Jay
Oct 31 '18 at 19:17
any other alternatives?
– Jay
Oct 31 '18 at 19:17
1
1
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49
|
show 5 more comments
4 Answers
4
active
oldest
votes
AWS Step Functions (a managed state machine service) would be the obvious choice. AWS has some examples as starting points. I remember one being a looping state that you could probably apply to this use case.
Another idea off top of my head...
Create an "Orchestration Lambda" that has the list of your files...
Orchestration Lambda invokes a "File Writer Lambda" in a loop, passing the file info. The invokeAsync(InvokeRequest request) returns a Future object. Orchestration Lambda can check the future object state for completion.
Orchestration Lambda can make a similar call to the "File Writer Lambda" but instead use the more flexible method: invokeAsync(InvokeRequest request, AsyncHandler asyncHandler). You can make an inner class that implements this AsyncHandler and monitor the completion there in the Orchestration Lambda. It is a little cleaner than all the loops.
There are probably many ways to solve this problem, but there are two ideas.
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
add a comment |
Personally, I prefer the idea with "Step Functions".
But if you want to simplify your architecture, you could create trigered lambda function. Chose 'S3 trigger' in left side of lambda function designer and configure it bottom.
Check out more - Using AWS Lambda with Amazon S3
But in this case you have to create more sophisticated lambda function wich will check that all apropriate files are uploaded on S3 and after this start your merge.
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
add a comment |
I would propose a couple of options here:
Step Functions:
This is a managed service for state machines. It's great for co-ordinating workflows.
Atomic Counting:
If you know the number of things in advance, you could initialize an Atomic Counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. Note that whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record, so every mutation of the counter would trigger your Lambda.
Note that DynamoDB Streams guarantees the following:
Each stream record appears exactly once in the stream.
For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item.
add a comment |
The stated problem seems a suitable candidate for the Saga Pattern.
Basically Saga is described like any long running , distributed process.
As mentioned earlier , the AWS platform allows using Step functions to implement a Saga, as described here enter
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53088269%2ftracking-async-lambda-execution-on-aws%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
AWS Step Functions (a managed state machine service) would be the obvious choice. AWS has some examples as starting points. I remember one being a looping state that you could probably apply to this use case.
Another idea off top of my head...
Create an "Orchestration Lambda" that has the list of your files...
Orchestration Lambda invokes a "File Writer Lambda" in a loop, passing the file info. The invokeAsync(InvokeRequest request) returns a Future object. Orchestration Lambda can check the future object state for completion.
Orchestration Lambda can make a similar call to the "File Writer Lambda" but instead use the more flexible method: invokeAsync(InvokeRequest request, AsyncHandler asyncHandler). You can make an inner class that implements this AsyncHandler and monitor the completion there in the Orchestration Lambda. It is a little cleaner than all the loops.
There are probably many ways to solve this problem, but there are two ideas.
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
add a comment |
AWS Step Functions (a managed state machine service) would be the obvious choice. AWS has some examples as starting points. I remember one being a looping state that you could probably apply to this use case.
Another idea off top of my head...
Create an "Orchestration Lambda" that has the list of your files...
Orchestration Lambda invokes a "File Writer Lambda" in a loop, passing the file info. The invokeAsync(InvokeRequest request) returns a Future object. Orchestration Lambda can check the future object state for completion.
Orchestration Lambda can make a similar call to the "File Writer Lambda" but instead use the more flexible method: invokeAsync(InvokeRequest request, AsyncHandler asyncHandler). You can make an inner class that implements this AsyncHandler and monitor the completion there in the Orchestration Lambda. It is a little cleaner than all the loops.
There are probably many ways to solve this problem, but there are two ideas.
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
add a comment |
AWS Step Functions (a managed state machine service) would be the obvious choice. AWS has some examples as starting points. I remember one being a looping state that you could probably apply to this use case.
Another idea off top of my head...
Create an "Orchestration Lambda" that has the list of your files...
Orchestration Lambda invokes a "File Writer Lambda" in a loop, passing the file info. The invokeAsync(InvokeRequest request) returns a Future object. Orchestration Lambda can check the future object state for completion.
Orchestration Lambda can make a similar call to the "File Writer Lambda" but instead use the more flexible method: invokeAsync(InvokeRequest request, AsyncHandler asyncHandler). You can make an inner class that implements this AsyncHandler and monitor the completion there in the Orchestration Lambda. It is a little cleaner than all the loops.
There are probably many ways to solve this problem, but there are two ideas.
AWS Step Functions (a managed state machine service) would be the obvious choice. AWS has some examples as starting points. I remember one being a looping state that you could probably apply to this use case.
Another idea off top of my head...
Create an "Orchestration Lambda" that has the list of your files...
Orchestration Lambda invokes a "File Writer Lambda" in a loop, passing the file info. The invokeAsync(InvokeRequest request) returns a Future object. Orchestration Lambda can check the future object state for completion.
Orchestration Lambda can make a similar call to the "File Writer Lambda" but instead use the more flexible method: invokeAsync(InvokeRequest request, AsyncHandler asyncHandler). You can make an inner class that implements this AsyncHandler and monitor the completion there in the Orchestration Lambda. It is a little cleaner than all the loops.
There are probably many ways to solve this problem, but there are two ideas.
edited Oct 31 '18 at 22:52
jarmod
18.7k63949
18.7k63949
answered Oct 31 '18 at 19:46
MattMatt
1859
1859
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
add a comment |
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
the problem with Orchestration Lambda is two fold - a) starting lambdas from with in a lambda is not a process that Amazon typically recommends. I tried this in the past and encountered some throttling. Using s3,sqs,sns as services that trigger lambda is the usual recommended way. 2) secondly, the Orchestration Lambda is likely to time out in my case (5minutes).
– Jay
Oct 31 '18 at 20:53
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
Well, that is a generalized statement. There are many scenarios in which lambda-to-lambda communication may be appropriate. Your use case will determine that based on any number of technical requirements, timeout as you mentioned is one. We have a lambda dispatching pattern with tens of thousands of invocations per minute and no issues. If you have a long running process, sounds like step functions are a good place for you to look.
– Matt
Nov 1 '18 at 13:02
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
you don't see any throttling at all with so many thousands of invocations per minute? Could you please tell me what your use case is briefly?
– Jay
Nov 1 '18 at 18:31
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
In a nutshell, it is the main engine for a web application. The API Gateway has a few greedy endpoints that send requests to the Lambda. Lambda dispatches to classes within the code-base to perform business logic or external calls to AWS services or both. Speed is very important, every request is kept to under 4500 ms, most average much lower. With the default 3,000 concurrency limit we had no problems under load.
– Matt
Nov 2 '18 at 19:25
add a comment |
Personally, I prefer the idea with "Step Functions".
But if you want to simplify your architecture, you could create trigered lambda function. Chose 'S3 trigger' in left side of lambda function designer and configure it bottom.
Check out more - Using AWS Lambda with Amazon S3
But in this case you have to create more sophisticated lambda function wich will check that all apropriate files are uploaded on S3 and after this start your merge.
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
add a comment |
Personally, I prefer the idea with "Step Functions".
But if you want to simplify your architecture, you could create trigered lambda function. Chose 'S3 trigger' in left side of lambda function designer and configure it bottom.
Check out more - Using AWS Lambda with Amazon S3
But in this case you have to create more sophisticated lambda function wich will check that all apropriate files are uploaded on S3 and after this start your merge.
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
add a comment |
Personally, I prefer the idea with "Step Functions".
But if you want to simplify your architecture, you could create trigered lambda function. Chose 'S3 trigger' in left side of lambda function designer and configure it bottom.
Check out more - Using AWS Lambda with Amazon S3
But in this case you have to create more sophisticated lambda function wich will check that all apropriate files are uploaded on S3 and after this start your merge.
Personally, I prefer the idea with "Step Functions".
But if you want to simplify your architecture, you could create trigered lambda function. Chose 'S3 trigger' in left side of lambda function designer and configure it bottom.
Check out more - Using AWS Lambda with Amazon S3
But in this case you have to create more sophisticated lambda function wich will check that all apropriate files are uploaded on S3 and after this start your merge.
edited Nov 13 '18 at 17:40
squeekyDave
393114
393114
answered Nov 13 '18 at 9:29
RredCatRredCat
3,58224273
3,58224273
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
add a comment |
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
Thanks for your answer. Even with step functions, I would have to have one step that triggers n lambdas and waits for them to finish. This waiting lambda is what I am trying to avoid. Using dynamodb as a countdown mechanism works well in my scenario.
– Jay
Nov 13 '18 at 19:37
add a comment |
I would propose a couple of options here:
Step Functions:
This is a managed service for state machines. It's great for co-ordinating workflows.
Atomic Counting:
If you know the number of things in advance, you could initialize an Atomic Counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. Note that whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record, so every mutation of the counter would trigger your Lambda.
Note that DynamoDB Streams guarantees the following:
Each stream record appears exactly once in the stream.
For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item.
add a comment |
I would propose a couple of options here:
Step Functions:
This is a managed service for state machines. It's great for co-ordinating workflows.
Atomic Counting:
If you know the number of things in advance, you could initialize an Atomic Counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. Note that whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record, so every mutation of the counter would trigger your Lambda.
Note that DynamoDB Streams guarantees the following:
Each stream record appears exactly once in the stream.
For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item.
add a comment |
I would propose a couple of options here:
Step Functions:
This is a managed service for state machines. It's great for co-ordinating workflows.
Atomic Counting:
If you know the number of things in advance, you could initialize an Atomic Counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. Note that whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record, so every mutation of the counter would trigger your Lambda.
Note that DynamoDB Streams guarantees the following:
Each stream record appears exactly once in the stream.
For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item.
I would propose a couple of options here:
Step Functions:
This is a managed service for state machines. It's great for co-ordinating workflows.
Atomic Counting:
If you know the number of things in advance, you could initialize an Atomic Counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. Note that whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record, so every mutation of the counter would trigger your Lambda.
Note that DynamoDB Streams guarantees the following:
Each stream record appears exactly once in the stream.
For each item that is modified in a DynamoDB table, the stream records appear in the same sequence as the actual modifications to the item.
answered Nov 13 '18 at 19:52
jarmodjarmod
18.7k63949
18.7k63949
add a comment |
add a comment |
The stated problem seems a suitable candidate for the Saga Pattern.
Basically Saga is described like any long running , distributed process.
As mentioned earlier , the AWS platform allows using Step functions to implement a Saga, as described here enter
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
add a comment |
The stated problem seems a suitable candidate for the Saga Pattern.
Basically Saga is described like any long running , distributed process.
As mentioned earlier , the AWS platform allows using Step functions to implement a Saga, as described here enter
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
add a comment |
The stated problem seems a suitable candidate for the Saga Pattern.
Basically Saga is described like any long running , distributed process.
As mentioned earlier , the AWS platform allows using Step functions to implement a Saga, as described here enter
The stated problem seems a suitable candidate for the Saga Pattern.
Basically Saga is described like any long running , distributed process.
As mentioned earlier , the AWS platform allows using Step functions to implement a Saga, as described here enter
answered Nov 14 '18 at 15:57
alex suchmanalex suchman
234
234
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
add a comment |
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
thank you. I am avoiding using step functions, for the reason that I don't prefer to launch sync/async lambdas from another lambda. In my case, atomic counting works just fine.
– Jay
Nov 14 '18 at 21:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53088269%2ftracking-async-lambda-execution-on-aws%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
AWS Step Functions.
– jarmod
Oct 31 '18 at 16:57
any other alternatives?
– Jay
Oct 31 '18 at 19:17
1
If you know the number of things in advance, you could initialize a counter in DynamoDB and then atomically decrement it as work completes. Use DynamoDB Streams to trigger Lambda invocation when the counter is mutated, and trigger your next phase (or end of work) when the counter hits zero. I have not personally implemented this but it may be worth investigating.
– jarmod
Oct 31 '18 at 20:41
@jarmod the trigger on DynamoDB Streams seems to be available on creation of new records. There seems to be no way to trigger on the event when the counter hits zero. I think the best solution would have been SQS queue purge event, but unfortunately, SQS doesn't give any such event triggers!.
– Jay
Oct 31 '18 at 20:51
Whenever an application creates, updates, or deletes items in the table, DynamoDB Streams writes a stream record.
– jarmod
Oct 31 '18 at 22:49