Ssl – Nodejs: server doesn’t close TCP connections

connectionlimitsnode.jsssl

Facing a problem in the production server running debian (7.0) with nodejs (v0.10.x) cluster where it doesn't close some TCP connections to the clients.

This leads to connection drops when connection limit is reached.

Using ss -s tool I can monitor that some connections are closed after a while but some are not.

Here is the sysctrl config changes I use in order to increase maximum connections as temporary workaround:

net.ipv4.ip_local_port_range = 1024 65500
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.ipv4.tcp_rmem = 4096 16384 33554432
net.ipv4.tcp_wmem = 4096 16384 33554432
net.ipv4.tcp_mem = 786432 1048576 26777216
net.core.netdev_max_backlog = 2000

How to find the bottleneck and solve the problem?

Best Answer

The problem was that https server doesn't inherit sockets timeout logic from http server.

There is a patch merged since Apr 2013, but it still doesn't merged to stable 0.10 branch.

The solutions:

  • avoid https usage, use some proxy server (nginx);
  • custom timeout handle;
  • use node version higher than 0.10.
Related Topic