网站只有第一个请求很慢
浏览“http://dev.bindsolution.com/”时,该网站需要很长时间才能开始处理。为什么会这样?
正在使用“CSS Sprites”、“css”和“JavaScript” minify,尽管我不认为问题是这样的。
为什么网站的第一次请求非常慢?
PS:我是从巴西来的
When browsing "http://dev.bindsolution.com/" the site takes too long to begin processing. Why this?
Are using "CSS Sprites", "css" and "JavaScript" minify although I do not think the problem is this.
Why the first request the site is extremely slow?
PS: I'm visiting from Brazil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您在发布后首次请求站点时,ASP.Net 需要编译并加载应用程序。
When you first request the site after publishing, ASP.Net needs to compile and load the application.
这取决于您所说的第一个请求是什么意思。它是应用程序(或应用程序池)重新部署/重新启动后的第一个请求吗?对应用程序的第一个请求很慢,可能是 IIS 必须启动 asp.net工人进程。
此链接还应为您提供更多详细信息: http://msdn.microsoft.com /en-us/library/ms366723.aspx
如果您的意思是任何用户的第一个请求,那么用户需要下载的文件会产生开销,而且该网站可能正在执行一些进程密集型的操作在Session_start,我会检查所有这些。
此外,如果您有权访问代码,您可能可以对其进行一些性能分析。我强烈推荐 JetBrains 的 dotTrace。
仅供参考,我与 JetBrains 没有任何关系。只是喜欢他们的软件/工具
It depends on what do you mean by first request.. Is it first request after an application (or app pool) has been redeployed/restarted, the very first request to your application is slow could be that IIS has to start the asp.net worker process.
also this link should provide you with more details: http://msdn.microsoft.com/en-us/library/ms366723.aspx
if you mean first request by any user well then there is an overhead on the files that needs to be downloaded by the user, also the site might be doing some process intensive stuff in Session_start, I would check all these..
Also if you have access to the code you could probably run some performance analysis on the same. I would highly recommend dotTrace by JetBrains.
FYI, I am no way associated with JetBrains. Just love their sw/tools
可能是第一次加载较慢,而后续加载较快,因为资源(js、css、images)已缓存以供后续视图使用,不需要加载。
firefox 插件 yslow 将为您提供有关大小和加载速度的详细分类。
还可以运行 smush.it ( yslow 的一部分)来缩小图像大小。它会使图像变小,但不会有明显的差异。
It could be that the first load is slow and subsequent loads are quicker because assets (js, css, images ) are cached for subsequent views and don't need to be loaded.
The firefox plugin yslow will give you a detailed breakdown on the sizes and loading speeds.
Also run smush.it ( part of yslow ) to shrink your image sizes. It will make the images smaller but there will be no noticeable difference.
IIS 可能已经关闭了一些需要启动的工作线程,您的 appDomain 将启动并加载 dll 中的所有类,并将这些类 JIT 为机器代码,ASP.Net 也将进行自己的预热(初始化管道,可能预编译一些视图等)。
更新
第一次请求很慢,因为页面需要加载的资源数量较多,一旦加载,浏览器就会缓存它们,不需要再次请求(这就是为什么速度会加快)改进)。
考虑在您自己的站点上聚合(并可能压缩)所有必需的资源,并在您的页面中引用这些资源。
IIS may have shut down some worker threads which need to be started, your appDomain will be starting and loading all classes from your dlls and JITing these to machine code, ASP.Net will also be doing it's own warmup (initialising all things required in the pipeline, possibly pre-compiling some views etc).
Update
The first request is slow because of the number of resources that the page has to load, once loaded, the browser will cache them do they will not need to be requested again (which is why there's the speed improvement).
Consider aggregating (and possibly compressing) all required resources on your own site, and referencing those in your pages.