Blog

Welcome to my blog, a dynamic space where I delve into the world of technology. Here, I not only share an array of tools, tips, and techniques that I’ve gathered over the years but also explore diverse tech topics. Additionally, this blog serves as a personal canvas, reflecting the various events and experiences from my life. It's a blend of professional insights and personal stories, all aimed at enriching your understanding of the ever-evolving tech landscape.

Faster Drupal Development on Linux

drupal linux Jan 23, 2020

Local Drupal development has moved to docker based environments with solutions like Lando and DDEv. With these tools, it’s fast and easy to spin up a local environment and manage many projects. The days of MAMP and WAMP are (long) gone.

Here’s the problem, Mac OS is the dominant development platform for Drupal developers, and Docker runs terribly on it. Docker interacts differently with macOS than it does with Linux. The source code on the host computer is shared with Docker containers. The multiple layers of communication between Docker and the macOS file system make file-sharing very slow. While Docker's direct access to the Linux file system makes it very fast. This video, Improving Docker Desktop File Sharing Performance, from DockerCon 18 describes this issue in detail.

The file-sharing performance issue became apparent when working with a colleague to set up a new Drupal 8 website build. I was shocked to see the local build process taking over 8 minutes on my colleague's computer and less than 30 seconds on my computer.

Benchmarks

In an unscientific way, with some help from my friends, I tested the build process on a few Macs and Linux computers with different hardware specs. Each computer had Docker and Lando installed. The website is a Drupal 8 Standard profile with Acquia's BLT. The test is simple, run the BLT artifact build, blt artifact:build

Below are the results of this test.

Computer Specs OS Artifact:build
ThinkPad T420 (2011) i5 (2 cores), 8GB RAM, SSD Linux (Endevour OS) 20 seconds
Custom Build (2020) Ryzen i7 (8 cores), 32GB, SSD Linux (Endevour OS) 7 seconds
Macbook Air (2018) i5 (2 cores), 8GB RAM, SSD macOS Catalina 8+ minutes
MacBook Pro (2015) i7 (4 cores), 16GB RAM, SSD macOS Mojave 6 minutes

Solutions

There are some potential solutions. Lando has an undocumented Mac-only feature called "Turbo Mode". Reviewing the issue thread, there are mixed results with this implementation. Turbo Mode had little impact on my test case shaving off 30 to 60 seconds. A 5% to 10% improvement is good, but when comparing it to performance on Linux, there is no practical improvement. Others have seen better improvements with Turbo Mode. This approach is easy to implement and worth exploring, but Turbo Mode hasn't made it's way into Lando as a supported feature. Use with caution.

Some tweaks can be made to your Docker configuration. Increasing the default RAM usage from 2GB to 4GB is a starting point. You can also limit the number of shared folders Docker watches, by default, the entire /Users folder is included. I tested the memory upgrade and limited the shared folders to only the necessary application folders. Similar to the results with Turbo Mode, they were minimal for my test case. You may have more promising results. There are many online resources with recommendations to improve performance, search "Docker Mac performance".

The beauty of using Lando is simplicity, which starts to diminish with lots of OS based tweaks. I suspect more research and testing could result in better performance on Mac. BUT, using Linux for Drupal development with Docker will get you the best performance by far, with ease. It's that simple.