'handle a request in django that takes a long time to process is a lambda function and api gateway better? OR async django function

I have a function in my django rest framework api that I am working out. I suspect that it will take a long time to finish. About a minute. Given api requests expect a response I suspect this is a problem.

My initial thought was set up a aws lambda function that is tied to a aws api gateway, secured by a api key.

The idea being that the front end calls the api gateway url, and the url and the api key are sent over by my server only when the user who requests the url and apikey has access. But is this secure enough?

Or is it better to have a django function that runs async? Meaning run the work that needs to be done async and immediately return the 200 response? Then just have another endpoint that polls the server to see if the work has been done? Can the async behavior even be done in the way I describe?

https://docs.djangoproject.com/en/4.0/topics/async/

after reading the docs it doesn't seem to do what i expect it to. I guess we can't return 200 while the function works. So AWS amazon gateway seems to be the win. But I worry that my api scheme and way I'm sending it over isn't secure enough.

Any advice?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source