0

I'm using this example https://github.com/BretFisher/node-docker-good-defaults

I have a nodejs backend app and I have 1 replica of the service. And the "deploy" section in the docker-stack.yml file looks like this:

  deploy:
    update_config:
      order: start-first

When I make a new version of the app, and then update the service, during the update, I have an overlap of the working "old" and "new" version of the app.

Steps to reproduce:

  1. build a new version of the app
  2. update the service
  3. send requests to the backend app each 10ms.

Result: at some point in time I see responses from the old and the new version.

enter image description here

Is it expected behavior?

Krishna Chaurasia
  • 8,924
  • 6
  • 22
  • 35
Alexandr Bur
  • 23
  • 1
  • 5

1 Answers1

1

Yes, this is expected.

Load balancing between multiple replicas of a swarm mode service in docker is round robin between the replicas. There's no priority between the replicas, including for containers running on the same node or for a newer version, it's just round robin.

This is implemented per connection, so if you want to keep talking to the same container, you could keep a persistent connection open (e.g. http keep alive), but then you'll want to have an automatic retry in the app if the connection fails, to handle the container getting replaced.

BMitch
  • 231,797
  • 42
  • 475
  • 450