You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to upload large-sized files into my Django application.
The files are typically around 500 MB - 2 GB.
While a client is uploading a file other clients are blocked (request hangs until timeout or it is processed)
I'm using Uvicorn with --worker-class uvicorn.workers.UvicornWorker.
First szenario: 1 Worker
While starting gunicorn with one worker only (--workers 1) the following issue appears:
Client A is starting the upload.
The file itself does not hit the upload handler directly (which is another issue in uvicorn), however as soon as the upload handler is called, other requests, e.g. from a Client B, hang.
This seems to be OK as I only have 1 worker to deal with incoming requests.
Second szenario: 2 Workers (or more)
If started with two or more workers (--workers 2), the same happens, but requests that are incoming as long as the file is being processed, are scheduled on the workers either by round-robin or sequentially.
Requests which hit the first worker (which process the file) hang until the prior request has been finished.
Some other requests which hits the second worker are processed directly.
This results in other clients getting time-out errors depending which worker is serving their request.
My question:
Is there a way to optimize this behavior? (or: Is this correct or do I have a false understanding of this issue?)
The first worker should "know" that it is already blocked by one request and cannot serve another one in parallel.
All other requests should be put onto the second worker's queue.
Only in the case, that Client A and Client B uploads files in parallel (or do other long-running requests), a request of a third client should be put into the queue and should be processed from the first worker which finished their task.
Is there another possibility to allow large-file uploads? Running with X workers always only allows X uploads to be processed simultaneously. Using WEB_CONCURRENCY or 2 * CPU_COUNT results only in a bunch of parallel uploads which does not seem to be desirable...
Thanks for your time and help!
The text was updated successfully, but these errors were encountered:
late answer but If you are using uvicorn ennsure the work is splitted in a queue that won't lock the event loop behind it. Not sure what 's the best way to do it though :)
Hi,
I'm trying to upload large-sized files into my Django application.
The files are typically around 500 MB - 2 GB.
While a client is uploading a file other clients are blocked (request hangs until timeout or it is processed)
I'm using Uvicorn with
--worker-class uvicorn.workers.UvicornWorker
.First szenario: 1 Worker
While starting gunicorn with one worker only (
--workers 1
) the following issue appears:Client A is starting the upload.
The file itself does not hit the upload handler directly (which is another issue in uvicorn), however as soon as the upload handler is called, other requests, e.g. from a Client B, hang.
This seems to be OK as I only have 1 worker to deal with incoming requests.
Second szenario: 2 Workers (or more)
If started with two or more workers (
--workers 2
), the same happens, but requests that are incoming as long as the file is being processed, are scheduled on the workers either by round-robin or sequentially.Requests which hit the first worker (which process the file) hang until the prior request has been finished.
Some other requests which hits the second worker are processed directly.
This results in other clients getting time-out errors depending which worker is serving their request.
My question:
Is there a way to optimize this behavior? (or: Is this correct or do I have a false understanding of this issue?)
The first worker should "know" that it is already blocked by one request and cannot serve another one in parallel.
All other requests should be put onto the second worker's queue.
Only in the case, that Client A and Client B uploads files in parallel (or do other long-running requests), a request of a third client should be put into the queue and should be processed from the first worker which finished their task.
Is there another possibility to allow large-file uploads? Running with X workers always only allows X uploads to be processed simultaneously. Using
WEB_CONCURRENCY
or2 * CPU_COUNT
results only in a bunch of parallel uploads which does not seem to be desirable...Thanks for your time and help!
The text was updated successfully, but these errors were encountered: