Yii2 urlManager performance

We are developing a CMS and we have a lot of modules in the application. We have to create about

100 or more url rules. As this is mentioned in documentation, too many url rules can affect performance.

I want to know how many rules is safe to use, and How many rules will affect performance?

Are there any benchmarks about urlmanager performance?

im also working on same kind of project there are maximum 15 modules is it really affect performance.?

Asking “how many rules is safe to use” is a bit like asking “how many lines of PHP code is safe to execute” or “how many bytes of data is safe to retrieve from the database” per request. There’s no general rule for this. I create as many rules as needed by my application then measure the performance myself and optimize routing by

  • creating custom URL rule classes

  • using more clever regular expressions

  • using yii\web\GroupUrlRule

when required.

Any ideas on how to measure performance of UrlManager?

Yii’s built-in profiling feature and the debug toolbar can give you some numbers to start with.

Standard tools like XHProf or Xdebug can be used for more detailed information.

For large-scale applications, where small performance improvements really count, you (or your system administrator) will probably use some dedicated tools to monitor your servers’ load and response time but I’m not really an expert on that.