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 7.5服务器上托管的ASP.NET MVC应用程序。以前在http://forums.iis.net/t/1176740.aspx上提供的预热模块已被删除。
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.
每当IIS或ASP.NET工作进程因任何原因重新启动时,应该预热应用程序。在预热期间,IIS应返回一些HTTP状态代码,表示其预热状态或无法为任何客户端提供服务。
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).
创建一个通过HttpRequests在网站中浏览必要页面的可执行文件是一个好主意吗?可执行文件可以从IProcessHostPreloadClient实现中触发。是否可以配置IIS以便它只接受来自localhost的请求,一旦可执行文件完成,它就可以切换到所有客户端 - 但是该交换机不应该触发IIS重启(显然)。
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?
是否可以使用Visual Studio 2010 - Web性能测试来预热应用程序而不是创建手动可执行文件?还有其他选择吗?
PS: The application uses Forms Authentication and uses sessions - so maintaining state cookie and other cookies is important.
PS:应用程序使用表单身份验证并使用会话 - 因此维护状态cookie和其他cookie非常重要。
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.
更新1 - 我们在我们的应用程序中使用.NET Framework 4.0和Entity Framework(数据库优先)。首次点击EF查询的速度很慢。热身背后的原因是让这些第一次点击不受影响。我们已经在大多数地方使用了编译查询,并且已经为EF实现了预编译视图。模型和应用程序的大小非常大且复杂。预热需要遍历许多页面,以确保在任何最终用户访问应用程序之前至少执行一次编译和非编译的EF查询。
3 个解决方案
#1
10
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 7.5的应用程序初始化模块通过在第一个请求到达之前加载Web应用程序来提高Web站点的响应能力。
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将预加载的一系列Url。我不认为您可以获得真正的用户登录,但也许您可以设置不需要登录的模拟页面,以满足您要求的相同热身效果?
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 8.0的以下教程包含有关如何启用重叠进程回收的分步方法。
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不会将活动流量切换到新的回收工作进程,直到新工作进程在新进程中完成所有应用程序初始化Urls的运行。这可确保浏览您网站的客户在应用程序运行并运行后看不到应用程序初始化页面。
This IIS Application Initialization module is built into IIS 8.0, but is available for download for IIS 7.5.
此IIS应用程序初始化模块内置于IIS 8.0中,但可供IIS 7.5下载。
#2
9
You may take a look at the following post for the Auto-Start feature built into IIS 7.5 and ASP.NET 4.0.
您可以查看以下帖子,了解IIS 7.5和ASP.NET 4.0中内置的自动启动功能。
#3
5
Any application that generates a server request for the hosted resources can be used to warm up an IIS process. Exactly how many requests you need depends on what parts need warming up. Typically, warm-up is used for:
任何为托管资源生成服务器请求的应用程序都可用于预热IIS进程。确切地说,您需要多少请求取决于需要预热的部件。通常,预热用于:
- Starting up a worker process. For this, you only need to ask for one resource to warm up a process for the entire application.
- 启动工作进程。为此,您只需要请求一个资源来为整个应用程序预热一个进程。
- Perform any static initialization, database startup, or pre-caching. Anything you do in your Global.asax file will happen when you do your first request, so if you can make all of your initialization happen then, you'll still only need to make one page request.
- 执行任何静态初始化,数据库启动或预缓存。当您执行第一个请求时,您在Global.asax文件中执行的任何操作都会发生,因此如果您可以进行所有初始化,那么您仍然只需要发出一个页面请求。
- Force pre-compilation of ASP.NET pages. For this to happen you would need to hit every page. Fortunately, this is typically not much of a time cost, so you likely don't need to worry about it. If you do have individual pages that load slowly, you can warm them up separately.
- 强制预编译ASP.NET页面。为此,您需要点击每一页。幸运的是,这通常不是一个时间成本,所以你可能不需要担心它。如果您确实有单独的页面加载缓慢,您可以单独加热它们。
The "warm-up" process here isn't anything magical. You just need force IIS to serve the URL in question. Everything you mentioned would take care of that: using a stress-test tool to query the URL, writing a custom utility to post HTTP requests, even just scripting out a tool like 'wget' or a PowerShell script to download the URLs would do it.
这里的“热身”过程并不神奇。您只需要强制IIS来提供相关URL。您提到的所有内容都会照顾到这一点:使用压力测试工具查询URL,编写自定义实用程序来发布HTTP请求,甚至只需编写“wget”或PowerShell脚本等脚本来下载URL就可以了。
As far as restricting access to localhost, as far as I know, within IIS, the only way to change that requires you to restart IIS. You could always build a pre-request hook into your application and maintain the state there, and have your warm-up process query some specific URL that toggles that state to "open". But I'm not sure what you would accomplish. If, somehow, a user did try to query your site before your warm-up finished, all that would happen is your site would take a long time to respond, then they would eventually get the page they asked for. If you locked them out of the site during warm-up, they would instead get a browser network error that claimed the site was offline, which (to me) sounds much worse.
至于限制对localhost的访问,据我所知,在IIS中,更改它的唯一方法需要重新启动IIS。您总是可以在应用程序中构建预请求挂钩并在那里维护状态,并让您的预热过程查询一些特定的URL,将该状态切换为“打开”。但我不确定你会完成什么。如果用户确实在热身结束之前尝试查询您的网站,那么所有这一切都会发生,您的网站需要很长时间才能回复,然后他们最终会获得他们要求的网页。如果你在热身期间将他们锁定在网站之外,他们会得到一个浏览器网络错误,声称该网站处于脱机状态,这对我来说听起来更糟糕。
#1
10
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 7.5的应用程序初始化模块通过在第一个请求到达之前加载Web应用程序来提高Web站点的响应能力。
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将预加载的一系列Url。我不认为您可以获得真正的用户登录,但也许您可以设置不需要登录的模拟页面,以满足您要求的相同热身效果?
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 8.0的以下教程包含有关如何启用重叠进程回收的分步方法。
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不会将活动流量切换到新的回收工作进程,直到新工作进程在新进程中完成所有应用程序初始化Urls的运行。这可确保浏览您网站的客户在应用程序运行并运行后看不到应用程序初始化页面。
This IIS Application Initialization module is built into IIS 8.0, but is available for download for IIS 7.5.
此IIS应用程序初始化模块内置于IIS 8.0中,但可供IIS 7.5下载。
#2
9
You may take a look at the following post for the Auto-Start feature built into IIS 7.5 and ASP.NET 4.0.
您可以查看以下帖子,了解IIS 7.5和ASP.NET 4.0中内置的自动启动功能。
#3
5
Any application that generates a server request for the hosted resources can be used to warm up an IIS process. Exactly how many requests you need depends on what parts need warming up. Typically, warm-up is used for:
任何为托管资源生成服务器请求的应用程序都可用于预热IIS进程。确切地说,您需要多少请求取决于需要预热的部件。通常,预热用于:
- Starting up a worker process. For this, you only need to ask for one resource to warm up a process for the entire application.
- 启动工作进程。为此,您只需要请求一个资源来为整个应用程序预热一个进程。
- Perform any static initialization, database startup, or pre-caching. Anything you do in your Global.asax file will happen when you do your first request, so if you can make all of your initialization happen then, you'll still only need to make one page request.
- 执行任何静态初始化,数据库启动或预缓存。当您执行第一个请求时,您在Global.asax文件中执行的任何操作都会发生,因此如果您可以进行所有初始化,那么您仍然只需要发出一个页面请求。
- Force pre-compilation of ASP.NET pages. For this to happen you would need to hit every page. Fortunately, this is typically not much of a time cost, so you likely don't need to worry about it. If you do have individual pages that load slowly, you can warm them up separately.
- 强制预编译ASP.NET页面。为此,您需要点击每一页。幸运的是,这通常不是一个时间成本,所以你可能不需要担心它。如果您确实有单独的页面加载缓慢,您可以单独加热它们。
The "warm-up" process here isn't anything magical. You just need force IIS to serve the URL in question. Everything you mentioned would take care of that: using a stress-test tool to query the URL, writing a custom utility to post HTTP requests, even just scripting out a tool like 'wget' or a PowerShell script to download the URLs would do it.
这里的“热身”过程并不神奇。您只需要强制IIS来提供相关URL。您提到的所有内容都会照顾到这一点:使用压力测试工具查询URL,编写自定义实用程序来发布HTTP请求,甚至只需编写“wget”或PowerShell脚本等脚本来下载URL就可以了。
As far as restricting access to localhost, as far as I know, within IIS, the only way to change that requires you to restart IIS. You could always build a pre-request hook into your application and maintain the state there, and have your warm-up process query some specific URL that toggles that state to "open". But I'm not sure what you would accomplish. If, somehow, a user did try to query your site before your warm-up finished, all that would happen is your site would take a long time to respond, then they would eventually get the page they asked for. If you locked them out of the site during warm-up, they would instead get a browser network error that claimed the site was offline, which (to me) sounds much worse.
至于限制对localhost的访问,据我所知,在IIS中,更改它的唯一方法需要重新启动IIS。您总是可以在应用程序中构建预请求挂钩并在那里维护状态,并让您的预热过程查询一些特定的URL,将该状态切换为“打开”。但我不确定你会完成什么。如果用户确实在热身结束之前尝试查询您的网站,那么所有这一切都会发生,您的网站需要很长时间才能回复,然后他们最终会获得他们要求的网页。如果你在热身期间将他们锁定在网站之外,他们会得到一个浏览器网络错误,声称该网站处于脱机状态,这对我来说听起来更糟糕。