Docker for Mac, VirtualBox and Docker performance

Oleksii Chekulaiev
Docksal Maintainers Blog
2 min readJun 14, 2018

--

I have one really heavyweight Drupal project. With the regular setup of Docksal plus NFS-mapped volumes the homepage load time is almost 2 minutes! This is unacceptable of course. So I changed volumes to Unison, and it slashed the load time dramatically, to 19 seconds. 19 seconds is still slow when you do development, but it is bearable. There was nothing more I could really do to make this site load even faster. It is just a heavyweight site.

Or maybe was there?..

I mostly use Docker for Mac. Could VirtualBox be faster? I changed DOCKER_NATIVE to 0, started VM (fin created it), imported my database and hit refresh in Opera with anticipation. Since it was the same project, same Docksal configuration (with Unison volumes) I expected better load times. To my displeasure, the load time was much higher now — 40 seconds!

I used fin diagnose to see containers memory and CPU usage, and noticed that my DB container was using almost 100% CPU during homepage load. The database on this project is pretty big, so CPU seemed to be a bottleneck here. It was then, when I recalled, that by default Docker for Mac uses 2 CPU cores (I actually have it set to 4), while boot2docker VM uses 1 core by default.

So I stopped the VM, opened VirtualBox UI and changed available cores to 4.

Then I started the project again and results were much better now! So keep that in mind for database-heavy projects.

At the same time the same project in VirtualBox when Unison is used was not showing any dramatic difference. Homepage load time was 17–19 seconds, which is at best only 10% better than the same project with Unison volumes on Docker for Mac.

Conclusions

  1. If you use VirtualBox with Docker, you might want to increase the number of processors.
  2. When Unison volumes are used with Docksal, there is almost no difference in performance between Boot2Docker (VirtualBox) and Docker for Mac.

--

--