0

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?

HBruijn
  • 77,029
  • 24
  • 135
  • 201
FelikZ
  • 345
  • 1
  • 4
  • 12
  • How solid is your code? Maybe there are some cases where the last callback is never called? – Bazze Jan 17 '15 at 08:57
  • @Bazze the code looks solid. Also there is a 2 min default timeout for that case, so connection will be closed even if there missed callback. – FelikZ Jan 17 '15 at 10:08

1 Answers1

1

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.
FelikZ
  • 345
  • 1
  • 4
  • 12