nodejs express series of questions

1. After using express, the throughput of the system is greatly reduced. This problem is mainly solved from express. The obvious problem is that  process. env . NODE_ENV = "production" needs to be set ; at this time, express will start a lot of performance optimizations Significantly improved performance

2. When the node application is released, if the cluster is not applicable, the performance will be poor. Because the node is a single-process application, we often see that the single cpu load on the server is very high, and the cpu cannot be used reasonably. At this time, we need to enable multi-process way to use node's cluster module to make full use of cpu performance

3. For the application of pm2, there are two ways to start the cluster. One is to use culster. We recommend using forever or pm2 to manage the cluster as much as possible. In this case, the node will not be down during production.

4. If you run pm2 in docker, you need to set pm2 as the foreground process, it is better to stop automatically after the docker monitoring process ends.

5. We conducted a stress test when deploying the node project. At that time, when a machine was tested by ip address alone, the concurrency was around 1500, and the performance was ok, but as long as it was tested in a cluster environment, the performance would plummet. It dropped to about 100. After checking the reason, it was caused by niginx. When we deployed the production environment, we added niginx as a reverse proxy, and niginx as a proxy server. There needs to be settings such as the maximum number of connections, workers, and link markets.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326270337&siteId=291194637