Microservice Practices - Dark Launches and Feature Toggles

Dark-launches and Feature toggles are two great practices to deploy code faster to production and get early feedback. Combined with microservices architecture, it becomes a very powerful tool and once adopted, there is no turning back! You will be thrilled by the speed with which you can build and ship software in a safe manner! In this blog, I will try to explain what these terms means.

Dark Launch
Dark launch is a practice where you can test/validate your new functionality in production without having to worrying about disturbing the original workflow. This technique is very useful when writing a new version of the functionality or even adding more functionality that can be triggered based of any existing workflow. The steps to achieve it are very simple:
  1. Deploy the new functionality in prod. 
  2. Incase if it is new version of an existing functionality and you want to test correctness: 
    • clone the request going into v1-logic —> then call the v1-logic —> clone the v1-result. 
    • Now in the background (fire and forget) call the new logic with cloned v1 request and compare v2-result with v1-result. Since this happens in background, there is no impact on the original workflow 
  3. In case if you want to test new functionality invoked of an existing workflow 
    • During the execution of the workflow, assemble the information you need in order to call the new functionality 
    • In the background - make the call to the new functionality and start collecting metrics. 
  4. If storage is involved - you can ignore it (if its dump) or do cleanup later (in case if there is some logic involved). Dump storage is preferred!


This practice allows you to collect some key metrics around correctness, robustness and performance of the new functionality even before the code is in use for real. Since the call to the new functionality happens in the background, it does not impact the original workflow! How awesome is that! You can ship the code faster to the production and get meaningful insights without breaking any of your clients! 

Feature Toggles
Feature toggles is a practice of enabling a new functionality for selected group of consumers at a time. This technique allows you to do selective rollout and also restricts the blast radius when things do go wrong with the newly deployed code. You can imagine dark-launch as a feature also and selectively enable it for set of clients. Toggles are created and stored external to the application and development team has full control over them. Feature toggles and branch-by-abstraction (which is well documented here by Martin Fowler) go hand in hand. In simple terms, all it is saying that before invoking a new piece of functionality, first check if the user has toggle-on for it. If yes - then call the new path else continue to call the old path. 

I work in Stock-market domain where one mistake could potentially cost our clients millions of dollars and I have used these techniques for all sort of work - from small rewrites/features to complex tasks of migrating storage from SQL-server to mysql. The results have been amazing and at the end, we have delivered a robust, stable and performant product offering. 




Popular posts from this blog

Break functional and orchestration responsibilities for better testability

Prefer Consumer over Integration Tests

Microservices and Tech Stack - Lessons Learned