Saturday, April 9, 2016

Composer Update Failed on Dreamhost - killed for excessive resource usage

Problem:
While working on a pet project, I decided to use Laravel 5 on my Dreamhost shared server (where most of my prototype/hobbies go). I was able to get composer running fine with the exception of when I would try to run composer update. Composer can sometimes take a bit of resources, and unfortunately Dreamhost shared servers are pretty slim. I kept getting the following message.

Loading composer repositories with package information
Updating dependencies (including require-dev)

Yikes! One of your processes (php, pid 3726) was just killed for excessive resource usage.
Please contact DreamHost Support for details.

Killed

Solution:
It turns out that one of the heaviest parts of running composer update is the point as which the composer.lock file is updated and PHP tries to determine new packages, etc. If we generate the composer.lock file outside of Dreamhost (like on your local machine) and then move the file over, we can bypass this by running composer install.  For this pet project, I just add the composer.lock to my source version control to make things simpler when moving the file back and forth.

Good luck!