DEV Community

Kay Gosho
Kay Gosho

Posted on

If you feel slow with Mac + Docker + Laravel, the reason may be Laravel Debugbar

I researched the reason why my development environment with Mac + Docker + Laravel.

My conclusion is disabling Laravel Debugbar. It increases the app speed about 3 times faster.


The response time was 2.6s and now 0.85s, so approximately 3x faster.

The considerable reason

Laravel Debugbar creates a log file under storage/debugbar/ like Xc590ef0f5b368cf34373093291b95147.json per request.

This is a log with a request.

~> find storage/debugbar -type f | wc -l
Enter fullscreen mode Exit fullscreen mode

Within this file, we can view the stack trace of app.

/api has a lot of middlewares so the file size is terribly bigger.
We can find over 24000 Line as formated json.

~> cat storage/debugbar/X2e75040e69de9cae006253a48fd5276c.json | jq . | wc -l
Enter fullscreen mode Exit fullscreen mode

This time size of the file was about 500KB.

~> ls -lh storage/debugbar/X2e75040e69de9cae006253a48fd5276c.json
-rw-r--r--  1 kazuya-mac  staff   508K  3 27 18:32 storage/debugbar/X2e75040e69de9cae006253a48fd5276c.json
Enter fullscreen mode Exit fullscreen mode

As we know, when we run Docker on Mac, writing file is terribly slow.
So stopping the logging make app faster greatly.


I would like to use Laravel Debugbar itself, so I am looking for the way to improve the performance of Laravel Debugbar.
I think the following way should be a candidate.

  • Forward logs via HTTP
  • Set log output directory to directory other than storage/logs.
  • Do not mount storage/ as Docker volume (Is it possible not to mount with Docker partially...?)

We may make the Laravel app faster, except for Debugbar with log output directory.

Off topic

This is useful.

#!/usr/bin/env fish

while true
    curl -H 'Accept-Encoding: gzip' -Ss -LI -o /dev/null -w \
        '%{http_code} in %{time_total} seconds, %{content_type} as %{size_download} \n' \
    sleep 1
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

tiagodamascena profile image
Tiago Damascena

It's been 2 years since this was posted but I will let the solution I have founded here to help anyone with the same issue, setting the Nginx and PHP volumes to cached and rebuilding the containers reduced my response times from 2.7s to 0.7s without need to do any change on Laravel.

aswinveepey profile image

Were you able to resolve it?

acro5piano profile image
Kay Gosho

Yes, disabling Laravel Debugbar resolved the issue in my case. 3x faster...!

aswinveepey profile image

Sorry. Wrong question. I was wondering if you were able to get Debugbar work faster with Docker+Laravel (as mentioned in your ToDo)? I'd like to use Debugbar for certain use cases. But the slowness is a hindrance.

Thread Thread
acro5piano profile image
Kay Gosho

Sorry for misunderstanding.

No, I couldn't finally get Debugbar work faster in Docker environment.