如何在 IIS 7.5 上预热 ASP.NET MVC 应用程序? [英] How to warm up an ASP.NET MVC application on IIS 7.5?

查看:36
本文介绍了如何在 IIS 7.5 上预热 ASP.NET MVC 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想要预热一个托管在 IIS 7.5 服务器上的 ASP.NET MVC 应用程序.以前在 http://forums.iis.net/t/1176740.aspx 已被删除.

We would like to warm up an ASP.NET MVC application hosted on IIS 7.5 server. The warm up module that used to be available at http://forums.iis.net/t/1176740.aspx has been removed since sometime.

每次 IIS 或 ASP.NET 工作进程因任何原因重新启动时,都应预热应用程序.在预热期间,IIS 应返回一些 HTTP 状态代码,表明其处于预热状态或无法为任何客户端提供服务.

The application should be warmed up everytime IIS or ASP.NET worker-process restarts for any reason. During the warm up period, IIS should return some HTTP status code signifying its warm up state or its inability to serve any clients.

创建一个可执行文件,通过 HttpRequests 浏览站点中的必要页面是个好主意吗?可执行文件可以从 IProcessHostPreloadClient 实现触发.是否可以将 IIS 配置为仅接受来自本地主机的请求,并且一旦可执行文件完成,它就可以切换到所有客户端 - 但该切换不应触发 IIS 重新启动(显然).

Would creating a executable that navigates through necessary pages in the site via HttpRequests be a good idea? The executable can be triggered from IProcessHostPreloadClient implementation. Is it possible to configure IIS so that it would only accept requests from localhost and once the executable is done, it can switch over to all clients - but that switch should not trigger an IIS restart (obviously).

是否可以使用 Visual Studio 2010 - Web 性能测试来预热应用程序而不是创建手动可执行文件?还有其他选择吗?

Is it possible to use an Visual Studio 2010 - Web Performance Test to warm-up an application instead of creating an manual executable? Any other alternatives?

PS:应用程序使用表单身份验证并使用会话 - 因此维护状态 cookie 和其他 cookie 很重要.

PS: The application uses Forms Authentication and uses sessions - so maintaining state cookie and other cookies is important.

更新 1 - 我们在我们的应用程序中使用 .NET Framework 4.0 和实体框架(数据库优先).EF 查询的第一次命中速度很慢.热身背后的原因是为了避免这些第一次命中.我们已经在大多数地方使用了编译查询,并且我们已经为 EF 实现了预编译视图.模型和应用程序的规模非常大且复杂.预热需要遍历许多页面,以确保在任何最终用户访问应用程序之前至少执行一次已编译和未编译的 EF 查询.

UPDATE 1 - We are using .NET Framework 4.0 and Entity Framework (database first) in our application. The first time hits to EF queries are slow. The reason behind the warm up is to get these first time hits out of the way. We are already using compiled queries at most places and we have implemented pre-compiled views for EF. The size of the model and application is very large and complex. Warm up needs to walk through many pages to ensure that compiled and non-compiled EF queries get executed at-least once before any end user gets access to the application.

推荐答案

Microsoft 发布了一个模块,可以完全满足您的要求.IIS 7.5 的应用程序初始化模块通过在第一个请求之前加载 Web 应用程序来提高网站的响应能力到达.

Microsoft has released a module that does exactly what you ask for. The Application Initialization Module for IIS 7.5 improves the responsiveness of Web sites by loading the Web applications before the first request arrives.

您可以指定 IIS 在接受来自真实用户的请求之前预加载的一系列 Url.我认为您无法获得真正的用户登录体验,但也许您可以设置不需要登录的模拟页面来满足您所要求的相同预热?

You can specify a series of Urls that IIS will preload before accepting requests from real users. I don't think you can get a true user login expereince, but maybe you can set up simulated pages that does not require login that fulfills the same warmup you ask for?

我认为最引人注目的功能是该模块还支持重叠进程回收.来自 IIS 8.0 的以下教程包括有关如何启用重叠流程回收的分步方法.

The feature I think is most compelling is that this module also enables overlapped process recycling. The following tutorial from IIS 8.0 include a step-by-step approach on how to enable overlapped process recycling.

当 IIS 检测到活动的工作进程正在被回收时,IIS 不会将活动流量切换到新的回收工作进程,直到新工作进程在新进程中运行完所有应用程序初始化 Url.这可确保浏览您网站的客户在应用程序上线并运行后不会看到应用程序初始化页面.

When IIS detects that an active worker process is being recycled, IIS does not switch active traffic over to the new recycled worker process until the new worker process finishes running all application initialization Urls in the new process. This ensures that customers browsing your website don't see application initialization pages once an application is live and running.

此 IIS 应用程序初始化模块内置于 IIS 8.0 中,但可供 IIS 7.5 下载.

This IIS Application Initialization module is built into IIS 8.0, but is available for download for IIS 7.5.

这篇关于如何在 IIS 7.5 上预热 ASP.NET MVC 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