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:
Result: at some point in time I see responses from the old and the new version.
Is it expected behavior?
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.