ASP.NET MVC与WebForms的大项目首页加载速度

时间:2022-08-05 03:18:51

We have a pretty big ASP.NET WebForm (web application) project with a lot of references to other libraries, other projects etc and most of the time after a compilation, the first time we load a page it takes a LONG time before rendering anything... Disk IO is the main problem. For small projects it's nearly instantaneous, but once your project gets large, it can really slow development and remove fun from programming.

我们有一个非常大的ASP.NET WebForm(Web应用程序)项目,其中包含大量对其他库,其他项目等的引用,并且大部分时间在编译之后,我们第一次加载页面时需要很长时间才能呈现任何内容...磁盘IO是主要问题。对于小型项目来说,它几乎是即时的,但是一旦你的项目变得庞大,它就会真正减慢开发速度并消除编程带来的乐趣。

My question: Is first page load time after a compilation as long in ASP.NET MVC as it is in ASP.NET Webforms for big projects?

我的问题:在ASP.NET MVC编译之后的第一页加载时间和ASP.NET Webforms中的大型项目一样吗?

3 个解决方案

#1


3  

MVC still uses the same ASP.NET framework as Web Forms, so you are probably going to see similar behavior, regardless.

MVC仍然使用与Web窗体相同的ASP.NET框架,因此您可能会看到类似的行为,无论如何。

The long first load time is because your project's build output is still just IL code that needs to be compiled into native code by the JIT compiler before executing. Any code changes that you make will cause the previously cached native code for your app to be discarded, so the JIT has to recompile. Naturally, the larger your project, the longer it's going to take for the JIT to process it.

首次加载时间较长是因为项目的构建输出仍然只是IL代码,需要在执行之前由JIT编译器编译为本机代码。您所做的任何代码更改都将导致您的应用程序的先前缓存的本机代码被丢弃,因此JIT必须重新编译。当然,项目越大,JIT处理它的时间就越长。

#2


2  

You will see similar load times in both environments.

您将在两种环境中看到类似的加载时间。

In both environments, if your site gets large you should pre-compile your site before deployment. This will eliminate the performance drag on first page load.

在这两种环境中,如果您的站点变大,您应该在部署之前预先编译您的站点。这将消除首页加载时的性能拖累。

#3


1  

There are a lot of things thhat can be done to improve performance, the enhancements in order to provide for a separation of concerns in MVC apps can help a lot. Though the default view engine re-uses webforms, Views have a far simpler control stack than typical webforms, which helps a lot, not to even mention alternative view engines.

有很多事情可以做,以提高性能,为了提供MVC应用程序中的关注点分离的增强可以帮助很多。虽然默认视图引擎重新使用了webforms,但是视图具有比典型webforms更简单的控制堆栈,这有很大帮助,甚至没有提到替代视图引擎。

the hit for 'first view' comes from having to JIT a large set of classes/objects that are used in your project and it's first page.

“第一个视图”的命中来自于必须JIT在项目中使用的大量类/对象,它是第一页。

#1


3  

MVC still uses the same ASP.NET framework as Web Forms, so you are probably going to see similar behavior, regardless.

MVC仍然使用与Web窗体相同的ASP.NET框架,因此您可能会看到类似的行为,无论如何。

The long first load time is because your project's build output is still just IL code that needs to be compiled into native code by the JIT compiler before executing. Any code changes that you make will cause the previously cached native code for your app to be discarded, so the JIT has to recompile. Naturally, the larger your project, the longer it's going to take for the JIT to process it.

首次加载时间较长是因为项目的构建输出仍然只是IL代码,需要在执行之前由JIT编译器编译为本机代码。您所做的任何代码更改都将导致您的应用程序的先前缓存的本机代码被丢弃,因此JIT必须重新编译。当然,项目越大,JIT处理它的时间就越长。

#2


2  

You will see similar load times in both environments.

您将在两种环境中看到类似的加载时间。

In both environments, if your site gets large you should pre-compile your site before deployment. This will eliminate the performance drag on first page load.

在这两种环境中,如果您的站点变大,您应该在部署之前预先编译您的站点。这将消除首页加载时的性能拖累。

#3


1  

There are a lot of things thhat can be done to improve performance, the enhancements in order to provide for a separation of concerns in MVC apps can help a lot. Though the default view engine re-uses webforms, Views have a far simpler control stack than typical webforms, which helps a lot, not to even mention alternative view engines.

有很多事情可以做,以提高性能,为了提供MVC应用程序中的关注点分离的增强可以帮助很多。虽然默认视图引擎重新使用了webforms,但是视图具有比典型webforms更简单的控制堆栈,这有很大帮助,甚至没有提到替代视图引擎。

the hit for 'first view' comes from having to JIT a large set of classes/objects that are used in your project and it's first page.

“第一个视图”的命中来自于必须JIT在项目中使用的大量类/对象,它是第一页。