I am using nodejs for a web server which decodes the GET params and returns data in some encoded format. The decode/encode are done using the crypto module of nodejs, which seems to be synchronous. While the time taken to serve a single request is fast enough, blocking the event loop has made the service perform poorly with concurrency.
My requirement is simple, make the encode/decode functionality outside of the event loop.
- Separate Process (child_process or cluster)
This can either be a separate process solely for this purpose, but since the encode/decode will be blocking in the child process this will stop the child process to receive new messages i.e. there will never be a situation when two strings are encoded as child process will also be single threaded.
- Separate Thread for each request (threads-a-gogo or fiber or node-webworker)
Create a separate thread for each request to carry out the encode/decode operation, but none of the modules seems to work as expected, i.e threads-a-gogo doesn't install through npm, fiber didn't create a separate thread on run(), node-webworker not working.
Has someone faced a similar problem or is there some way to easily create threads in nodejs with simple message passing.