Route is too many. more than 4000. help...
laravel version: 5.8.27.
PHP: ^7.3
Hello, In our project we have too many routes which cause performance issue and memory issue. We use Route::getRoutes(); to find out how many route do we have and the result "allroutes" shows 4498 routes. and in the future it might grows to 5000 routes. And then we use barryvdh/laravel-debugbar to see how is the different memory will be used when we have so many routes Loaded.
Result: around 200 Routes : total memory usage is 3MB around 4498 Routes: total memory usage is 8MB
We Have 5 MB Used In Routes!!
So the problem is how should we deal with it. Currently I only have few ways to try.
- Upgrade to laravel ^7.x Since Symfony's Router have a huge improvement. and Laravel integrate it in version 7.x
- Use PHP 7.4 preload Feature. to load hot classes in to memory.
- Don't load every route in every request. only load it when we need it. (This one i guess need to change a lot of code.)
I don't know. Is there any options better than my thoughts. If you can tell me. I'm REALLY Appreciate it.
Please or to participate in this conversation.