Reputation: 308
The first request takes time to hit the server API method because it pre-building the services in a start-up task can anyone suggest me to reduce the initial latency of my first request after published in IIS
// This method gets called by the runtime.
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IContactService, ContactService>();
services.AddTransient<IPersonService, PersonService>();
services.AddTransient<IDashboardService, DashboardService>();
services.AddTransient<IEmployeeService, EmployeeService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/build";
});
}
Need to inject more than 100 services its taking time to prebuilding.
Upvotes: 13
Views: 7580
Reputation: 1727
This might be an issue with your IIS configuration as the Application Pool is recycled from inactivity.
If you set the ApplicationPool's Start Mode under Advanced Settings it should be ready to be used whenever you call it, unless you happen to call it just as the recycling is happening.
This can be found by:
For the latter issue of it recycling whenever it wants to (every 29 hours), you can schedule the recycle to happen at a set time to be unobtrusive. On the same Advanced Settings screen:
Change Regular Time Interval (minutes)
to 0Specific Times
and click the ...
where it says TimeSpan[] Array.Upvotes: 6