I just started using Laravel. I've barely written any code yet, but my pages are taking nearly a second to load!
This is a bit shocking to me when my framework-less apps and NodeJS apps take ~2ms. What's Laravel doing? This isn't normal behaviour is it? Does it need some fine-tuning?
you have to ensure any recursive query not exist. Make efficient data cache. Check queries takes a little time to execute. If you are using different network connections with your Redis, database, queue then make sure those connections are well optimized and taking a little time to connect and serve data.
Due to their simpler structure in comparison to Laravel, Core PHP scripts are faster to execute on the condition that the codes are clearly and concisely written. Web developers can reuse Core PHP scripts in similar projects. Laravel has a layered structure, therefore, code lines will be executed a bit slower.
WordPress depends on plugins for most of the functionalities, while Laravel has built-in features for validation, authorization, inversion of control, etc. Too many plugins can substantially slow down the page loading speed of WordPress sites, while Laravel pages load faster due to easily manageable automated tasks.
The PHP scripting language has a variety of frameworks with robust technical capabilities such as – Laravel, Symfony, CodeIgniter, Yii 2, Phalcon, CakePHP, Zend, Slim, etc. Yet, Laravel has retained the top position on top PHP MVC frameworks.
Laravel is not actually that slow. 500-1000ms is absurd; I got it down to 20ms in debug mode.
The problem was Vagrant/VirtualBox + shared folders. I didn't realize they incurred such a performance hit. I guess because Laravel has so many dependencies (loads ~280 files) and each of those file reads is slow, it adds up really quick.
kreeves pointed me in the right direction, this blog post describes a new feature in Vagrant 1.5 that lets you rsync your files into the VM rather than using a shared folder.
There's no native rsync client on Windows, so you'll have to use cygwin. Install it, and make sure to check off Net/rsync. Add C:\cygwin64\bin
to your paths. [Or you can install it on Win10/Bash]
Vagrant introduces the new feature. I'm using Puphet, so my Vagrantfile looks a bit funny. I had to tweak it to look like this:
data['vm']['synced_folder'].each do |i, folder| if folder['source'] != '' && folder['target'] != '' && folder['id'] != '' config.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{folder['id']}", type: "rsync", rsync__auto: "true", rsync__exclude: ".hg/" end end
Once you're all set up, try vagrant up
. If everything goes smoothly your machine should boot up and it should copy all the files over. You'll need to run vagrant rsync-auto
in a terminal to keep the files up to date. You'll pay a little bit in latency, but for 30x faster page loads, it's worth it!
If you're using PhpStorm, it's auto-upload feature works even better than rsync. PhpStorm creates a lot of temporary files which can trip up file watchers, but if you let it handle the uploads itself, it works nicely.
One more option is to use lsyncd. I've had great success using this on Ubuntu host -> FreeBSD guest. I haven't tried it on a Windows host yet.
I now use Docker + DevSpace. DevSpace has a sync feature that is 1000x faster than Docker's mounted directories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With