Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting graceful upgrades and zero-downtime dpeloys #1663

Closed
prologic opened this issue Jul 7, 2015 · 10 comments
Closed

Supporting graceful upgrades and zero-downtime dpeloys #1663

prologic opened this issue Jul 7, 2015 · 10 comments

Comments

@prologic
Copy link

prologic commented Jul 7, 2015

Hi All,

I see there are talks about plans to support this in the future which is great. What have we come up with so far? I'm starting to think about this more with the stuff I do and would like to see something get started on this. I was at least initially thinking of an upgrade command that gracefully pulls down the latest image for a service, spawns a new instance and terminates the old one.

I think things like (typical web production stuff) like database migrations/upgrades, load balancer raining and switching are likely out-of-scope for Docker Compose and should probably be handled by some other decoupled tooling. But I'm not sure yet; I'm just thinking about the "first step".

Thoughts?

@prologic
Copy link
Author

prologic commented Jul 7, 2015

@ccll
Copy link

ccll commented Jul 15, 2015

+1

@prologic
I'm facing the same problem as you, fortunately I figured out a approach today right after google directed me to this post.
Suppose we have 10 instances of container 'web' running in the cluster, and we are upgrading 3 instances at a time, now the basic steps for the rolling upgrade script:

  1. docker-compose pull to pull the latest image.
  2. docker-compose scale web=13 to create 3 instances of the latest version, which will be named as 'web_11', 'web_12' and 'web_13'.
  3. Move the first 3 instances(web_1, web_2, web_3) out of LB, the traffic will be gradually drained to other instances.
  4. Wait until netstat shows there are no connections to the first 3 instances, then we can safely docker rm them.
  5. Repeat from step 2 until all 10 instances are swapped to latest version.
  6. Final step, docker rename the 'web_11', 'web_12', ... to 'web_1', 'web_2' ..., make everything clean and tidy.

I've tested the process manually and it works great, and a basic automated script is not very hard to write, but in a production environment we need to handle failures, rollbacks or resumes of upgrading, which complicates things a bit, so an official support on this will be great.

A minor problem: I couldn't find a way to spawn new containers affinitied to corresponding old containers with docker-compose scale, e.g. spawn 'web_11' on the same host as 'web_1', 'web_12' on the same host as 'web_2', etc, I saw an article from quay.io did it this way, but I have no idea if this is important in some situation or not, if anybody knows please tell me.

@prologic
Copy link
Author

Is something like this considered genreal purpose and useful enough? Or do we also need to think about making "draining load balancer" a plugable thing?

@prologic
Copy link
Author

Not a lot of movement on this one (even from me!); How about something as simple as a docker-compose upgrade <service> (destructive). I'm thinking:

  • pull latest image
  • stop and re-create service

@jayfk
Copy link

jayfk commented Aug 25, 2015

The main problem I see right now is that links are not updated. If you want to do something like @ccll you need to add your own container discovery service.

@aanand
Copy link

aanand commented Aug 25, 2015

@jayfk We shouldn't worry too much about links when designing future stuff (especially for production), as it's soon to be replaced by new networking constructs (see #1676).

@prologic
Copy link
Author

prologic commented Sep 9, 2015

@ccll Do you have a script/tool that does what you described that you're willing to share? Otherwise I'm going to prototype up something (be good to leverage of your efforts).

@ccll
Copy link

ccll commented Sep 14, 2015

Do you have a script/tool that does what you described that you're willing to share? Otherwise I'm going to prototype up something (be good to leverage of your efforts).

@prologic
Not yet, our project is still far to production stage, so I didn't bother to write it yet, sorry!

@prologic
Copy link
Author

In that case I've almost completed a general solution that will work with the autodock platform.

@dnephin
Copy link

dnephin commented Feb 3, 2016

Consolidating all production related issues into #1786

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants