2

I am new to asp.net Core and so far I like it . I have a very simple action that just returns a string "Hello World" . My problem is that I think that http request are locking which is really slowing things down essentially just like this ASP.NET application to serve multiple requests from a single process . I am doing load testing my first request is 967 milliseconds however my 100th request takes 10927 milliseconds or 10 seconds which is incredibly long to return a simple string . This is being done in release mode .

  public string HomeStream()
    {

        return "Hello World";
    }

I am thinking that something is locking http requests because the 100th request should return much sooner . Any suggestions would be great. This is my launch settings

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:55556/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyApp": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5002/"
    }
  }
}

I am using the 5002 url . enter image description here

user1591668
  • 2,591
  • 5
  • 41
  • 84
  • 4 cpu's it's a MacBook Pro – user1591668 Oct 08 '17 at 05:20
  • What are `maxConcurrentThreadsPerCPU` and `maxConcurrentRequestsPerCPU` set to https://stackoverflow.com/questions/44391268/how-to-configure-concurrency-in-net-core-web-api ? Does setting `ThreadPool.SetMinThreads` to a large number (say 2000) help? What OS are you running on (Windows 10 Home? something else?)? – mjwills Oct 08 '17 at 05:21
  • I don't think those options exists for .net core 2.0 – user1591668 Oct 08 '17 at 05:36

1 Answers1

1

If all you are doing is trying to return a simple string and load testing the underlying host then I would suggest you remove all the middleware and services

using System.Net;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

public static void Main(string[] args)
{
    IWebHost host = new WebHostBuilder()
        .UseKestrel()
        .Configure(app =>
        {
            // notice how we don't have app.UseMvc()?
            app.Map("/hello", SayHello);  // <-- ex: "http://localhost/hello"
        })
        .Build();

    host.Run();
}

private static void SayHello(IApplicationBuilder app)
{
    app.Run(async context =>
    {
        // implement your own response
        await context.Response.WriteAsync("Hello World!");
    });
}
Svek
  • 12,350
  • 6
  • 38
  • 69