nodejs express windows max connections setting

2019-08-01 05:49发布

问题:

Where to set max connections for nodejs(for using express' get) in windows 10? Is it related to max files(descriptors) setting in linux? Is there a windows version of that setting? Preferably a setting in nodejs so it will be compatible when migrated to unix?

I suspect loadtest module gives error because of this setting when over 2000 concurrent connections to attack my server program that uses express and keeps connections in a queue to be processed later. Loadtest finishes normally for 200 concurrent connections(-c 200 in command line). Also when I don't keep connections in a queue and if operation in get is simple("response.end('hello world')"), it doesn't give error for -c 2000 maybe it finishes a work before other starts so its not 2000 concurrent really, only queued version has 2000 concurrency?

I'm not using http module but I am handling xlmhttprequest sent from clients on serverside express module's get function.

Maybe desktop version windows os wasn't developed with server apps in mind so it doesn't have a setting for max connections, max file accesses and related variables has been hardcoded in it?

回答1:

To answer one part of your question, for max open file there is _setmaxstdio, see:

  • https://msdn.microsoft.com/en-us/library/6e3b887c(vs.71).aspx

Maybe you can write a wrapper that changes this and starts your Node program.

As for the general question of max open connections, this is what I found about some older Windows:

  • http://smallvoid.com/article/winnt-tcpip-max-limit.html

It talks about changing the config of:

[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters]

TcpNumConnections = 0x00fffffe (Default = 16,777,214)

[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters]

MaxUserPort = 5000 (Default = 5000, Max = 65534)

See also other related parameters in the above link. I don't know if the names of the config values changed in more recent versions of Windows but HKEY_LOCAL_MACHINE System CurrentControlSet Services Tcpip Parameters is something that I would search for if increasing the open files limit is not enough.

For a comparison, here is how I increase the number of concurrent Node/Express connection in Linux.