geerlingguy / jeffgeerling-com

Drupal Codebase for JeffGeerling.com
https://www.jeffgeerling.com
GNU General Public License v2.0
40 stars 2 forks source link

Test and benchmark other local development environments #18

Closed geerlingguy closed 4 years ago

geerlingguy commented 4 years ago

After episode 6, Oliver Davies mentioned the Symfony Local Server, and I thought it might be time—especially since the live stream software eats my little MacBook Pro's CPU for lunch—to try out a faster local dev environment.

Because I'm one for data, I'd rather test things out with some 'official' timings, like how long it takes to install Drupal, to run a cache rebuild, and to migrate things.

So here's a table with some data:

Dev Environment Drupal install (drush) 1st / page load (curl) Cache rebuild (drush)
Current / custom Docker 71.16s 6.36s 7.25s
Current / with NFS (#22) 30.92s 2.80s 5.09s
Current / with bg-sync (#22) 35.54s 1.20s 3.50s
Current / with docker-sync (#22) 35.84s 1.58s 3.51s
Symfony Local Server 71.33s 2.78s 4.25s
DDEV Local 63.24s 4.16s 9.20s
Drupal VM 23.45s 2.83s 2.56s

Commands run:

# Drupal install (drush)
time drush site:install minimal --db-url="mysql://drupal:$DRUPAL_DATABASE_PASSWORD@$DRUPAL_DATABASE_HOST/drupal" --site-name="Jeff Geerling" --existing-config -y

# Home page load (curl)
time curl http://localhost/

# Cache rebuild (drush)
time drush cr
geerlingguy commented 4 years ago

For Drupal VM I'm adding it as a composer dev dependency: http://docs.drupalvm.com/en/latest/deployment/composer-dependency/

geerlingguy commented 4 years ago

It's strange, I would've thought the Symfony Local server would be a lot faster, but it seems it was as slow as the custom Docker environment! I made sure to test with opcache enabled and disabled. With it disabled the UI is very slow. With it enabled the UI is faster. CLI speed seemed to not be impacted even if I turned everything off and set it enabled on cli (and confirmed via drush php-ev).

Drupal VM is the winner—once it's up and running. But it takes a minute or two to get started (versus only a few seconds for the others).

So I'm kind of at a crossroads here. I think I'll end up sticking with the custom docker setup, mostly because that doesn't require me to have a fully-tweaked and operational local PHP 7.3 environment running (which could make it more annoying to work on in different environments, especially if I want to work from a PC running Linux or Windows here and there).

geerlingguy commented 4 years ago

I filed some PRs for the other environments (DDEV, Drupal VM, Symfony Local) and closed them so that I have the reference point if I should choose to use one of them in the future.

Honestly, Drupal VM felt the fastest (by a good margin—especially for installation), but it also feels very heavyweight... and means that I can't have the exact same setup in CI (and eventually in production, if I use Docker) as I have locally... which I don't particularly enjoy.

geerlingguy commented 4 years ago

So closing this issue and I might have some good material for a blog post at some point, otherwise I'll leave this as-is.

Also note: https://github.com/geerlingguy/drupal-the-fastest

geerlingguy commented 4 years ago

While working on #22, I decided to test things out with NFS. Might also try docker-sync or one of the other sync methods too.

geerlingguy commented 4 years ago

TIL, you can add a docker-compose.override.yml file and it will be merged into the structure of the main docker-compose.yml file. You an also specify multiple compose files with -f and they'll be merged. That's how I'll get things going for CI and local with different volume mounts.

geerlingguy commented 4 years ago

Heh, I also attempted a Drupal install without cached/delegated on the volume mount, and not only did it consume 5% of my battery (and 200% of my CPU), it took a whopping 5 minutes!

geerlingguy commented 4 years ago

Well, pretty happy now. I'll be summing this stuff up in a blog post.

gitressa commented 4 years ago

Thanks for the thorough bench-marking. I compared plain vanilla installs of Drupal 8 between ddev and Lando. They seem to perform almost at the same speed, except for Lando start, which takes 60 seconds, compared to ddev's 15 seconds.

System

Get the Drupal 8 code with Composer

$ time composer create-project drupal/recommended-project drupalddev
real  0m6,357s

Lando

$ time lando init --source cwd --recipe drupal8 --webroot web --name drupallando
real  0m0,334s

$ time lando start
real  1m1,861s

$ time drush site:install --db-url=mysql://drupal8:drupal8@database/drupal8 -y
real  0m16,639s

$ time curl http://drupallando.lndo.site
real  0m1,452s

$ time drush cache:rebuild
real  0m2,719s

ddev

$ time ddev config --project-type drupal8
real  0m0,040s

$ time ddev start
real  0m14,813s

$ time ddev exec drush site:install -y
real  0m15,121s

$ time curl http://drupalddev.ddev.site
real  0m1,325s

$ time ddev exec drush cache:rebuild
real  0m4,177s
gitressa commented 4 years ago

I just upgraded to the latest Lando v3.0.0-aft.2, and the first lando start of a new instance is 50% faster, down to half a minute. Just to clarify, I haven't timed the very first start after installing Lando itself, where PHP, MySQL and the rest of the software is downloaded. Here are the values for easier comparison, all times are in seconds:

Tool First start Start site:install 1st / page load (curl) cache:rebuild
ddev 1.13.1 11.3 11.2 15.1 1.3 4.2
Lando v3.0.0-rc.23 61.9 7.6 16.6 1.5 2.7
Lando v3.0.0-aft.2 28.6 9.3 16.5 1.5 2.7
geerlingguy commented 4 years ago

@gitressa - Thanks so much for adding these details here! It may be time to revisit my project https://github.com/geerlingguy/drupal-the-fastest and update things again for 2020.

gitressa commented 4 years ago

You're welcome @geerlingguy :-) Revisiting and updating the bench-marking project would certainly be of great interest to me, and surely many others.

I noticed that the Lando script also downloads Drush 10, which will take around 20 seconds longer, compared to for example ddev:

# Install Drush, then install Drupal inside Lando.
lando composer require drush/drush

https://github.com/geerlingguy/drupal-the-fastest/blob/master/methods/lando.sh https://github.com/geerlingguy/drupal-the-fastest/blob/master/methods/ddev-local.sh

Lando does come with Drush 8.3.2 out of the box, but perhaps Drush wasn't included, when the lando.sh script was initially created?

I have created a PR which updates Lando and removes Drush installation https://github.com/geerlingguy/drupal-the-fastest/pull/9.