title: Web Api Entity Framework 6 High CPU Usage And Application Hang
body: <p>I have an ASP.NET Web Api application with Entity Framework 6 running on 2 extra large instances os AWS.</p>
  
  <p>It was 2 large instances before, but I was facing IIS 503 errors after some time.</p>
  
  <p>The problem is: the app which consumes this api makes a request every 10 seconds from each connected client. We've reached 5k simultaneous clients connected, calling the api every 10 seconds. The cpu of both instances are 40% (I think it's still high).</p>
  
  <p>Now the app is supporting the load. However we can reach up to 20k clients and I don't know what else can I improve in the code.</p>
  
  <p>The method which is called every 10 seconds is async.</p>
  
  <pre><code>public async Task&lt;ExampleContract&gt; Post(ExampleRequest example)
      {
          try
          {
              return await _localizacaService.ExampleAsync(example);
          }
          catch (DataException ex)
          {
              throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
          }
      }
  </code></pre>
  
  <p>Windows 2008
  IIS 7.5
  The only IIS setting I've changed was in queue limit, from 500 to 5000.</p>
  
  <p>Is anything else that I can do?</p>
  
  <p>Any help would be really appreciated</p>