[SOLVED] Is Laravel really this slow?


I just started using Laravel. I’ve barely written any code yet, but my pages are taking nearly a second to load!

laravel timings

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?


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/"

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.

Answered By – mpen

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *