如果网站闲置,则MVC速度很慢 [英] MVC slow if site has been idle

查看:102
本文介绍了如果网站闲置,则MVC速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的VPS上有几个MVC4网站.他们都有相同的问题.它们是如此之慢(最多需要加载10秒,这不是一个很好的第一印象).

I have several MVC4 sites on my VPS. They all have the same issue. They are so slow (up to 10 seconds to load, which is not a good first impression).

我知道,当您第一次加载网站时,由于阅读过的各种内容,可能需要一些时间.我明白这一点.

I am aware that when you first load your site, it will take a little while due to various things I've read upon. I understand this.

问题在于以下情况是正确的.

The problem is the following situation is true.

将MVC4站点发布到服务器.
在浏览器PC上加载MVC4站点.网站需要一段时间才能加载,但可以预期.
查看网站上的其他页面.有一些很慢,但通常都可以.
关闭网站.
重新打开网站.
所有页面都响应良好.
关闭网站.
使其闲置1小时.
打开网站,它又变慢了,好像它只是被发布

Publish MVC4 site to server.
Load MVC4 site in browser a PC. Site takes a while to load but expected.
Look at other pages on the site. A few are slow, but generally all is OK.
Close the website.
Reopen the website.
All pages respond well.
Close the website.
Leave it idle for 1 hour.
Open website, it is slow again, as if it's only been published

我只能假定这与会话,IIS或应用程序池有关

I can only assume it's something to do with the session, IIS or the app pool

在我曾经使用过跟踪的Web窗体中,我似乎在MVC中没有,而且我也不知道如何调试此类问题.

In webforms I used to have tracing, I don't appear to have that in MVC and I don't know how I can debug such an issue.

推荐答案

实际上,这是预期的行为,因为经过一段时间的不活动后,应用程序池将回收以释放未使用的资源.检查应用程序池的回收设置以配置该持续时间.

That's actually the expected behavior, given that after a period of inactivity the application pool will recycle, to free up unused resources. Check the application pool's Recycle settings to configure that duration.

如果您还希望对回收期间发生的事情进行更多控制,则有以下几种选择:

If you also want additional control on what happens during recycling there are a few options:

  • IIS7.5 (ASP.NET 4) supports a feature called "AutoStart", which can warm up your site after deployment and after recycling.

IIS8通过 查看全文

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