Friday, November 30, 2018

Re: What is meant by blocking request in django?

This is how I think about blocking in the context of Django. Anything that takes time and is not directly related to returning an http response should be done in the background (via celery or whatever). Your email example is a good one. The email doesn't need to be sent before the http response is returned so you should send email via celery. In general anything that "blocks" the http response unnecessarily should be done in the background.

On November 29, 2018 9:58:30 PM CST, Kharis <kharis@wisana.com> wrote:
Once I worked on a feature that use API like sending emails from my app, I write the code inside the django app.
My superior told me that causes request to block, so another request will be blocked until the process of calling the API finished and response sent to user.
He suggest that this process better off offloaded to celery.

I thought this can be solved by using multiple worker as in gunicorn, so another client can be served by another worker if there's available.
but, both he and I don't have a clue if above (solved by creating multiple worker) is true.

so, does it mean by blocking, it only blocks a single process/worker? or do all worker have to wait?
and what is another possible blocking request scenario? generating pdf? long calculation?

in addition, where can I read about blocking request in django? I searched but, really hard to find one 

This message and any attachments may contain confidential information and are intended only for the use of the intended recipient(s). Any disclosure, distribution or copying of this message and any attachments is strictly prohibited without approval from PT. Wisanamitra Argakarya. If you are not the intended recipient, you should notify the sender and delete this message immediately. PT. Wisanamitra Argakarya is not liable for any damage caused by any virus or malicious file transmitted by this message. Any views, opinions, or commitments expressed in this message do not necessarily reflect the views of PT. Wisanamitra Argakarya.

No comments:

Post a Comment