Deploying Without Downtime Print

  • developersgitdeployment, developers, downtime, migration, database, troubleshooting, uploads, guide
  • 0

Avoiding a broken site during deployment.

THE PROBLEM

A deployment that copies files one at a time leaves the site in a mixed state. A visitor arriving mid-deployment sees errors.

THE SIMPLE APPROACH

A Git pull is fast and mostly atomic in practice. For small sites this is usually sufficient.

THE BETTER APPROACH

Deploy into a new directory, then switch a symlink to point at it. The switch is instantaneous, and rolling back means switching the symlink back.

This requires the web server's document root to point at a symlink, which is configurable.

SHARED DIRECTORIES

Uploads, storage and configuration must persist across deployments. Keep them outside the release directories and symlink them in.

DATABASE MIGRATIONS

The hard part. A migration that removes a column breaks the old code still running during the switch.

Write migrations that are compatible with both old and new code where possible: add before removing, and remove in a later deployment.

MAINTENANCE MODE

For deployments that cannot be made seamless, a brief maintenance page is more honest than errors.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot