Rails routes and site performance

2019-07-05 16:47发布

问题:

Is there a direct correlation on site speed with the number of namespaces / routes in the routes.rb file of a Rails Application?

I am handling a fairly large application with more than 30 disparate models/entities and most of these resources have their own routes.

回答1:

I don't have a citation† but DHH recently said that 37signals' Highrise application has thousands of routes, so it is possible to scale the routes if you have a big enough box to run your application on.

† I think it may have been during his recent RailsConf keynote, when he was talking about the new router API in Rails 3.



回答2:

the number of routes will affect the memory overhead - it's why rails no longer defines formatted routes out the box: http://ryandaigle.com/articles/2008/11/27/what-s-new-in-edge-rails-no-more-formatted-routes

It's not unusual to have 30 or so routes though

As for whether or not this will affect the speed of your app, it's difficult to say - are you using metric-fu or anything like that?