简体   繁体   中英

Heap stable while rss increases node.js

I have an app written in node.js and it works as it should. The only problem is that the memory keeps increasing 'till it hits 1.3Gb and immediately drops to ~400Mb. At first I though it's a memory leak, but further investigation shows there's no leaks.

内存使用情况

The analyze of heap-dump doesn't give any useful information, just proves that there's no leak. I'm using node.js v4.2.1 and the application is heavily using websockets (socket.io) with transports set to ['websockets'] only. For load balancing I'm using PM2 in cluster mode (4 instances) .

What could be the reason? What are the consequences? Do you think it might crash the server in the long run?

If you plan to distribute the load of connections among different processes or machines with pm2 , you have to make sure that requests associated with a particular session id connect to the process that originated them. If it connect wrong process , it will make a mass of request ajax to server . You can use inspector in browser to check it, refresh web an check socket run correctly. It will make memory increase faster and when it to limit , It will call gc().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM