Asp.Net - When does it restart the application - asp.net

I know that whenever you add/remove/modify any file in the "App_Code", "App_GlobalResources", and "bin" directories that ASP.NET will recompile and essentially restart the application.
My question is : "What happens to any threads currently executing durring the change?"
Do they finish? Is a Thread.Abort Exception thrown?
What happens if the application itself makes a change in any of those directories?

All currently executing threads are finished gracefully before recompilation.
Here's the docs:
When a worker process requests a
recycle, the WWW service initiates an
overlapped recycle, creating a new
worker process to replace the old one.
While the new worker process is
starting, the old process continues to
serve requests. After the new process
starts and initializes successfully,
the WWW service instructs the old
worker process to shut down. At this
point, the old worker process stops
accepting new requests from HTTP.sys
and begins to shut down. The WWW
service allows the old worker process
a configured time period in which to
finish processing its requests before
the worker process is shut down. The
WWW service terminates the worker
process if it fails to shut down
within the configured time.

Related

When does IIS spin up a new child worker process?

Platform: Windows Server 2016
Website: Default website using https
Custom app pools - 4 - one used as the default for our application[
Recycle settings: default
We have an issue with our web servers, where occasionally the existing worker process stops processing requests. But for whatever reason, IIS does not spin up a new worker process. The net effect is that the web server is dead in the water.
Is it possible that the existing process is not terminated until a new child process successfully announces itself?
This problem only occurs in the app pool that our application creates, and uses as the default app pool. (The other worker threads probably don't do enough to run into this situation)
The attached screenshot taken from our monitoring shows the server doing nothing, until we manually intervened and recyled IIS.

IIS .Net Website hangs even after restart IIS/Machine

I have a .Net application hosted in IIS 10 running on Windows Service 2019. Sometimes the website stops responding (usually when running E2E tests). Even after restarting Website/Application Pool/IIS/Machine it doesn't work.
Looking in Event Viewer I see errors like these:
Forms authentication failed for the request. Reason: The ticket supplied has expired
Failed to stop a listening channel for protocol 'http' at allotted time from worker process serving application pool
A process serving application pool exceeded time limits during shut down
In HTTPERR files I see a lot of messages containing Connection_Abandoned_By_ReqQueue and Connection_Dropped
In inetpub log files I can't see any relevant, just the url requests.
To add more information, we have signalr installed and sometimes errors appear in the events, errors with messages like:
The user identity cannot change during an active SignalR connection.
Any idea what might be causing this?

Does stopping IIS7 application pool kill any currently executing requests?

Does stopping an IIS7 application pool kill any currently executing requests? Or does it wait for all requests to complete?
Please notice, I am asking about stopping the pool, not recycling it.

nginx load balancing - keep last working server

I have two servers A and B.
Most of the time, both servers are not running at the same time.
So when A is running, it is most likely that B is not running.
When B is running, it is most likely that A is not running.
This switch between A and B can happen after some weeks.
So I would like that nginx redirect to the running server and keep using that server until it is down.
I have tried that solution:
upstream backend {
server SERVER_A;
server SERVER_B;
}
server {...}
This is working but I can see in the logs that it is periodically trying to connect to the "down" server.
Then I tried that:
upstream backend {
server SERVER_A;
server SERVER_B backup;
}
server {...}
This is working correctly if SERVER_A is up. But if it is SERVER_B, then it is frequently trying to access SERVER_A.
Actually, in that case, the correct configuration would be "server SERVER_A backup;" but I don't think we can do dynamic reconfiguration ;-)
Actually, it is not a very big deal that nginx is periodically trying to access the down server, but if I can avoid that using a correct configuration, it would be better.
I know about that fail-timeout argument. But I don't think it will really solve my issue, and it might even add some down time during switching.
Thanks in advance.
According to controlled mechanism for server switch a hook to mark an individual server down is only required:
sed -i 's/server SERVER_A;/server SERVER_A down;/' /etc/nginx/nginx.conf
nginx -s reload
A configuration load of standard procedure that handles graceful reload and it is safe: http://nginx.org/en/docs/beginners_guide.html#control
Once the master process receives the signal to reload configuration,
it checks the syntax validity of the new configuration file and tries
to apply the configuration provided in it. If this is a success, the
master process starts new worker processes and sends messages to old
worker processes, requesting them to shut down. Otherwise, the master
process rolls back the changes and continues to work with the old
configuration. Old worker processes, receiving a command to shut down,
stop accepting new connections and continue to service current
requests until all such requests are serviced. After that, the old
worker processes exit.

Does stopping a BizTalk host instance also stop the Applications that run under it?

Does stopping a BizTalk host instance also stop the Applications that run under it?
Or, what is the difference between stopping a host instance and stopping the applications under it?
No, host instances and applications are completely independent. You can stop a host instance and the application will remain in the started state. You can stop an application and the host instance will remain in the running state.
To understand the difference between stopping a host instance and stopping an application you first need to understand what these things are.
Basically, you need to think of your application as a set of assemblies plus some runtime configuration, and a set of logical subscriptions.
When you "start" an application up there are actually two steps which happen.
The parts of your application which need to receive messages (orchestrations and send ports) are enlisted. This ensures that an internal queue exists to receive the messages. Note that the application is not yet started, but it can receive and queue messages for processing later.
Then when you start the application the various parts of your application are able to process the messages.
The host instance is basically a windows service.
When you stop the host instance, all you are really doing is stopping the underlying windows service which runs the host instance. This means that all the assemblies which contain your application artifacts are unloaded, and the application will obviously stop processing. This is despite the fact that the application is still in the started state.
When you start the host instance again it loads your application assemblies back into memory and will be able to continue processing new messages. Messages which were being processed when the host instance was stopped may be in a state called suspended, but if they are can be manually resumed.
Hope this helps.
Yes, if you application run only on that host instance (meaning: application will stop to process messages). However internals of why it stopped processing is quite different. See explanation below and in hugh jadick's answer.
Stopping host instance for specified host type will stop execution of all artifacts (adapter handlers, receive locations, pipelines, orchestrations, etc.) that run on specified host. Application is a logical group of artifacts which can run on single or multiple host instances. Multiple applications can run on a single host instance, and vice versa. So, stopping an app is just shutdown of execution of artifacts, while stopping host instance is shutdown of physical instance there app artifacts are executing.

Resources