RE:NODE
Обзор хостинга

Эксплуатация6 мин чтения

Zero-downtime deploys on a server that only has one of everything

You do not need a cluster. What actually causes the gap during a deploy, and three techniques that remove it on a single machine.

Эта статья пока на английском. Мы её переводим.


Zero-downtime deployment is usually described in terms of load balancers and rolling updates, which is unhelpful if you have one server. On one machine the gap has a simpler cause: the old process stops before the new one is ready to answer.

Close the gap

  • Start the new process first, on a second port, and switch only once it responds.
  • Have the old process finish in-flight requests instead of dropping them, which is a signal handler and about ten lines.
  • Run migrations before the deploy, written so both versions of the code can live with the schema.

The migration is the hard part

Adding a column is safe. Renaming one is not, because for a few seconds both versions are running. Add, deploy, backfill, then remove in a later release: three boring deploys instead of one exciting one.