Reputation: 1283
I was going to port a custom webstore application to Laravel, so that it's new, shiny and is a pleasure to support. After spending a couple of hours on setting up the framework and starting to port the main layout, I decided to test how it performs. I have installed a copy of my original app and the ported part to laravel, where I set up a Section model with a translation from dimsav/laravel-translatable and output the main navigation with Section::all() of about 30 sections.
I was shocked when I saw the result of simple observation of the Netwrok tab in Firebug:
For my laravel setup it takes roughly 360ms to render just the above. I imagine how much the response time will be when the whole page would be ported...
For the original app it takes ~30ms to serve the whole homepage with the same navigation, popular products, submenus, footer navigation, checking cart contents etc.
Both on the same virtual server and even using the same database, no caching in either.
I profiled the code to discover any issues, but all I found is that
Just to confirm, an empty laravel app responds in about 17ms.
Am I missing somethign here? I imagined there would be some performance degrade when moving to the framework, but (assuming the reponse time will increase for the complete setup, so I would expect ~20x) 20x seems crazy. Are these time normal for laravel and is there any big win from using caching (Redis for instance) or any other optimization techinques? I wonder if there actually are any except for caching?
Upvotes: 4
Views: 2043
Reputation: 1029
On a $5 VPS instance from Digital Ocean with deployed apps I see response times:
512MBMemory 1 Core Processor 20GBSSD Disk
Lumen 60-120 ms Laravel 100-300 ms
These particular apps do not caching. The 100-150 ms response time seems to be the base response time with laravel for a view that has already been compiled. Obviously having slow queries will increase that.
Adding redis or memcached will dramatically degrease your response time compared to going to the db in most cases getting pretty close to the base response time of laravel.
You should make sure to set APP_DEBUG to false in your .env file:
# /.env
APP_ENV=production
APP_DEBUG=false
Run php artisan optimize
Upvotes: 1