Reputation: 75
The problem I have is the following.
I currently have a system running in .NET. This system makes a call to a service which takes approximately 1 minute.
We are currently migrating the solution to AWS. And the problem I find is that the Lambda works runs in 1 minute (since it makes the call to the other system that takes 1 minute) and everything works fine. But when I make the call from the Gateway API, y have a timout. Investigating I found that it has a maximum timeout of 29 seconds.
Then I need to know what solution I can have to this problem, considering that i need wait 1 minute for the lambda function.
One that occurred to me is to trigger the call from the API, and that the lambda function runs, and from the client create a pool to see the status of the transaction. But I don't know how to keep the initial call "in memory" and when I call again the api to see the status, I know I'm talking about the same request, to get the result data
Upvotes: 3
Views: 2118
Reputation: 78663
Here's an outline of one way to solve this:
/start
API request that triggers Lambda #1/status?id=UUID
API, on whatever schedule it likes, which triggers Lambda #3When the /status?id=UUID
API call indicates that the long-lived task is complete (or failed), the client can make a final API request to indicate that it has the result associated with the UUID and the DynamoDB item can be deleted, or you could just implement a TTL on the DynamoDB item.
This process looks complicated, but it's really not.
Rather than the client polling the back-end for status and results, it could alternately poll an SQS queue for the same, or subscribe to an SNS topic.
Upvotes: 3