How do you improve your ASP.NET MVC application performance?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A compiled list of possible sources of improvement are below:
General
Caching
CompiledQuery.Compile()recursively avoiding
recompilation of your query
expressions
content using
OutputCacheAttributeto save unnecessary and action
executions
ActionResultmethods if necessaryRouteNameto organize your routes and then use it to generateyour links, and try not to use the expression tree based ActionLink method.
PartialViews, avoid render it xxxx times: if youend up calling the same partial 300 times in the same view, probably there is something
wrong with that. Explanation And Benchmarks
Routing
Use
Url.RouteUrl("User", new { username = "joeuser" })to specify routes. ASP.NET MVC Perfomance by Rudi BenkovicCache route resolving using this helper
UrlHelperCachedASP.NET MVC Perfomance by Rudi BenkovicSecurity
authentication ticket
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
suggestions to improve performance
reload based in timeouts.
is a expensive activity. Deferring to the client side your server from an
unnecessary burden, and allows you to work with graphs locally without make a new
request (i.e. Flex charting, jqbargraph, MoreJqueryCharts).
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">