Why does IIS accept requests before RoleEntryPoint.OnStart returns?

送分小仙女□ 提交于 2019-12-22 18:37:40

问题


I'm playing with Azure sample from here on Compute Emulator and I found that if I make OnStart() in my class inherited from RoleEntryPoint rather slow to return the .aspx page in the web role accepts HTTP requests even before OnStart() returns.

I find it rather confusing - why would IIS accept requests to the role that hasn't yet started?


回答1:


The emulator does not emulate the load balancer 100%. For the cloud, when your role is in OnStart() you are reported to the LB as Busy and no traffic will be routed to it. Once you return from OnStart() with true, it will take a few seconds or so but only then will the LB start to route to it. You can test this yourself by tracing in your OnStart() and putting a big Sleep() in there. You won't be able to reach your instance (over non lingering ports).

You can of course ask the LB to ignore the Ready status and it will route even when busy - that is done by specifying ignoreRoleInstanceStatus="true" on the endpoint.



来源:https://stackoverflow.com/questions/6355988/why-does-iis-accept-requests-before-roleentrypoint-onstart-returns

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