It is said that Node.js code is single thread that should not processing some cpu-intensive tasks such image resizing, those tasks should be delegate to other programs such as ImageMagick other third party service.reference :
I have used S3-uploader lib in my project and test it using two devices to upload and resize images simultaneously, I found the server indeed is not blocked by one request of them, although the cpu usage rate is almost 100% and the response takes about 3000ms to finish(it is just a AWS EC2 t2.micro instance).
The understanding and questions are in the following image:
Please help me to ensure my understanding about node.js single thread above, and questions:
- When thread 1 delegate the task to ImageMagick, whether this thread is free to be used by new coming request or not?
Edit
the image is not 100% correct. The delegate to and callback from ImageMagick should be through Event Loop as well and there is only one Event loop for a node application (My understanding, anyone can confirm?).
answer from node-s3-uploader author: https://github.com/Turistforeningen/node-s3-uploader/issues/64