scotch-io / scotch-box

Scotch Box is a preconfigured Vagrant Box with a full array of LAMP Stack features to get you up and running with Vagrant in no time.
http://box.scotch.io
2.7k stars 548 forks source link

Can the performance be enhanced? #395

Closed gitressa closed 5 years ago

gitressa commented 5 years ago

I have bench-marked Scotch Box by downloading and installing Drupal 8, notorious for having many files. Interestingly, with NFS enabled, downloading and unpacking is much slower, whereas installing is faster. Without NFS, downloading and installing takes about the same time.

Also, after installation with NFS enabled, Scotch Box is much faster between clicking and the page being ready (~1 second), whereas without NFS it takes 2-3 seconds. Perhaps the file system works slower with NFS enabled, but database write is faster?

Method:

$ date
$ drush dl drupal --destination=/var/www/public --drupal-project-rename=d8.local -y
$ date
$ drush site-install --db-url=mysql://root:root@localhost/d8 -y;
$ date

Results

* NFS Disabled = 64 seconds
download: 39 sec.
install: 25 sec.

Mon Oct  8 14:55:01 CEST 2018
$ drush dl drupal --destination=/var/www/public --drupal-project-rename=no-nfs.local -y
Mon Oct  8 14:55:40 CEST 2018
$ drush site-install --db-url=mysql://root:root@localhost/no-nfs -y;
Mon Oct  8 14:56:05 CEST 2018

-----------------------------

* NFS Enabled = 118 seconds
download: 106 sec.
install: 12 sec.

Mon Oct  8 15:00:40 CEST 2018
$ drush dl drupal --destination=/var/www/public --drupal-project-rename=nfs-enabled.local -y
Mon Oct  8 15:02:26 CEST 2018
$ drush site-install --db-url=mysql://root:root@localhost/nfs-enabled -y;
Mon Oct  8 15:02:38 CEST 2018

Vagrant file, default (no NFS):

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]

    # Optional NFS. Make sure to remove other synced_folder line too
    # config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end

Vagrant file, NFS-enabled:

Vagrant.configure("2") do |config|

    config.vm.box = "scotch/box"
    config.vm.network "private_network", ip: "192.168.33.10"
    config.vm.hostname = "scotchbox"
    #config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]

    # Optional NFS. Make sure to remove other synced_folder line too
    config.vm.synced_folder ".", "/var/www", :nfs => { :mount_options => ["dmode=777","fmode=666"] }

end
gitressa commented 5 years ago

I have recently been testing out Docker based Lando. Load time for individual pages are faster, and it downloads a Drupal 8 code base with Composer up to 15 times faster:

composer create-project drupal-composer/drupal-project:8.x-dev d8 --stability dev --no-interaction --no-dev

Scotch Box Time: 4:10 min

Lando Time: 16 seconds

Setting up a new environment for a Lando project is also much faster, since the settings for the individual projects are discerned between based on the unique socket, so database name, user name, etc. are all called fx drupal8 for a Drupal 8 project. As an example here is the settings.php from one Drupal 8 project, but it would be identical in another project:

$databases['default']['default'] = array (
  'database' => 'drupal8',
  'username' => 'drupal8',
  'password' => 'drupal8',
  'prefix' => '',
  'host' => 'database',
  'port' => '',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);