修复 IIS 的缓慢初始加载 [英] Fixing slow initial load for IIS

查看:29
本文介绍了修复 IIS 的缓慢初始加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IIS 对低流量网站有一个令人讨厌的功能,它会回收未使用的工作进程,导致第一个用户在一段时间后访问该网站,延迟时间非常长(30 秒以上).

IIS has an annoying feature for low traffic websites where it recycles unused worker processes, causing the first user to the site after some time to get an extremely long delay (30+ seconds).

我一直在寻找问题的解决方案,并且找到了这些潜在的解决方案.

I've been looking for a solution to the problem and I've found these potential solutions.

A.使用应用初始化插件

B.在 .NET 4 中使用自动启动

C.禁用空闲超时(在 IIS 重置下)

D.预编译网站

我想知道这些中哪一个是首选,更重要的是,为什么同一个问题有这么多解决方案?(我猜他们不是,我只是没有正确理解某些东西).

I'm wondering which of these is preferred, and more importantly, why are there so many solutions to the same problem? (My guess is they aren't, and I'm just not understanding something correctly).

编辑

执行 C 似乎足以让我的网站升温,但我发现我网站缓慢的真正根源与实体框架有关,我似乎无法弄清楚为什么它会变冷.请参阅这个问题,遗憾的是尚未回答已回答!

Performing C seems to be enough to keep my site warmed up, but I've discovered that the real root of my site's slowness has to do with Entity Framework, which I can't seem to figure out why it's going cold. See this question, which unfortunately hasn't been answered yet has been answered!

我最终只需要制作一个 预热脚本 偶尔访问我的网站以确保它保持快速.

I eventually just had to make a warm up script to hit my site occasionally to make sure it stayed speedy.

推荐答案

选项 A、B 和 D 似乎在同一类别中,因为它们只影响初始启动时间,它们对网站进行预热,例如编译和加载内存中的库.

Options A, B and D seem to be in the same category since they only influence the initial start time, they do warmup of the website like compilation and loading of libraries in memory.

使用 C 设置空闲超时应该足够了,以便快速处理对服务器的后续请求(重新启动应用程序池需要相当长的时间 - 以秒为单位).

Using C, setting the idle timeout, should be enough so that subsequent requests to the server are served fast (restarting the app pool takes quite some time - in the order of seconds).

据我所知,超时的存在是为了节省在该机器上并行运行的其他网站可能需要的内存.代价是加载时间变慢了一次.

As far as I know, the timeout exists to save memory that other websites running in parallel on that machine might need. The price being that one time slow load time.

除了应用池在用户不活动的情况下关闭的事实外,应用池还会默认每 1740 分钟(29 小时)回收一次.

Besides the fact that the app pool gets shutdown in case of user inactivity, the app pool will also recycle by default every 1740 minutes (29 hours).

来自技术网:

Internet 信息服务 (IIS) 应用程序池可以定期回收以避免可能导致不稳定状态应用程序崩溃、挂起或内存泄漏.

Internet Information Services (IIS) application pools can be periodically recycled to avoid unstable states that can lead to application crashes, hangs, or memory leaks.

只要保留应用程序池回收,就足够了.但是,如果您真的希望大多数组件具有一流的性能,您还应该使用您提到的应用程序初始化模块之类的东西.

As long as app pool recycling is left on, it should be enough. But if you really want top notch performance for most components, you should also use something like the Application Initialization Module you mentioned.

这篇关于修复 IIS 的缓慢初始加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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