V
V
vadimparinov2022-01-25 17:05:47
Node.js
vadimparinov, 2022-01-25 17:05:47

How to make deploy without downtime?

Good afternoon! The bottom line is this
Let's say there are two containers: - frontend and backend, work through docker compose
How can I deploy a new version without downtime for a while creating new containers and launching them?
Tell me which way to dig

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Michael, 2022-01-25
@vadimparinov

The principle is the following:

  1. You make a container with a front-end balancer (nginx or something similar).
  2. You start the second container with backing containing the new version.
  3. The new container is connected to the load balancer. Here further options are possible - the balancer automatically starts transferring traffic to the new version. Or in some ratio. Or just test traffic. Or switch the balancer to a new container manually. Or ... (in general, there are many options here). The idea is to move to the target state - requests are processed by a new backend. At this stage, the old and new versions of the backend should be able to work in parallel, that is, some requests can be processed by the old version, some by the new one, which imposes on the new version the requirement to maintain backward compatibility with the old version (in particular, this limits possible changes to the database structure). At any time, if the new version is working somehow wrong, you can "turn everything back",
  4. After making sure that the new version works stably, transfer all traffic from the balancer to the new one and lower the container with the old version, leaving the container with the new one alone.

I don’t really understand what you mean by a container with a frontend, if it’s just a web server that distributes a SPA application (HTML / CSS / JS), then in principle it’s the same.
The scheme for such an upgrade is not very easy to implement, so such an upgrade (zero-downtime upgrade) is used in an enterprise in which downtime in maintenance cannot be allowed. Therefore, see for yourself - how much those few seconds (maximum minutes) of downtime for which a new container is launched are worth this fuss. If such an upgrade is really needed, then I advise you to look towards kubernetes instead of docker compose.

V
Vitaly Karasik, 2022-01-25
@vitaly_il1

In order not to reinvent the wheel yourself (with loadbalancer, etc.), you need some kind of orchestrator. Of these, Kubernetes is the most popular, besides it there is Docker Swarm, Nomad, Openshift.

R
Rag'n' Code Man, 2022-01-25
@iDmitriyWinX

docker-compose up -d --no-deps --build <service_name>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question