Hi, I need to make a service, where the a web app ...
# help
a
Hi, I need to make a service, where the a web app invokes an API endpoint A, which hits servic that can take 10+ seconds. I want to respond with response of the service in a seperate API endpoint ("B") which might find the service request complete, or still in progress and wait for the payload. What's the best service/architecture for something like that
j
As always, it depends. You might want to start with this article about poll-to-push (https://aws.amazon.com/blogs/compute/from-poll-to-push-transform-apis-using-amazon-api-gateway-rest-apis-and-websockets/) with cover : • HTTP : Poll / Sync • HTTP + Pub/Sub : Push / Async • HTTP + websockets : Push / Async I can think of other AWS Services for these solutions but it's a good start.
f
Thanks @JP (junaway)!
t
@Abdul Taleb least complex + safest way is to have endpoint A return an ID immediately which can then be polled at endpoint B
f
@Abdul Taleb there are a number of ways you can do it. The simplest way would be something like: 1. Api A create a row in DB with status
started
, and kicks off another Lambda to do the processing, and return the id to the frontend; 2. When the Lambda finishes processing, it updates the row with status `completed`; 3. In the meanwhile, Api B keeps polling the status of the DB row
okay @thdxr just said what I was about to say in 1 sentence
j
@thdxr that's what I usually do to get started. That's the baseline solution, using either 200 or 202 as status code.
a
Thanks all for your help! I think I'll start with the simpler approach and improve later