erratic behavior of Preload()

爱⌒轻易说出口 提交于 2019-12-31 03:49:05

问题


I have a WCF application hosted in Windows Azure. It has IIS v8.0

I have used IProcessHostPreloadClient's Preload() method for application warmup

Now, I have two issues here:

1) whenever my application pool recycles, the Preload() function is called twice. I have some static variables being initialized in the preload() method which will persist in my worker process (w3wp.exe).

What I have seen is interesting:

My current worker process ID is (w3wp.exe 1234,say)

when recycled, preload is called twice:

1st Time: in w3wp.exe which has Process ID: 5678,say (a new worker process)

2nd Time: in w3wp.exe which has Process ID: 1234 (same as the exiting one)

Now, I have configured my app pool so that only one instance of w3wp.exe will be present. Hence after recycle happens, the w3wp.exe that exists is that of process id: 5678.

My question is, why a dying w3wp.exe with process ID: 1234 has executed preload

There is a 3ms gap between both.

EDIT I just learned that what exactly happens is that due to app-pool recycle, an old w3wp.exe terminates and a new w3wp.exe is started. What causes preload to be called twice is:

1) new process of w3wp.exe - causes preload() to be called on the new process (Process ID: 5678 in our example)

2) the old process of w3wp.exe (Process ID: 1234) : Its app-domain is restarted before it is killed. Hence, when app domain is restarted, preload() is called

Now, my question is why a dying w3wp.exe's app-domain got restarted. It was about to die anyways in next 3ms (as mentioned above)

2) I have started the service and I was doing some testing. In between, for sometime, worker process was not serving any requests. But my w3wp.exe has a thread which runs continuously.

What we observer after some time was that, the existing instance of w3wp.exe (process id 1234,say) ended abruptly and preload() was called in the same process (w3wp.exe with process id 1234)

What I am assuming is that, for some reason, preload was called again. I used to think that preload will be called only when a new w3wp.exe will be created (in turn meaning that app pool has recycled)

This behavior was observed twice Can anyone tell me anything about it

EDIT

Answer: Partial: its because of app-domain restart. I still do not know why app-domain got restarted

来源:https://stackoverflow.com/questions/27859599/erratic-behavior-of-preload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!