1

I use ServiceStack.Core to test concurrency in Windows and Ubuntu, all with a maximum of 6 concurrency, how to set up to improve concurrency?

public class AppHost : AppHostBase
{
    ...
}

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseStartup<Startup>()
        .UseUrls("http://localhost:1337/")
        .Build();

    host.Run();
}

[Route("/test")]
public class Test { }

public object Get(Test request)
{
    System.Threading.Thread.Sleep(3000);
    return '';
}

Only 6 concurrent

CPU

wilmer
  • 13
  • 2

1 Answers1

1

Note: it's not a good idea to test concurrency in a browser which have their own Max concurrency limits. Use something like wrk or ab Apache Bench.

ServiceStack doesn't have a separate concurrency model in .NET Core nor does it spawn new threads per request, it just uses .NET Core's Kestrel's configured concurrency.

Previously in ASP.NET Core 1.1 you can specify the ThreadCount when you configure Kestrel:

var host = new WebHostBuilder()
    .UseKestrel(options => options.ThreadCount = 10)

Where it specifies the number of libuv I/O threads used to process requests which defaults to half of ProcessorCount

Although ThreadCount has since been moved and only available if you configure Kestrel to you use the Libuv Transport:

WebHost.CreateDefaultBuilder(args)
    .UseLibuv(options => {
        options.ThreadCount = 10;
    })

Note from .NET Core 2.1 Kestrel uses Managed Sockets for the default transport not Kestrel.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • It is wrong for me to use browsers such as chrome as a test tool, the browser limits concurrent requests for the same domain name. Thank you @mythz – wilmer Apr 02 '19 at 06:39