简体   繁体   English

IIS应用程序池/重新启动和ASP.NET

[英]IIS App Pool/Restart and ASP.NET

We are using IIS7 to host an asp.net web-based application. 我们使用IIS7来托管基于Web.net的asp.net应用程序。 In this environment administrators and developers can deploy code to the application on a regular basis. 在此环境中,管理员和开发人员可以定期将代码部署到应用程序。

The new code or app goes as a DLL to the ASP.NET bin folder. 新代码或应用程序作为DLL进入ASP.NET bin文件夹。 Upon deployment of the new DLL, IIS restarts the process, impacting (slowing down) all online users. 部署新DLL后,IIS将重新启动该进程,从而影响(减慢)所有在线用户。

Is there a way to configure IIS to run the process in the background and once ready make the switch from old state into new without impacting the users?! 有没有办法配置IIS以在后台运行该进程,并准备好从旧状态切换到新状态而不影响用户?!

Thanks in advance for your feedback! 在此先感谢您的反馈!

IIS already does this, that's what recycling is all about. IIS已经做到了这一点,这就是回收利用的全部内容。 IT's loading the DLL's while the old version of the application is still running. 当旧版本的应用程序仍在运行时,IT正在加载DLL。 only after this is completed the recycling is complete. 只有在完成后才能完成回收。

However loading the DLL's is only part of getting web applications ready , there might also be initial loads like loading/caching the user db etc. 但是, 加载DLL只是准备好Web应用程序的一部分 ,也可能有初始加载,如加载/缓存用户数据库等。
These actions are not part of the recycle process , they happen after all DLL's reloaded and the recycling is already completed. 这些操作不是回收过程的一部分 ,它们在所有DLL重新加载并且回收已经完成之后发生。

A while back I ran into this issue with an application that had a huge startup time due to heavy db activity/caching during startup. 前段时间我遇到了这个问题,因为在启动过程中由于数据库活动/缓存繁重而导致启动时间很长。 So I was interested if there is some functionality that allows us to execute code before the recycle is marked as completed, so that the application is first considered recycled when everything is ready to run. 所以我感兴趣的是,是否有一些功能允许我们在回收标记为已完成之前执行代码,以便在一切准备好运行时首先考虑回收应用程序。 Basically what I wanted is some kind of staging functionality. 基本上我想要的是某种分段功能。
I was in contact with the IIS team regarding this issue, sadly they told me that no such functionality exists, nor is it planned . 我在这个问题上与IIS团队保持联系,遗憾的是他们告诉我没有这样的功能存在,也没有计划

To solve this you could try do the following: 要解决此问题,您可以尝试执行以下操作:

  • Use alternating deploys: 使用交替部署:
    You setup 2 Websites with separate application pools. 您设置了2个具有单独应用程序池的网站。 One of them is the LIVE website the other one is the STAGED website. 其中一个是LIVE网站,另一个是STAGED网站。 If you want to deploy changed you simply deploy to the STAGED website. 如果要部署更改,只需部署到STAGED网站即可。 After everything is loaded/cached etc. you switch the URL settings of the web applications to reroute incoming requests from the LIVE to the STAGED one. 在加载/缓存所有内容之后,您可以切换Web应用程序的URL设置,以将来自LIVE的传入请求重新路由到STAGED请求。 So the LIVE one becomes the new STAGED and the other way around. 所以LIVE一个成为新的STAGED而另一个方式。 The next deploy would then go to the new STAGED again and so on. 然后,下一次部署将再次转到新的STAGED,依此类推。

UPDATE UPDATE
Apparently they have created a IIS Module that provides this functionality by now: 显然他们已经创建了一个IIS模块,现在提供此功能:

IIS Application Warm-Up Module for IIS 7.5 IIS 7.5的IIS应用程序预热模块

The IIS team has released the first beta test version of the Application Warm-Up Module for IIS 7.5. IIS团队发布了IIS 7.5应用程序预热模块的第一个beta测试版。 This makes warming up your applications even easier than previously described. 这使得应用程序的预热比以前描述的更容易。 Instead of writing custom code, you specify the URLs of resources to execute before the Web application accepts requests from the network. 您可以指定在Web应用程序接受来自网络的请求之前要执行的资源的URL,而不是编写自定义代码。 This warm-up occurs during startup of the IIS service (if you configured the IIS application pool as AlwaysRunning) and when an IIS worker process recycles. 在IIS服务启动期间(如果将IIS应用程序池配置为AlwaysRunning)以及IIS工作进程回收时,会发生此预热。 During recycle, the old IIS worker process continues to execute requests until the newly spawned worker process is fully warmed up, so that applications experience no interruptions or other issues due to unprimed caches. 在回收期间,旧的IIS工作进程继续执行请求,直到新生成的工作进程完全预热,以便应用程序不会因未启用的高速缓存而出现中断或其他问题。 Note that this module works with any version of ASP.NET, starting with version 2.0. 请注意,此模块适用于任何版本的ASP.NET,从2.0版开始。

For more information, see Application Warm-Up on the IIS.net Web site. 有关更多信息,请参阅IIS.net网站上的应用程序预热。 For a walkthrough that illustrates how to use the warm-up feature, see Getting Started with the IIS 7.5 Application Warm-Up Module on the IIS.net Web site. 有关如何使用预热功能的演练,请参阅IIS.net网站上的IIS 7.5应用程序预热模块入门。

