Reputation: 849
I'm running a query that takes maximum 3 minutes to complete with django, using connections['report'].cursor()
When I make a request to the view that execute that query, Nginx give me a timeout (that is presented in the view as "502 Bad Gateway").
What approach should I choose to overcome this issue? Should I increase the timeout setting or how can I make this asynchronous?
Upvotes: 0
Views: 538
Reputation: 13733
First approach (easiest): You can increase the timeout setting. This way your users will have to wait a long time. Not a good user experience.
Second approach (moderate difficulty): If your users don't have to wait for that request (such as email sending), you could delegate that task to a background worker. In Django community, that's usually done by celery
Third approach (the most difficult - best experience): Use django-channels and web sockets. This will take a lot of time if you are new to these technologies.
Choose depending on your case. Hope it helps!
Upvotes: 3