I am running the GRPC ASP.NET Core Web API. I want to reduce the multiple thread instance to single thread instance. So I used pstree command to see how many threads it invoked.
This is the output:
├─node─┬─bash───dotnet─┬─TestGRPC───25*[{TestGRPC}]
│ │ │ └─16*[{dotnet}]
│ │ ├─2*[bash───htop]
│ │ ├─bash───pstree
│ │ └─14*[{node}]
We can see that it is invoking 25 thread instance. I tried to reduce it to 4 thread instances using below code. But it didn’t work.
bool isMin = ThreadPool.SetMinThreads(1, 1);
bool isMax = ThreadPool.SetMaxThreads(4, 4);
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.Limits.MaxConcurrentConnections = 1;
});
Here is the output I got after setting the max threads to 4 and min threads to 1
├─node───12*[{node}]
│ ├─node─┬─bash───dotnet─┬─TestGRPC───26*[{TestGRPC}]
│ │ │ └─23*[{dotnet}]
│ │ ├─2*[bash───htop]
│ │ ├─bash───pstree
│ │ └─14*[{node}]
Could someone please help me to control the number of thread instances invoked by ASP.NET Core Web API?
Curio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4