Peter O'Callaghan
Thoughts on Development, Magento and Security
  • email
  • twitter
  • Home
  • About
Select Page ...

Magento 2 - Faster composer install

February 6, 2016 Development Process, Magento

Anybody that has sat through an initial composer install of Magento 2 will know it’s slow. Very slow. Unbelievably slow in fact. The main reason for this is the sheer number of dependencies which it pulls in. I decided to do some profiling and see if I could improve performance.

Development Setup

I’ve only recently started looking into Magento 2. To kickstart the process I decided to use a basic Vagrant set-up that I currently use with Magento 1. I’m using a Centos 7 base box that is provisioned with Ansible. This is running as a 4GB Virtual Box on Mac OS X.

Default Install of Magento 2

In order to check just how slow it was, and confirm it wasn’t my imagination or impatience, I first needed to profile the installation. In order to make it a fair test, I first removed the files and cleared the composer cache.

Profiling default install of Magento 2
1
2
3
4
5
6
[vagrant@vagrant magento]$ composer clear-cache
[vagrant@vagrant magento]$ rm -rf vendor/
[vagrant@vagrant magento]$ composer install --no-progress --profile --prefer-dist
...
[14.4MB/855.58s] Generating autoload files
[14.8MB/884.81s] Memory usage: 14.8MB (peak: 102.98MB), time: 884.81s

As you can see it took the best part of 16 minutes to fetch and install all the dependencies! Achieving a fast deployment pipeline is important. Especially during the initial development stages where you’re still smoothing the edges of your process. Waiting over a quarter of an hour is therefore not going to fly.

Prestissimo

Performing some research, I came across the composer plugin prestissimo. The purpose of the plugin is to fetch the dependencies in parallel thus reducing the overall time taken. I read some debates over whether it was truly ‘parallel’, but for our purposes this isn’t really relevant. All that really matters is whether or not time to completion is improved. Since that is our objective, I decided it was worth checking out.

Following the instructions on the official github page, I therefore installed the plugin for global usage:

Installing prestissimo
1
[vagrant@vagrant magento]$ composer global require hirak/prestissimo

Prestissimo Install of Magento 2

With the plugin installed, it’s time to perform our new profile. To ensure a fair test I ran the exact commands I ran previously:

Profiling prestissimo install of Magento 2
1
2
3
4
5
6
[vagrant@vagrant magento]$ composer clear-cache
[vagrant@vagrant magento]$ rm -rf vendor/
[vagrant@vagrant magento]$ composer install --no-progress --profile --prefer-dist
...
[14.8MB/656.62s] Generating autoload files
[15.2MB/684.19s] Memory usage: 15.18MB (peak: 19.98MB), time: 684.19s

As you can see the overall time is now just under 11 and a half minutes. Still pretty slow, but a significant improvement none the less.

← Magento 1.9.2.2 + patches vs Magento 1.9.2.3
HTTP composer dependencies →
  • Categories

    • Development Process
    • Magento
    • Sysadmin
    • Uncategorized
  • Tags

    .htacces Apache composer facepalm filesystem magento 2 mod_rewrite security
    • Archives

      • December 2017
      • June 2017
      • April 2017
      • February 2017
      • January 2017
      • December 2016
      • October 2016
      • September 2016
      • July 2016
      • February 2016
      • January 2016
      • April 2012
      • February 2012
      • August 2011
    • Categories

      • Development Process
      • Magento
      • Sysadmin
      • Uncategorized
    • “There are two types of people. Those who can extrapolate from incomplete data.”

    • Contact
    • Home
    Copyright © 2012 All Rights Reserved - peterocallaghan.co.uk