Serverless Blue-Green Deployment
Blue-Green Deployment is a very good technique that has been successfully used for managing releases of cloud applications. Now it's time to rethink it a bit for serverless systems.
The concept is pretty easy: We have two identical production environments (blue and green), the green is "live" as default. When we release a new version, we deploy first into the blue environment. There we can perform some tests and then switch routing. The blue enviroment becomes "live". If something goes wrong we should be able to switch back in less than a second.
Problems with Serverless
So, why don't we use the same strategy for serverless deployment? We have several challenges to solve:
- No database integration - a service should contain its own data storages as a part of the stack.
- Independent deployment lifecycles - there is no synchronization between deployments.
- Location transparency - the topology of serverless systems is dynamic.
Is there any solution for those problems? Maybe yes, but the cost of complexity would be too high. On the other hand, this doesn't mean we have to abandon the blue-green deployment completely. We can still benefit from the idea, just on another level.
Blue-Green for Test-Isolation
Let's image the following scenario: We have a test stage where all the integration tests are executed in. This stage is shared by all the service deployment pipelines.
What happens when a test of the service A runs at the same time as another test of the service B, which uses the service A as an external resource? When the new version of the service A doesn't work, it has a negative impact on the test results. And that's the point where the blue-green deployment comes to rescue!
As you can see in the picture above, when a new version of the service A (Av2) is about to be tested, it is deployed parallel to the previous version stack (Av1). The blue version is integrated in the system as well as the green version. If another test comes along, it sees only the already tested stack Av1.
You can find a simple implementation of the serverless blue-green development for test-isolation in my Github account. The example uses AWS CodePipeline.
Be blue-green, be happy!