Sunday, June 27, 2021

Re: how does Django handle outbound requests?

It is quite often recommended to keep it simple and then optimize if you need to. The optimization woiuld be to decouple the external request using a queue, then provide a response to the client separately. Just as you suggest.

You can also design your API to allow this optimization, without actually implementing the queue feature yet. But adding a work queue using celery is pretty darn easy (at least after you have done the first one) so that is probably the easiest part of your future work.

If you already think you know your likely range of loading, then you can also use a test rig to load your system and see if it can keep up without bogging down Django or your other components. Then optimize if needed before you go into production...

hth

- Tom


On Jun 25, 2021, at 2:41 PM, Glenn Rutkowski <glenn@caffeinelab.com> wrote:

Can anyone point me in the right direction?  We are using Django as an API Endpoint that accepts a request and then repackages it and sends it to an external service and waits for a response.  I'm interested in the external call and how it is handled.  If it times out or takes forever, what it the effect on the Django server?  Am I blocking any other execution from happening while waiting for the response?  

From what I have read it seems as if the best idea is to pass the job off to a queue and then check for job status alerts or updates.  If I have to rethink this - I'd rather do it now. 

Thanks for reading, looking forward to responses!

-g




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20152777-2847-4b94-974c-27be70ee04can%40googlegroups.com.

No comments:

Post a Comment