3

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

1 Answer 1

3

Here's an outline of one way to solve this:

  • the client makes a /start API request that triggers Lambda #1
  • Lambda #1 is short-lived and does the following:
    • generates a UUID as a correlator for the task about to be undertaken
    • creates a new item in DynamoDB, with the UUID as the key
    • triggers the long-lasting (1 minute) Lambda #2 to start, passing it the UUID
    • returns the UUID to the client
  • Lambda #2 is long-lived and does the following:
    • whatever work it needs to
    • periodically update its status and results to the UUID item in DynamoDB
  • the client can poll a /status?id=UUID API, on whatever schedule it likes, which triggers Lambda #3
  • Lambda #3 is short-lived and does the following:
    • query the UUID item from DynamoDB
    • return the current status and any results to the client

When 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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.