title: Web Api 2 OWIN Selfhost handle multiple concurrent requests
body: <p>I have a selfhosted web api using OWIN, and I seems to struggle on concurrent connections. When I run a stress test with 50 concurrent get events, the response time is increasing A LOT, even tho the operation is quite simple, return 200 OK with the id typed in the uri.</p>
  
  <p>How do I my web api OWIN and api controllers to run simultanious per requests??</p>
  
  <p>Here's a sample of my project:</p>
  
  <p>Startup class</p>
  
  <pre><code>public class Startup
  {
      public void Configuration(IAppBuilder appBuilder)
      {
          try
          {
              appBuilder.UseWelcomePage("/welcome.html");
              appBuilder.UseErrorPage(new ErrorPageOptions
              {
                  ShowExceptionDetails =
      #if DEBUG
                  true
      #else
                  false
      #endif
              });
  
              Debug.WriteLine($"Setting Web Api Configuration up...");
              var apiConfig = ConfigureWebApi();
              appBuilder.UseWebApi(new HttpServer(apiConfig));
              appBuilder.UseCors(CorsOptions.AllowAll);
  
              Debug.WriteLine($"Completed Web Api configuration.");
          }
          catch (Exception ex)
          {
              Debug.WriteLine($"Failed to complete Web Api setup.", ex);
              throw;
          }
      }
  }
  </code></pre>
  
  <p>Controller    </p>
  
  <pre><code>public class TestController : ApiController
  {
      public async Task&lt;IHttpActionResult&gt; Get(int id)
      {
          return Task&lt;IHttpActionResult&gt;.Factory.StartNew(() =&gt; {
              try
              {
                  return Ok(id);
              }
              catch (Exception ex)
              {
                  Debug.WriteLine(ex.Message, nameof(Get));
                  return InternalServerError();
              }
          });
      }
  }
  </code></pre>
  
  <p>My console startup of web api:</p>
  
  <pre><code>public static void Open()
  {
      _webApp = WebApp.Start&lt;Startup&gt;(HostAddress);
      Console.WriteLine($"Host open -&gt; {HostAddress}");
  }
  </code></pre>