See: 看到:

http://www.asp.net/whitepapers/aspnet4 http://www.asp.net/whitepapers/aspnet4

If you use ASP.NET 4 Auto Start feature: 如果您使用ASP.NET 4自动启动功能:

You can still choose to auto-recycle the worker processes from time to time. 您仍然可以选择自动回收工作进程。 When you do that, though, the app will immediately restart and your warm up code will execute (unlike today - where you have to wait for the next request to-do that). 但是,当你这样做时,应用程序将立即重新启动,你的预热代码将会执行(与今天不同 - 你必须等待下一个请求才能执行此操作)。

The main difference between Warm Up and Auto Start feature is that the Warm Up Module is part of the recycling process. 预热和自动启动功能的主要区别在于预热模块是回收过程的一部分。 Rather than blocking the application for requests, while running the init code . 而不是在运行init代码时阻止应用程序的请求
Only thing you get by using the Auto Start feature is that you don't have to wait for a user to hit the page, which does not help your case. 只有使用“自动启动”功能才能获得的是,您不必等待用户点击页面,这对您的情况没有帮助。

See the Gu's blog post: 参见顾的博客文章:

http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx

UPDATE 2: 更新2:

Sadly the Warmup Module has been discontinued for IIS 7/7.5: 遗憾的是,IIS 7 / 7.5已停止使用预热模块:

http://forums.iis.net/t/1176740.aspx http://forums.iis.net/t/1176740.aspx

It will be part of IIS8 though (It's now called Application Initialization Module): 它将成为IIS8的一部分(它现在称为应用程序初始化模块):

http://weblogs.asp.net/owscott/archive/2012/03/01/what-s-new-in-iis-8.aspx http://weblogs.asp.net/owscott/archive/2012/03/01/what-s-new-in-iis-8.aspx

UPDATE 3: 更新3:

As pointed out in the comments the Warmup Module resurfaced for IIS 7.5 as Application Initialization Module for IIS 7.5 after IIS 8 was released: 正如评论中所指出的,在IIS 8发布后,预热模块重新启动IIS 7.5作为IIS 7.5的应用程序初始化模块

http://www.iis.net/downloads/microsoft/application-initialization http://www.iis.net/downloads/microsoft/application-initialization

The first part of ntziolis answer is a wee bit inaccurate. ntziolis答案的第一部分是一点点不准确。 The worker process isn't being recycled or restarted, it just keeps running. 工作进程没有被回收或重新启动,它只是继续运行。 If this were the case, then in shared pool environments you would have sites knocked out every time a new one was deployed. 如果是这种情况,那么在共享池环境中,每次部署新站点时都会将站点淘汰。

When you deploy a new ASP.NET application it's the site's "Application Domain" within the worker process is torn down, not the pool process. 当你部署一个新的ASP.NET应用程序它的工作进程的网站的“应用程序域”被拆除,而不是池进程。

In addition pool recycling is a completely separate concept to deployment 此外,池回收是一个完全独立的部署概念

At this point in time in the commercial life of ASP.NET, during a deployment, a site will be in an inconsistent state until all of the site is deployed. 在ASP.NET的商业生命中的这个时间点,在部署期间,站点将处于不一致状态,直到部署了所有站点。 There is still no good story about this from Microsoft at this time for single site on a single server deployments. 目前,对于单个服务器部署的单个站点,Microsoft仍然没有关于此的好故事。

This is why ASP.NET has the special App_Offline.htm page. 这就是ASP.NET具有特殊的App_Offline.htm页面的原因。 It's there so you can enable that page, deploy and then turn it off. 它就在那里你可以启用该页面,部署然后关闭它。

The second part of ntziolis answer is nearly correct but you don't need two sites or two application pools. ntziolis答案的第二部分几乎是正确的,但您不需要两个站点或两个应用程序池。 You just need two file system folders that switch between being the physical folders for the site...if you're on a single server and not behind a load balancer or ARR. 您只需要两个文件系统文件夹,它们可以在站点的物理文件夹之间切换...如果您在单个服务器上而不是在负载均衡器或ARR之后。

If your sites were on a web server behind a load-balancer or ARR then having two different sites would make sense, you could route requests from one site to the other and round-robin on each deploy. 如果您的站点位于负载均衡器或ARR后面的Web服务器上,那么有两个不同的站点是有意义的,您可以将请求从一个站点路由到另一个站点并在每个部署上循环。

Obviously if there is a large amount of user generated content (uploaded files and the like) then you'd map a virtual directory in your site to a common location for this data. 显然,如果有大量用户生成的内容(上传的文件等),那么您将站点中的虚拟目录映射到此数据的公共位置。

In larger scale deployments where your app is running across (for example) a load-balanced environment you can do more sophisticated deployments. 在运行应用程序的较大规模部署(例如)负载平衡环境中,您可以执行更复杂的部署。

For related questions please see: 有关相关问题,请参阅:

How Do I deploy an application to IIS while that web application is running 如何在运行该Web应用程序时将应用程序部署到IIS

Publishing/uploading new DLL to IIS: website goes down whilst uploading 将新DLL发布/上传到IIS:网站在上传时关闭

Is smooth deployment possible with componentized ASP.NET MVC apps? 使用组件化的ASP.NET MVC应用程序可以顺利部署吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM