Topic:   Why is my controller blocking?
Jan 25, 2021 14:32 1 Replies 403 Views ALLINO

I have simple test for asp net core web api :

[HttpGet]

I send 20 requests to server.

But my app deployed to IIS can process only 10 requests.

When 10 request is processed, it process next 10 requests.

public async Task GetAsync()

{

string ConnectionString = "Min Pool Size=20;Pooling=true;Server=172.31.3.177;Database=mantra2017;Integrated Security=SSPI;";

using (SqlConnection c = new SqlConnection(ConnectionString))

{

await c.OpenAsync();

using (SqlCommand sc = new SqlCommand("WAITFOR DELAY '00:00:20';", c))

{

await sc.ExecuteNonQueryAsync();

}

}

return 77;

}

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    PARTH

    There are two issues I can see here-

    1. The first is that your controller is not truly asynchronous. Spinning up a ThreadPool thread to perform work generally has worse performance characteristics than just doing everything from within the action method itself, as you're still taking ThreadPool resources from ASP.NET
    2. The second issue is that ASP.NET MVC takes a Session lock on all requests. Multiple requests within a single Session will always be serialized, as otherwise the user's Session could become corrupted if one controller writes to Session as another controller is trying to read it.

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect