I'm developing a node.js app which is fully non-blocking.
There are however a few CPU intensive functions:
- CryptoJS.AES decrypt/encrypt
- uuid creation
- create content from data
Now I found a module to use threads to offload the event loop from the CPU intensive tasks: node-webworker-threads
Should I now create:
- At app boot: one thread per function, so AES.decrypt is a thread, as is AES.encrypt, etc.
- At app boot: a thread pool per function? (how many threads? 1 per CPU core?)
- At execution: a new thread on entering of each function, and destroy it after completion?
Threads are something I don't yet fully understand..