How do you improve your ASP.NET MVC application performance?
See Question&Answers more detail:osA compiled list of possible sources of improvement are below:
General
Caching
CompiledQuery.Compile()
recursively avoiding
recompilation of your query
expressionsOutputCacheAttribute
to save unnecessary and action
executionsActionResult
methods if necessaryRouteName
to organize your routes and then use it to generate
your links, and try not to use the expression tree based ActionLink method. PartialViews
, avoid render it xxxx times: if you
end up calling the same partial 300 times in the same view, probably there is something
wrong with that. Explanation And BenchmarksRouting
Use Url.RouteUrl("User", new { username = "joeuser" })
to specify routes. ASP.NET MVC Perfomance by Rudi Benkovic
Cache route resolving using this helper UrlHelperCached
ASP.NET MVC Perfomance by Rudi Benkovic
Security
DAL
Load balancing
Utilize reverse proxies, to spread the client load across your app instance. (Stack Overflow uses HAProxy (MSDN).
Use Asynchronous Controllers to implement actions that depend on external resources processing.
Client side
Global configuration
If you use Razor, add the following code in your global.asax.cs, by default, Asp.Net MVC renders with an aspx engine and a razor engine. This only uses the RazorViewEngine.
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
Add gzip (HTTP compression) and static cache (images, css, ...) in your web.config
<system.webServer>
<urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/>
</system.webServer>
<pages buffer="true" enableViewState="false">