Header

How to migrate a DeployHQ project to use atomic deployments

Tips & Tricks and Tutorials

Thumb1400

What's the difference between non-atomic and atomic deployments?

When deploying your project to a regular server, the server will hold a single copy of all the files in your repository. Then each deployment will update only the changed files (unless it's your first deployment, or you've deliberately deployed from scratch). This is fine in most cases, however, if you wanted to have zero-downtime between deployments, this is where atomic deployments are needed.

Primarily the benefits of atomic deployments are that if someone is visiting the page when the deployment is in progress, they won't see any errors relating to files that are in the process of being uploaded/updated. Also if a deployment fails it won't bring the site down as it will still be using the old release.

How atomic deployments work

Using atomic deployments will ensure there is no downtime during the deployment process. When the first atomic deployment is run, DeployHQ will create three directories within your defined deployment path:

  • releases
  • shared
  • cache (this will be created if you set up the cache strategy)

There will also be a "current" symlink created, which will point to the latest release. The files will be deployed to a folder within releases, named as the timestamp of the deployment. Once the files have transferred successfully, the current directory will be symlinked from the previous release, to the newest release.

How to set up atomic deployments

To set up atomic deployments, check the Perform zero-downtime deployments on this server? box whilst creating a new server.

How to migrate an existing project to use atomic deployments

If you'd like to migrate your current project to use atomic deployments, you'll need to create a new server within DeployHQ, with all the same settings as the previous one, which will then enable you to check the appropriate box. When updating a previous project, the web server configuration will also need to be updated to serve files from "current".

The specified deployment path needs to be empty when setting up atomic deployments, nothing should be in this directory other than the folders generated by DeployHQ.

Anything that isn't part of the repository but that should be persisted between deployments, should be moved into the shared folder.

A little bit about the author

I'm Carla and I work in the support team for aTech Media and Dial 9. When I'm not helping customers with their questions I enjoy spending time with my dog and cats.