Some tips for ASP.NET MVC performance tunning, that really works. From these slides I recommend:
- jetBrains dotTrace – for performance tunning and dot.net app and webs tracing
- Apache Bench (ab.exe in bin directory) from Apache web server – it’s simplier to setup tests than WCAT
- use LINQ compiled queries
- Cache links, it takes very much time every time you render page:
I created this two extensions for me (based on code from slides):
public static string RouteUrlCached(this UrlHelper helper, string routeName, RouteValueDictionary routeDictionary)
{
string key = "RouteUrl" + routeName + String.Join("!", routeDictionary.Keys.ToArray()) + String.Join("!", routeDictionary.Values.Select(x => x.ToString()).ToArray());
string ret = CacheHelper.GetFromCache<string>(key, System.Web.HttpContext.Current);
if (string.IsNullOrEmpty(ret))
{
ret = helper.RouteUrl(routeName, routeDictionary);
CacheHelper.AddToCache(key, ret, System.Web.HttpContext.Current);
}
return ret;
}
and
public static string RouteLinkCached(this HtmlHelper htmlHelper, string linkText, RouteValueDictionary routeDictionary)
{
string key = "RouteLink" + linkText + String.Join("!", routeDictionary.Keys.ToArray()) + String.Join("!", routeDictionary.Values.Select(x=>x.ToString()).ToArray());
string ret = CacheHelper.GetFromCache<string>(key, System.Web.HttpContext.Current);
if (string.IsNullOrEmpty(ret))
{
ret = htmlHelper.RouteLink(linkText, routeDictionary);
CacheHelper.AddToCache(key, ret, System.Web.HttpContext.Current);
}
return ret;
}
Other sources I used when tuning my app: