5

I am working with Attribute Routing in asp.net mvc 4 web application. It is a single application that supports 15 different cultures and 20+ languages. The result of this, my routing table is extremely large, over 3000 routes. The main reason for so many routes is because the routes are localized per language. The follow on effect of this is that it results in a slow route lookup and in turn poor performance of the site.

I am looking at ways to improve performance. So looking for tips. Unfortunately I can't alter my routing structure due to business restrictions. The main reason I have so many routes is due to translations - there is an entry in the routing table for each language. Any way to avoid this?

Also, I note in the routing table, entries for POST methods - is this required? Can it be avoided to have entries in routing table for POST's?

Is there any form of caching that can be included to avoid routing table lookup and instead read from memory?

Any performance optimization tips of Attribute Routing or with routing in general would be excellent.

amateur
  • 43,371
  • 65
  • 192
  • 320
  • Take a look at http://superscribe.org/ for some pretty cool graph based routing. – DavidG Jul 06 '14 at 20:52
  • Thanks but I would prefer to optimise rather than change if possible. – amateur Jul 06 '14 at 22:42
  • 2
    There's a rather old post from one of the original Stack Overflow developers about optimizing MVC3 routing. I'm not sure if it would stil apply in MVC4 specifically, or if you would even benefit from it. http://samsaffron.com/archive/2011/10/13/optimising-asp-net-mvc3-routing. I would highly recommend measuring where your slow downs are before you start "optimizing" though. – Steven V Jul 07 '14 at 19:49
  • It would be a nice feature if we can set the RouteTable.Routes static property to a new instance of RouteCollection which we can override its method GetVirtualPath & GetEnumerator. Unfortunately those method are not virtual, otherwise you can make it as a dictionary or something to make a smarter lookup by language & culture in the path. – Van Thoai Nguyen Jul 29 '15 at 07:03

1 Answers1

1

This is a complicated question, as no one clearly knows how complicated your route table is and what business restrictions you are facing when re-organize your web application. So what I can do is prompting some options for you to explore:

The suggestions above can be based on locale or language. For example, when you visit www.apple.com, you can find their local website like Canada or Italy are set up like virtual directory "www.apple.com/ca" or "www.apple.com/it".

Hope this helps! Henry

Henry Liang
  • 137
  • 1
  • 7