如何提高ASP ?NET MVC应用程序性能?


当前回答

以下是要做的事情

内核模式缓存 管道模式 移除未使用的模块 runAllManagedModulesForAllRequests 不要使用wwwroot 删除未使用的视图引擎和语言

其他回答

这似乎是显而易见的,但是在生产环境中以及在性能分析期间以发布模式而不是调试模式运行站点。释放模式要快得多。调试模式可以在您自己的代码中隐藏性能问题。

另外,如果你使用NHibernate,你可以为查询打开和设置二级缓存,并添加到查询范围和超时。并且有踢屁股的EF, L2S和NHibernate分析器- http://hibernatingrhinos.com/products/UberProf。这将有助于调优您的查询。

我做了上面所有的答案,但还是没有解决我的问题。

最后,我解决了我的网站加载缓慢的问题,在发布配置文件PrecompileBeforePublish设置为真。如果你想使用msbuild,你可以使用这个参数:

 /p:PrecompileBeforePublish=true

这真的很有帮助。现在我的MVC ASP。NET加载速度快10倍。

使用捆绑和缩小还可以帮助您提高性能。它基本上减少了页面加载时间。

如果您正在运行您的ASP。NET MVC应用程序在Microsoft Azure (IaaS或PaaS)上,然后至少在第一次部署之前执行以下操作。

Scan your code with static code analyzer for any type of code debt, duplication, complexity and for security. Always enable the Application Insight, and monitor the performance, browsers, and analytics frequently to find the real-time issues in the application. Implement Azure Redis Cache for static and less frequent change data like Images, assets, common layouts etc. Always rely on APM (Application Performance Management) tools provided by Azure. See application map frequently to investigate the communication performance between internal parts of the application. Monitor Database/VM performance too. Use Load Balancer (Horizontal Scale) if required and within the budget. If your application has the target audience all over the globe, then use Azure Trafic Manager to automatically handle the incoming request and divert it to the most available application instance. Try to automate the performance monitoring by writing the alerts based on low performance.