8000 Too many Routes ? · Issue #16343 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Too many Routes ? #16343

New issue

Have a question about this pro 8000 ject? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AntoineLemaire opened this issue Oct 26, 2015 · 10 comments
Closed

Too many Routes ? #16343

AntoineLemaire opened this issue Oct 26, 2015 · 10 comments
Labels

Comments

@AntoineLemaire
Copy link

Is there a limit with the number of routes we can create ?

My application is using JMSI18nRoutingBundle, and we have more than 30 locales.

JMS create in app/cache/prod/appProdUrlGenerator.php all routes for each locales in $declaredRoutes

I opened a ticket an issue on JMSI18nRoutingBundle (link), but it seems the issue is the same in symfony without JMSI18nRoutingBundle.

I just try to create a basic project, with 20 controllers, and foreach of them, on function with 2000 routes.

    /**
     * @Route("/1", name="homepage1")
     * @Route("/2", name="homepage2")
     * @Route("/3", name="homepage3")
    [...]
     * @Route("/2000", name="homepage2000")
     */
    public function indexAction(Request $request)
    {
        echo $this->generateUrl('homepage1');
        exit;
    }

When number of routes approaches 32 760, echo $this->generateUrl('homepage1'); is failing :

Unable to generate a URL for the named route "homepage1" as such route does not exist.
@Tobion
Copy link
Contributor
Tobion commented Oct 26, 2015

Please provide a fork of symfony-standard that reproduces the problem

@AntoineLemaire
Copy link
Author

As asked : https://github.com/AntoineLemaire/symfony-standard/commits/2.8

(Don't know why, but this time, route homepage1 was working, but homepage20_2000 don't)

Image of Issue

@jakzal jakzal added the Routing label Oct 28, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Oct 30, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Oct 30, 2015
@jelte
Copy link
jelte commented Oct 30, 2015

Just checked this a bit, and it seems weird to say the least.
when you check appDevUrlGenerator.php and dump the self::$declaredRoutes you only got 7265 routes in there.
Seems you're hitting some limit in php arrays, when I split the self::$declaredRoutes up into blocks of 5000 it works.

Check #16386

jelte pushed a commit to jelte/symfony that referenced this issue Oct 30, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Oct 30, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Oct 30, 2015
@ghost
Copy link
ghost commented Nov 2, 2015

Known PHP issue for PHP5.6+ but it is only fixed in PHP7+.
https://bugs.php.net/bug.php?id=68057

[2015-03-23 17:51 UTC] bwoebi@php.net
Fixing this is an ABI break (so not really possible for 5.6.x). It's fixed in master (PHP 7+) though.

@Pierstoval
Copy link
Contributor

As a potential issue, can the cached urlGenerator retrieve the routes using php5.5 generators instead of saving all datas in an array? Maybe it would save some memory? If it's not fixed in php5.6 maybe it could be a nice idea 😕 ?

@SoboLAN
Copy link
SoboLAN commented Nov 2, 2015

I can reproduce the bug mentioned by @JHGitty , which is probably the cause for your issue.

So basically you can't have arrays with more than 2^15 elements in PHP 5.6. That seems like a really critical bug to me because I think 2^15 is very small in 2015...

@mvrhov
Copy link
mvrhov commented Nov 2, 2015

Well they marked it as won't fix. So the author has two choices. downgrade to 5.5, or upgrade to upcoming 7.0. IMO, it's rare for one to have that many routes.
@Pierstoval: That won't work. AS sf 2.3 requires php 5.3

@AntoineLemaire
Copy link
Author

@mvrhov Yep, I'm waiting for 7.0 and I'll see with it.
For us, a other way to "fix" this problem pending, is to split our application with other server, and divide locales on each one, 15 for one, 15 for the other, so number of routes 10000 does not exceed 20 000

@SoboLAN
Copy link
SoboLAN commented Nov 2, 2015

@AntoineLemaire That huge number of routes does seem excessive, I'm sure that in 99.9% of situations, they can be significantly reduced.

  • Why don't you have the locale as a route parameter ? Something like /my/route/{locale} .
  • Or maybe split your project using the MicroServices architecture model.
  • Some other solution ?

jelte pushed a commit to jelte/symfony that referenced this issue Nov 2, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 2, 2015
@jelte
Copy link
jelte commented Nov 2, 2015

@AntoineLemaire I've updated my fix (#16386) for this so it has a slightly different behaviour in php 5.6 in the case you have a large number of routes.
Hopefully someone approves it and it gets merged.

jelte pushed a commit to jelte/symfony that referenced this issue Nov 2, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 2, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 2, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 5, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 5, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 5, 2015
jelte pushed a commit to jelte/symfony that referenced this issue Nov 5, 2015
nicolas-grekas added a commit that referenced this issue Nov 25, 2015
This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #16386).

Discussion
----------

Bug #16343 [Router] Too many Routes ?

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16343
| License       | MIT
| Doc PR        | N/A

Seems there is an issue when you have more than 7265 routes declared,
The routes are generated into the cached appDevUrlGenerator.php but php only loads the last 7265 elements of the array.

Commits
-------

0113ac3 Bug #16343 [Router] Too many Routes ?
nicolas-grekas added a commit that referenced this issue Nov 26, 2015
* 2.3:
  Always enable clock-mock for HttpFoundation
  [ClassLoader] Fix parsing namespace when token_get_all() is missing
  Bug #16343 [Router] Too many Routes ?
nicolas-grekas added a commit that referenced this issue Nov 26, 2015
* 2.7:
  Always enable clock-mock for HttpFoundation
  [ClassLoader] Fix parsing namespace when token_get_all() is missing
  Bug #16343 [Router] Too many Routes ?
  [Debug] Ensure class declarations are loaded only once
nicolas-grekas added a commit that referenced this issue Nov 26, 2015
* 2.8:
  Always enable clock-mock for HttpFoundation
  [ClassLoader] Fix parsing namespace when token_get_all() is missing
  Bug #16343 [Router] Too many Routes ?
  Fixes the stack traces of the deprecation logs
  fix unused variable warning
  [Translation][Form] Do not translate form labels and placeholders when 'translation_domain' is false
  add composer exclude-from-classmap for new 2.8 components
  [Yaml] sync changelog and upgrade files
  [Debug] Ensure class declarations are loaded only once
  Minor design tweaks for the Logs and Doctrine profiler panels

Conflicts:
	UPGRADE-2.8.md
This was referenced Nov 30, 2015
This was referenced Dec 26, 2015
ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018
* 2.8:
  Always enable clock-mock for HttpFoundation
  [ClassLoader] Fix parsing namespace when token_get_all() is missing
  Bug symfony#16343 [Router] Too many Routes ?
  Fixes the stack traces of the deprecation logs
  fix unused variable warning
  [Translation][Form] Do not translate form labels and placeholders when 'translation_domain' is false
  add composer exclude-from-classmap for new 2.8 components
  [Yaml] sync changelog and upgrade files
  [Debug] Ensure class declarations are loaded only once
  Minor design tweaks for the Logs and Doctrine profiler panels

Conflicts:
	UPGRADE-2.8.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants
0