---
created_at: '2015-06-05T11:03:00.000Z'
title: BlueGreenDeployment (2010)
url: http://martinfowler.com/bliki/BlueGreenDeployment.html
author: colund
points: 75
story_text: ''
comment_text: 
num_comments: 35
story_id: 
story_title: 
story_url: 
parent_id: 
created_at_i: 1433502180
_tags:
- story
- author_colund
- story_9664814
objectID: '9664814'

---
[Source](https://martinfowler.com/bliki/BlueGreenDeployment.html "Permalink to BlueGreenDeployment")

# BlueGreenDeployment

[ ![][1] ][2]

* [Intro][3]
* [Videos][4]
* [Design][5]
* [Agile][6]
* [Refactoring][7]
* [FAQ][8]
* [About Me][9]
* [All Sections ][10]
* [ThoughtWorks][11]
* [ ][12]
* [ ][13]
* [home][14]
* topics
    * [agile][15]
    * [refactoring][7]
    * [design][16]
    * [noSQL][17]
    * [DSL][18]
    * [continuous delivery][19]
    * [microservices][20]
* media
    * [books][21]
    * [video][22]
* site
    * [site introduction][23]
    * [about me][24]
    * [FAQ][25]
    * [content index][26]
    * [photos][27]
* catalogs
    * [refactoring][28]
    * [P of EAA][29]
    * [EAA dev][30]
    * [DSL][31]
* feeds
    * [twitter][32]
    * [rss][33]
    * [facebook][34]
* popular
    * [microservices][35]
    * [dependency injection][36]
* ThoughtWorks
    * [blogs][37]
    * [careers][38]
    * [products][39]

# [BlueGreenDeployment][40]

![][41]

[Martin Fowler][14]

1 March 2010

[continuous delivery][42]

tags:

One of the goals that my colleagues and I urge on our clients is that of a completely automated deployment process. Automating your deployment helps reduce the frictions and delays that crop up in between getting the software "done" and getting it to realize its value. Dave Farley and Jez Humble are finishing up a book on this topic \- [Continuous Delivery][43]. It builds upon many of the ideas that are commonly associated with [Continuous Integration][44], driving more towards this ability to rapidly put software into production and get it doing something. Their section on blue-green deployment caught my eye as one of those techniques that's underused, so I thought I'd give a brief overview of it here.

![][45]

One of the challenges with automating deployment is the cut-over itself, taking software from the final stage of testing to live production. You usually need to do this quickly in order to minimize downtime. The blue-green deployment approach does this by ensuring you have two production environments, as identical as possible. At any time one of them, let's say blue for the example, is live. As you prepare a new release of your software you do your final stage of testing in the green environment. Once the software is working in the green environment, you switch the router so that all incoming requests go to the green environment - the blue one is now idle.

Blue-green deployment also gives you a rapid way to rollback - if anything goes wrong you switch the router back to your blue environment. There's still the issue of dealing with missed transactions while the green environment was live, but depending on your design you may be able to feed transactions to both environments in such a way as to keep the blue environment as a backup when the green is live. Or you may be able to put the application in read-only mode before cut-over, run it for a while in read-only mode, and then switch it to read-write mode. That may be enough to flush out many outstanding issues.

The two environments need to be different but as identical as possible. In some situations they can be different pieces of hardware, or they can be different virtual machines running on the same (or different) hardware. They can also be a single operating environment partitioned into separate zones with separate IP addresses for the two slices.

Once you've put your green environment live and you're happy with its stability, you then use the blue environment as your staging environment for the final testing step for your next deployment. When you are ready for your next release, you switch from green to blue in the same way that you did from blue to green earlier. That way both green and blue environments are regularly cycling between live, previous version (for rollback) and staging the next version.

An advantage of this approach is that it's the same basic mechanism as you need to get a hot-standby working. Hence this allows you to test your disaster-recovery procedure on every release. (I hope that you release more frequently than you have a disaster.)

The fundamental idea is to have two easily switchable environments to switch between, there are plenty of ways to vary the details. One project did the switch by bouncing the web server rather than working on the router. Another variation would be to use the same database, making the blue-green switches for web and domain layers.

Databases can often be a challenge with this technique, particularly when you need to change the schema to support a new version of the software. The trick is to separate the deployment of schema changes from application upgrades. So first apply a [database refactoring][46] to change the schema to support both the new and old version of the application, deploy that, check everything is working fine so you have a rollback point, then deploy the new version of the application. (And when the upgrade has bedded down remove the database support for the old version.) 

This technique has been "out there" for ages, but I don't see it used as often as it should be. Some foggy combination of [Dan North][47] and Jez Humble came up with the name.

## Further Reading

You can find much more detail on this and related techniques from the [Continuous Delivery book][43] by Jez Humble and Dave Farley. My [guide page on delivery][19] points to more material on these topcis.

## Acknowledgements

Illustration by Ketan Padegaonkar 

* * *

## Updates

2015-06-05: The page got a lot more page traffic today as Hacker News noticed it. So I added a paragraph on database changes and the further reading section.

Share:![][48]![][49]![][50]

if you found this article useful, please share it. I appreciate the feedback and encouragement

## Find similar articles at the tag

[continuous delivery][42]

* [home][14]
* topics
    * [agile][15]
    * [refactoring][7]
    * [design][16]
    * [noSQL][17]
    * [DSL][18]
    * [continuous delivery][19]
    * [microservices][20]
* media
    * [books][21]
    * [video][22]
* site
    * [site introduction][23]
    * [about me][24]
    * [FAQ][25]
    * [content index][26]
    * [photos][27]
* catalogs
    * [refactoring][28]
    * [P of EAA][29]
    * [EAA dev][30]
    * [DSL][31]
* feeds
    * [twitter][32]
    * [rss][33]
    * [facebook][34]
* popular
    * [microservices][35]
    * [dependency injection][36]
* ThoughtWorks
    * [blogs][37]
    * [careers][38]
    * [products][39]

[ ![][51] ][11]

© Martin Fowler | [Privacy Policy][52] | [Disclosures][53]

[1]: /mf-name-white.png
[2]: https://martinfowler.com
[3]: https://martinfowler.com/intro.html
[4]: https://martinfowler.com/videos.html
[5]: https://martinfowler.com/design.html
[6]: https://martinfowler.com/agile.html
[7]: http://refactoring.com
[8]: https://martinfowler.com/faq.html
[9]: https://martinfowler.com/aboutMe.html
[10]: https://martinfowler.com#bottom-navmenu
[11]: http://www.thoughtworks.com
[12]: https://martinfowler.com/feed.atom "feed"
[13]: http://www.twitter.com/martinfowler "Twitter stream"
[14]: /
[15]: /agile.html
[16]: /design.html
[17]: /nosql.html
[18]: /dsl.html
[19]: /delivery.html
[20]: /microservices
[21]: /books
[22]: /videos.html
[23]: /intro.html
[24]: /aboutMe.html
[25]: /faq.html
[26]: /tags
[27]: /photos
[28]: http://refactoring.com/catalog
[29]: /eaaCatalog
[30]: /eaaDev
[31]: /dslCatalog
[32]: http://www.twitter.com/martinfowler
[33]: /feed.atom
[34]: https://www.facebook.com/martinFowlerThoughtWorks
[35]: /articles/microservices.html
[36]: /articles/injection.html
[37]: http://thoughtworks.com/blogs
[38]: http://thoughtworks.com/careers
[39]: https://www.thoughtworks.com/products
[40]: BlueGreenDeployment.html
[41]: /mf.jpg "Photo of Martin Fowler"
[42]: /tags/continuous delivery.html
[43]: /books/continuousDelivery.html
[44]: /articles/continuousIntegration.html
[45]: images/blueGreenDeployment/blue_green_deployments.png
[46]: /books/refactoringDatabases.html
[47]: http://dannorth.net/
[48]: /t_mini-a.png
[49]: /fb-icon-20.png
[50]: /gplus-16.png
[51]: https://martinfowler.com/TW_smb.jpg
[52]: http://www.thoughtworks.com/privacy-policy
[53]: https://martinfowler.com/aboutMe.html#disclosures

