I would like to point out that async.parallel performs several functions at the same time not (completely) in parallel . This is more like virtual parallelism.
Execution at the same time is the launch of various programs on the same processor core using multitasking / scheduling. True parallel execution will run a different program on each core of the multi-core processor. This is important because node.js has a single-threaded architecture.
The best thing about node is that you don't have to worry about I / O. It efficiently handles I / O operations.
In your case, you are storing data in MongoDB, mostly I / O. Therefore, their simultaneous use will use your network bandwidth, as well as when reading / writing from disk, as well as in disk bandwidth. Your server will not hang due to processor overload.
The consequence of this is that if you overload your server, your requests may fail. You may receive an EMFILE error (too many open files). Each socket is considered a file. Typically, the connections are combined, which means to establish a connection that will be selected by the socket from the pool, and upon completion of the return to the pool. You can increase the file descriptor with ulimit -n xxxx .
You can also get socket errors when overloaded, for example, ECONNRESET (Error: opening socket), ECONNREFUSED or ETIMEDOUT . Therefore, treat them correctly. Also check the maximum number of concurrent connections for the mongoDB server.
Finally, the server may freeze due to garbage collection. Garbage collection starts after your memory grows to a certain point, and then periodically starts after a while. The maximum memory of the V8 heap can be around 1.5 GB, so expect the GC to work often if its memory is high. node will crash with process out of memory if requested more than this limit. Therefore, fix memory leaks in your program. You can see these tools .
source share