I have an ASP.NET MVC 3 application that uses Entity Framework 4.3 code first. The application works satisfactorily with the WebDev server in Visual Studio. Once the application is running in IIS 7.5, it is, it occasionally happens that the server no longer responds. The browser waits until it times out. Also, a refresh of the page does not help. Only if the browser is closed and restarted the IIS provides responses back to the browser.
The work processes are utilized here to 0%. An infinite loop is ruled out as cause therefore. When I examine the worker process with the debugger, all threads are in the external code. Even with WinDbg I can not identify the cause.
The application uses the DbContext together with the UnitOfWork pattern. The controllers receive an UnitOfWork object via dependency injection. The dependency resolution is done with the UnityDependencyResolver of the Unity.Mvc package. The Entity Framwork is also used in my own MembershipProvier and role providers, but here is the DbContext explicitly created and destroyed.
I'm desperate. What could cause this behavior?
Related
Our live website is loading very slow at first request and I need to dig deeper in IIS/Server. Do you have any tricks that could help me investigate and resolve this without any 3rd parties tools?
There are some things to consider
Change IIS/Application Pools configuration to use startMode="AlwaysRunning" this causes to w3wp process spawning just after you start Application Pool (this reduces a bit of time with first request)
Start using Application Initialization Module, it may require some implementation but in basic setup can reduce time of first request at least several seconds
Alternatively you can use IProcessHostPreloadClient but it's specific to ASP.NET applications
If we are talking about application deployment process you also need to know that there are 2 concepts (if we are talking about .net applications) IIS Application Pool and .Net AppDomain https://www.treeloop.com/blog/iis-application-domain-and-pool-recycling so 2 and 3 may behave diferrently
IIS must compile the application when the first request come. That's why IIS cost so much time to return first response. Please application initialization.
application-initialization
I'm experiencing an issue with an asp.net core application that virtually hangs when started under load. Once started, the application can handle the load no problem. It feels like initialization is happening for every concurrent request. Is anyone else experiencing similar behavior?
test scenario:
start a test application that hits the service with 50 simultaneous tasks
start the service
notice the requests getting started, but extremely long delays before any start to finish and most will time out
As a temporary work around, I created middleware that throttles subsequent requests until the very first finishes. This effectively lets asp.net mvc initialize before processing the bulk of the requests. This particular app is asp.net core 1.1 (web api) with EF core.
When using a real database located halfway across the country, I experience a good 900ms delay for the first request to my ASP.NET Core WebAPI. This is because it needs to get a connection pool established for use with connecting to said database, and I do not eagerly create a connection pool when running the service. Instead, it gets initialized lazily when I request a connection via a connection factory that is registered as a singleton in the services container.
Perhaps you're experiencing the same type of delay as you stated you're using Entity Framework Core, which is presumably backed by SQL Server. Is a connection pool with the database being initiated lazily as part of this initial request?
Try making a controller that does not have any dependencies that returns a vanilla 200 OK. Assuming you do not have global filters that have expensive services to hydrate, you should see the baseline initialization performance of your web service.
I am currently using SignalR 2.0 and MVC 5.0 for my project. All the signalR update works fine except when I have updated the web.config file which causes the application pool to recycle. This is the starting point I notice SignalR behaving inconsistently. Sometimes I need to perform an action multiple times before the SignalR update can be propagated to the client. I have enabled the SignalR logging and I can't see anything displayed in the log whenever it failed to propagate to the client.
Do we need to do something in the hub, like reconnect or anything when the app pool got recycled?
At the moment, i didnt do anything in terms of coding and simply refresh the page. But it gives me that problems with SignalR. And the only way to fix that intermittent problem completely is to reboot the server.
Have anyone experienced this kind of behavior in SignalR?
Thanks in advance.
I have an asp.net mvc4 web api interface that gets about 54k requests a day.
http://myserv.x.com/api/123/getstuff?whatstuff=thisstuff
I have 3 web servers behind a load balancer that are setup to handle the http requests.
On average response times are ~300ms. However, lately something has gone awry (or maybe it has always been there) as there is sporadic behavior of response times coming back in 10-20sec. This would be for the same request hitting the same server directly instead of through the load balancer.
GIVEN:
- System has been passed down to me so there may be gaps with IIS confiuration, etc,.
- Database: SQL Server 2008R2
- Web Servers: Windows Server 2008R2 Enterprise SP1
- IIS 7.5
- Using MemoryCache aggressively with Model and Business Objects with eviction set to 2hrs
- Looked at the logs but really don't see anything significantly relevant
- One application pool...no other LOB applications running on this server
Assumptions & Ask:
Somehow I'm thinking that something is recycling the application pool or IIS worker threads are shutting down and restarting thus causing each new request to warmup and recache itself. It's so sporadic that it's tough to trouble shoot right now. The same request to the same server comes back fast as expected (back to back N requests) since it was cached in about 300ms....but wait about 5-10-20min and that same request to the same server takes 16seconds.
I have limited tracing to go by as these are prod systems so I can only expose so much logging details. Any help and information attacking this or similar behavior somebody else has run into is appreciated. Thx
UPDATE:
The w3wpe.exe process grows to ~3G. Somehow it gets wiped out and the PID changes so itself or something is killing it every 3-4min I see tons of warnings in my webserver (IIS) log:
A process serving application pool 'MyApplication' suffered a fatal
communication error with the Windows Process Activation Service. The
process id was '1732'. The data field contains the error number.
After 4-5 days of assessing IIS and configuration vs internal code issues I finally found the issue with little to no help with windbg or debugdiag IIS tools. Those tools contain so much information even with mini dumps or log trace stacks that they can be red herrings. Best bet was to reproduce it by setting up a "copy intelligently" instance of a production system, which we did not have at the time and took a bit for ops to set something up.
Needless to say the problem had to do with over cacheing business objects. There was one race condition where updates on a certain table were updating an attribute to that corresponding business object (updates were coming from multiple servers) which was causing an OOC stackoverflow that pretty much caused the cacheing to recursively cache itself to death thus causing the w3wp.exe process to die and psuedo-recycle itself. It was one of those edge cases that was incredibly hard to test and repro in a non-production environment.
Which event is the best for registering the types with Unity?
I wish to do this
iocContainer.RegisterType<ControllerA>();
iocContainer.RegisterType<ControllerB>();
so they could be retrieved by the ControllerFactory from the Unity Container.
My opinion was to do that in the Application_Start event, but I've been warned that I could face many problems caused by the App pool recycling (not firing the Application_start). So the alternative would be the Session_start.
Any advice?
[UPDATE]
But if I use
iocContainer.RegisterInstance<IService>(service)
what happens if the app pool recycle or IIS is resetted? Is the instance of service been recreated?
No, Application_start is the correct place to do it.
Nothing's going to help if the app pool or IIS (or the server is recycled). Then the container will be recycled itself, but when the app pool is restarted, the container will be configured anew.
I think that PreApplicationStartMethod is a better place.
Check out these articles:
http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx
http://ilearnable.net/2010/11/22/webactivator-preapplicationstartmethod/