Answer the question
In order to leave comments, you need to log in
NodeJS + socket.io + mongoDB. Where is the memory leak?
There is a simple echo socket server implemented in nodejs and socket.io.
Each message received by the socket server is written to mongoDB.
When testing a server socket with the websocket-bench utility , 3000 simultaneous connections are created that send one message every second, the memory begins to grow linearly to infinity.
With 2000 connections and 2000 messages per second, there is no problem.
Starting the server socket with --nouse-idle-notification and --expose-gc + calling the GC manually does not give any results.
The socket server is running in one thread.
Is it a memory leak or is the socket server not handling the load this way? If there is a leak, please tell me where.
Link to github with server socket codehttps://github.com/MaxBoltik/echo-socket-server/bl...
Answer the question
In order to leave comments, you need to log in
call GC manually
Leak in the CLIENTS array, it is never cleared
cause socket.on('disconnect') in socket.io is done in one place, like socket.io itself to
be quite precise, this event will not happen until you try something write to socket
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question