M
M
Maxim Boltik2016-03-30 15:05:04
MongoDB
Maxim Boltik, 2016-03-30 15:05:04

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

2 answer(s)
S
Sergey, 2016-03-30
Protko @Fesor

call GC manually

And how it could help is interesting.
if there is a message buffer inside for sending, then it may well simply not have time to send messages.

D
Dmitry Belyaev, 2016-03-30
@bingo347

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 question

Ask a Question

731 491 924 answers to any question