ASP.NET Core SignalR websocket connection limit
Asked Answered
P

1

6

I produce load testing of SignalR (ASP.NET Core) application hosted at Windows Server 2016 standard using Microsoft.AspNetCore.SignalR.Client. Dotnet core hosting 2.1.1 installed

And i can not create more than 3000 (2950-3050) connections.

Already tried recomendations as described here:

Added limits to UseKestrel (this seems to work if i set values to 100 or 1000):

var host = new WebHostBuilder()
    .UseKestrel(options =>
    {
        options.Limits.MaxConcurrentConnections = 50000;
        options.Limits.MaxConcurrentUpgradedConnections = 50000;
    })

Changed all aspnet.config files by adding this:

<system.web>
    <applicationPool maxConcurrentRequestsPerCPU="50000" />
</system.web>

Executed this command:

cd %windir%\System32\inetsrv\ appcmd.exe set config /section:system.webserver/serverRuntime /appConcurrentRequestLimit:50000

Added performance counter for Web Service\Current Connections - Maximum Connections. And Maximum Connections increases to 3300 and stops.

There are no exceptions in server logs. But I feel that there are some restrictions in system.

Server IIS logs contains only this:

GET /messageshub id=A_3x1sH9kHM1Rc3oPSgP6w 80 - 172.20.192.11 - - 404 0 0 3

Client exceptions is basically the following:

System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

Poon answered 9/7, 2018 at 9:54 Comment(1)
There's no inherent limit. You might be hitting limits on the client. maxConcurrentRequestsPerCPU doesn't affect ASP.NET Core applicationsNickens
P
5

On Windows you may have dynamic port assignment issue . Windows by default has 5000 port numbers ready to be assigned to TCP connections and 1024 of them are reserved for the OS itself which you will end up with 3977 ports free to be assigned . In your case the number is 3300 as you mentioned but it's possible that 3300 of the connections are established and 677 of them are Time_Waited. In any case i recommend to use

netstat -an | find 'Established" -c 
netstat -an | find 'TIME" -c 
netstat -an | find 'CLOSED" -c 

In order to figure out the number of established & time_wait & close_wait connections at the time you received the IO exception and if the number is close to 5000 just add this to your registry and reboot and test again

  [HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters]
MaxUserPort = 5000 (Default = 5000, Max = 65534)
Porch answered 20/1, 2019 at 9:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.