Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Web API session request is very slow

Tags:

I'm writing an ASP.NET Web API application hosted on IIS7 (no special configuration).

My problem is that for each first request (on a new machine/new browser/after a while...) there is a long delay - even on requests that return constants!

I've read about "warming up" scripts but it's not the issue here. It seems like the web server is trying to create a session and it takes very long time. Any suggestions?

EDIT

I think the delay is caused by worker-process creation for each new session. Now the question is why is it so slow, and why doesn't the web server reuse living worker-processes to serve requests?

I have configured the application pool to limit worker processes to 5 with no timeout (set to 0). This caused the first five sessions to be slow on first requests (which I can live with) and now the worker processes are alive. But surprisingly, from time to time, the request is slow again!

like image 551
Niro Avatar asked Nov 23 '13 17:11

Niro


People also ask

Why is API taking so long?

The larger the database (more data concerning devices, users, etc.), the longer it will take to sort through all the data and return a result. This also correlates to the back-end where calls are processed on a server.

How many requests can an API handle at a time?

In the API Console, there is a similar quota referred to as Requests per 100 seconds per user. By default, it is set to 100 requests per 100 seconds per user and can be adjusted to a maximum value of 1,000. But the number of requests to the API is restricted to a maximum of 10 requests per second per user.

Does Web API have session?

The ASP.NET Web API does not support sessions and does not rely on System.

Why is my asp net site so slow?

There can be numerous reasons why . NET applications can be slow. These include incorrect memory sizing, GC pauses, code-level errors, excessive logging of exceptions, high usage of synchronized blocks, IIS server bottlenecks, and so on.


1 Answers

If you are using Windows Server 2008 R2 you could configure the Auto-Start feature on the Application Pool. Also in the properties of the application pool you should disable it from being recycled at regular intervals. Bear in mind though that while this will limit the slowness, the application pool could still be recycled by IIS. With the Auto-Start feature it will be loaded again automatically in memory, but the code in your Application_Start will be executed on the next request. So you could still observe some slowness.

like image 58
Darin Dimitrov Avatar answered Sep 28 '22 06:09

Darin Dimitrov