Uploading large files blocks other requests. #1952
Replies: 2 comments 2 replies
-
It is not clear to me what is actually blocking the Hypnotoad process here, making it impossible to answer the question. Uploads are already non-blocking and will not interfere with parallel requests. If you're post-processing the uploaded JSON file, then that would be a task for a job queue like Minion. |
Beta Was this translation helpful? Give feedback.
-
The endpoint is blocking. There is reading content of file, json decoding of this content to check if valid json and then saving file on server. Job queue sounds good for this case but besides this upload the app is a standard REST API and does not use background jobs. Just wondering what are other options. For large files these operations takes long time blocking other requests.
|
Beta Was this translation helpful? Give feedback.
-
Hi, I maintain a Mojolicious app with mainly short & non-blocking operations. But there is one long blocking action used to upload large json files (like 200MB and bigger). When hypnotoad worker handles this action then next requests delegated to this worker have to wait. It makes that request that should take miliseconds can wait even 30 seconds to be done. The solution for blocking operations is using subprocesses but I am not sure is it good for such requests with 200MB files. As I understand there could be bigger RAM usage and longer response time as the whole request need to be copied to another process - can anyone explain if should I care about it?
Any other option?
I was wondering if there can be a separate pool of workers that can handle 1 connection and use them for this single endpoint.
I also tried to call stop_gracefully on before_dispatch for this endpoint to prevent this worker from handling next requests but it does not work as I expected. It seems that stop_gracefully starts to work when upload endpoint is completed. So all incoming requests may be still delegated to this worker before completing upload. However I am still using that because it perfectly frees up memory after upload.
Any advice is welcome.
Beta Was this translation helpful? Give feedback.
All reactions