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?

  • How solid is your code? Maybe there are some cases where the last callback is never called? – Bazze Jan 17 '15 at 8: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

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.