1

I have a Nodejs application that included clustering for being uptime and domain for error handling.

Now for achieving zero downtime deployment, I have an instruction but I need help to convert this instruction to Nodejs code (I need an example for it please).

This is the instruction:

  1. When master starts, give it a symlink to worker code.
  2. After deploying new code, update symlink
  3. Send a signal to master: fork new workers!
  4. Mater tells old workers to shut down, forks new workers from new code.
  5. Mater process never stop running

Instruction source -> slide number 39

Jon Saw
  • 7,599
  • 6
  • 48
  • 57
kazem 2073
  • 11
  • 3
  • Alternative, you may want to check this https://www.chrismoos.com/2016/09/28/zero-downtime-deployments-kubernetes/ I've followed this setup in production and it works pretty well. Not exactly what you need, just sth to keep in mind. – Tuan Anh Tran Jun 04 '17 at 11:24
  • Thanks but it was so far than my purpose!! – kazem 2073 Jun 04 '17 at 11:41

1 Answers1

1

For 100% uptime the road is more or less the same regardless of the language you are using:

  • Store your session tokens in a database rather than in an in-memory array or something. This will allow users to stay logged-in after you swap versions.

  • Run your server inside a Docker container

  • Use a proxy to handle swapping containers when you need to run a new server version.

I wrote easy-deploy to handle exactly that, so that I wouldn't need to worry about setting up the proxy every time.

Deploy version 1

easy-deploy -p 80:80 -v some/path:other/path my-image:1

To deploy a new version just run the command with the updated tag name

easy-deploy -p 80:80 -v some/path:other/path my-image:2

The proxy is taken care of. my-image:1 will be replaced by my-image:2 without letting any request drop.

Marcelo Lazaroni
  • 9,819
  • 3
  • 35
  • 41