On automated deployments


Today, pretty much anybody who’s serious about software development, uses automated deployments.  Gone are the days of the manual uploads to FTP servers, tedious command lines, and long checklists.  There are a million tools that can help a team to automate file synchronizations, database schema changes, cache warm ups, and other tasks related to pushing a new version to users.  If you are not familiar with the benefits of the automated deployments, have a look at this article, for example.  If you want to do them, but don’t know how, let us know and we’ll help you out.

During the last three years, we’ve used several tools, progressively making our deployments easier and faster.  Our current process uses the following components:

  • HipChat – team chat application, where we have a bot, listening to deployment commands and calling a small API end-point to trigger the deployment script execution.
  • Slim PHP Framework – which we used to implement a tiny application for the API end-point called by the above.
  • Envoy Task Runner – a Laravel PHP framework component, that makes it easy to run commands via Secure Shell (ssh) across multiple servers.
  • phake-builder – our own Open Source project, based on phake, for executing project build tasks, like pulling source code from repositories, setting up databases, fixing file permissions, and the like.
  • GitHub and BitBucket – excellent source code repositories, complete with API, web hooks, code review, and other useful developer gems.
  • git – the King of software version control tools.

There are two reasons for why we have so many components to the process.  First, each of these tools does its own thing and does it well.  Second, there is a bit of history – we didn’t come up with the process all in one go.  It took time, effort, and experimentation.

The thing about automated deployments is that you don’t always feel that you need them.  Sure, sometimes it’s so much simpler to work directly on the live server.  It’s a quick fix after all, right?  Well, yes.  But in the long run, having a well defined, automated, repeatable process pays off.  There are fewer mistakes.  There is fewer thinking or remembering.  It’s much easier to bring new team members up to speed.  And it’s much easier to improve and optimize over time.

During a slow week, with just a few deployments here and there, it’s difficult to see the benefit.  But when the work hits the fan and you need to crank up as much or as fast as possible, every tiny bit of automation helps.  Here’s an example from the last week at our office, which was one of the craziest this year so far:

 | 2016-10 |  31 |
 | 2016-11 |  46 |
 | 2016-12 |  35 |
 | 2016-13 |  19 |
 | 2016-14 |  35 |
 | 2016-15 |  26 |
 | 2016-16 | 101 |

The above shows the number of deployments per week over the last few weeks.  As you can see, we usually do anywhere between 25 and 45 deployments (these includes all deployments to test, staging, and live servers).  Last week, however, we’ve done just over a 100!

Consider an average manual deployment being about 15 minutes (getting the files, packaging, uploading, extracting, fixing permissions, applying database changes, clearing the cache, sending out notifications, etc).  Our automated deployment takes roughly 30 seconds (depending on the number of changes, the size of the project, and servers affected).  So, just last week alone, we’ve done 101 deployments times 30 seconds = 3030 seconds = 50.5 minutes (not even a full lunch break).  If we were to do that manually, that would crank up to 25 hours 15 minutes (not a full time employee, but more than a part-time can handle).

The benefits are obvious.  But now that we have it, can it get any better?  Yes, of course!  As we mentioned earlier, we are new fans in the Ansible camp.  So far we’ve only been moving our Puppet configuration management, but soon, our deployment automation will shift to Ansible as well.  The setup will be simpler, more consistent, with fewer conponents, faster, and more powerful.  We’ll be able to automate more with less.  Ansible has enough functionality built-in for us to replace both Laravel Envoy and phake-builder with it.  We’ll still keep the HipChat, the API end-point, and our git repositories though.