EyalAr / lwip

Light Weight Image Processor for NodeJS
MIT License
2.36k stars 231 forks source link

lwip as a child process #247

Closed ChristianRich closed 8 years ago

ChristianRich commented 8 years ago

Generally speaking image processing is CPU intensive, so I was wondering if anyone has tried lwip running as a child process? This should be pretty straight forward I reckon?

While users are uploading images to my site and lwip is doing work, I don't want the main thread to lag causing my web server to slow down.

Is this a valid concern at all?

thedewpoint commented 8 years ago

This is how I handled it as well. I have a slave process that handles resizing and uploading images

ChristianRich commented 8 years ago

@thedewpoint Have you got any code you'd like to share?

thedewpoint commented 8 years ago

@ChristianRich sure I created a gist. its not pretty but it gets the job done

https://gist.github.com/thedewpoint/ff143e0fc780b251b0281a866b008bdc

ChristianRich commented 8 years ago

Awesome. Thanks @thedewpoint

EyalAr commented 8 years ago

lwip does image operations on worker threads, so in that sense it's non blocking. If you want a separate process, you'd have to fork a child.