<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sheroy Marker</title>
    <description>The latest articles on Forem by Sheroy Marker (@sheroy).</description>
    <link>https://forem.com/sheroy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F134224%2F1b7cf74c-c46d-4999-af35-c6e89ed4f376.png</url>
      <title>Forem: Sheroy Marker</title>
      <link>https://forem.com/sheroy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sheroy"/>
    <language>en</language>
    <item>
      <title>Configuration Strategy for Continuous Delivery of Microservices</title>
      <dc:creator>Sheroy Marker</dc:creator>
      <pubDate>Mon, 03 Jun 2019 18:18:45 +0000</pubDate>
      <link>https://forem.com/gocd/configuration-strategy-for-continuous-delivery-of-microservices-5a26</link>
      <guid>https://forem.com/gocd/configuration-strategy-for-continuous-delivery-of-microservices-5a26</guid>
      <description>&lt;p&gt;This is the fifth post in the series - &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html"&gt;Continuous Delivery of Microservices&lt;/a&gt;. In the &lt;a href="https://www.gocd.org/2018/06/12/cd-microservices-environment-strategy/"&gt;previous post&lt;/a&gt;, we talked about environment strategy - including artifact promotion and ways to leverage modern infrastructure for dynamic environments. In this post, we will discuss configuration strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;An application’s configuration is everything that is variable across deployment environments such as development, test, and production. Deploying the same code but switching out certain aspects (like URLs to backing services, database connection information, credentials to third-party services, etc.) are examples of what I mean by variables in this context. Such configuration should be stored separately from the application code.&lt;/p&gt;

&lt;p&gt;In a system based on a microservices architecture, configuration also needs to be distributed across multiple services. There are a couple of ways to manage configurations in a distributed way: *make configuration available in environment variables at deploy time, *use an external configuration server product designed to expose configuration&lt;/p&gt;

&lt;p&gt;Here are three things you should consider for your microservices configuration strategy:&lt;/p&gt;

&lt;h2&gt;
  
  
  1: Manage application configurations centrally
&lt;/h2&gt;

&lt;p&gt;An external configuration server is a more appropriate system for managing application configuration and introduces cleaner separation of concerns.&lt;/p&gt;

&lt;p&gt;The configuration management code (in chef or puppet) can solely be responsible for cluster management. With Chef, updating application configuration would require a slow convergence operation of the cluster. With an external configuration server, updates to application configuration can be more dynamic without the need to update any other aspect of the infrastructure.&lt;/p&gt;

&lt;p&gt;Another added advantage of this approach is that it forces consistent practices with organizing configuration by application, and environment.&lt;/p&gt;

&lt;p&gt;There are a number of purpose built external configuration servers you could consider. The Spring cloud config server is a good option for Spring applications. With support for multiple backends, you could integrate with industry standard KV stores such as &lt;a href="https://www.consul.io"&gt;Consul&lt;/a&gt; for non-sensitive configuration, and &lt;a href="https://www.vaultproject.io/"&gt;Vault&lt;/a&gt; for sensitive configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  2: Standard process for distributing configuration
&lt;/h2&gt;

&lt;p&gt;For microservices systems, it is possible to have different tech stacks across the systems. If one is handling configuration differently for different stacks, then the complexity becomes hard to manage. Therefore, regardless of the tech stack of a microservice, configurations should be distributed to nodes in a standard manner.&lt;/p&gt;

&lt;p&gt;A technique we use is to supply configuration as environment variables per The &lt;a href="https://12factor.net/"&gt;Twelve-Factor App&lt;/a&gt; methodology. As a rule of thumb, always avoid distributing configuration files.&lt;/p&gt;

&lt;p&gt;The Twelve-Factor app is a manifesto that provides some guidelines to be followed while building cloud-native applications. These guidelines let you build applications that are cloud-friendly. To truly harness the advantages of a cloud environment, an application needs to embrace cloud concepts such as elastic scalability, independently deployable and operable services, and statelessness.&lt;/p&gt;

&lt;h2&gt;
  
  
  3: Governance policy around secrets
&lt;/h2&gt;

&lt;p&gt;Secrets such as API keys, passwords, and certificates need to be accessed securely. You need a governance process to ensure secrets access is managed appropriately. One technique we recommend to store all secrets is a central secrets store. The central external configuration server could provide this capability.&lt;/p&gt;

&lt;p&gt;This central store gives you traceability on how and when policies were changed. That traceability goes a long way in setting up a governance process.&lt;/p&gt;

&lt;p&gt;A tool we recommend to store secrets is the &lt;a href="https://www.vaultproject.io/"&gt;Vault&lt;/a&gt; by Hashicorp.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bj6o1rvl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cl.ly/038cd11a56ea/download/Image%25202019-05-31%2520at%252010.27.20%2520AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bj6o1rvl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cl.ly/038cd11a56ea/download/Image%25202019-05-31%2520at%252010.27.20%2520AM.png" alt="Managing Configuration"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is an example of an architecture where configurations are stored centrally in a config server and updated by the CD pipeline and pushed out to service instances.&lt;/p&gt;

&lt;p&gt;At the top there is an abstraction of the CD pipeline. This updates the config server and then the configuration from the config server is pushed to the service instances. At run time, service instances are aware of how to consume this configuration. When setting-up an architecture like this, you need to consider how many configuration servers should you have. We recommend that you have one configuration server per CD environment, or at least one for production and one for all other environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is the part 5 of our &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html"&gt;CD for Microservices blog series&lt;/a&gt;. We have talked about configuration strategy for your CD pipeline. In the next post, we will talk about the last consideration: remediation strategies for when something goes wrong.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>cd</category>
      <category>microservices</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Environment Strategy for Continuous Delivery of Microservices</title>
      <dc:creator>Sheroy Marker</dc:creator>
      <pubDate>Mon, 13 May 2019 13:47:12 +0000</pubDate>
      <link>https://forem.com/gocd/environment-strategy-for-continuous-delivery-of-microservices-5bki</link>
      <guid>https://forem.com/gocd/environment-strategy-for-continuous-delivery-of-microservices-5bki</guid>
      <description>&lt;p&gt;This is the fourth post in the series - &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html" rel="noopener noreferrer"&gt;CD of Microservices&lt;/a&gt;. In the &lt;a href="https://www.gocd.org/2018/05/08/continuous-delivery-microservices-test-strategy/" rel="noopener noreferrer"&gt;previous post&lt;/a&gt;, we talked in depth about CI practices, in particular trunk based deployment and feature toggles. In this post, we’ll discuss environment strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Environment plan
&lt;/h2&gt;

&lt;p&gt;In some organizations people don’t realize the importance of an environment plan until they have too many environments and maintaining them becomes overwhelming.&lt;/p&gt;

&lt;p&gt;An environment plan communicates the various environments that are involved in the path to production and their intended uses. It also communicates how your artifacts are promoted and the toggle states on these environments.&lt;/p&gt;

&lt;p&gt;You can start with thinking about what environments need to be created upfront and talking about the intended use cases for these environments. Different groups in your organization will have different competing needs. Your environment plan should accommodate the needs from different parties.&lt;/p&gt;

&lt;h2&gt;
  
  
  Artifact promotion
&lt;/h2&gt;

&lt;p&gt;Artifacts are one of many kinds of tangible by-products produced during the development of software. Some of these artifacts are text files like test and coverage reports. Some of these artifacts are binary artifacts like npm packages, jar files, and AMI machine images, which are built once and propagated along the CD pipelines for deployment in downstream environments.&lt;/p&gt;

&lt;p&gt;CD pipelines generate a lot of artifacts. Before you know it, you're getting into terabytes, or tens of terabytes of generated artifacts. It's important to think through an artifact promotion strategy, which deals with where these artifacts are stored, how many are retained, and how you do clean-up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2F4c76b5839016%2Fdownload%2FImage%25202019-05-13%2520at%25209.36.50%2520AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2F4c76b5839016%2Fdownload%2FImage%25202019-05-13%2520at%25209.36.50%2520AM.png" alt="Environment Plan for Continuous Delivery"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The diagram above shows you an environment plan which factors in an artifact promotion strategy. From the plan you can see the environments that exist in the CD pipeline, with different colored arrows depicting different artifact promotion strategies. Early on in this pipeline, we generate artifacts that go to an artifact repository that has a more aggressive clean-up strategy, so we don't really retain too many of those environments. As you go further down this pipeline, artifacts are verified and more robust and you may want to keep these for a little longer, so you could keep them in a store with a different retention policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dynamic environments
&lt;/h2&gt;

&lt;p&gt;Environments are expensive and cumbersome to maintain. One way to make the process simpler and less expensive is to create environments on the fly. For example, when running functional tests, you can provision a functional test environment on demand, then clean it up right after your test is done.&lt;/p&gt;

&lt;p&gt;To do this, you need use &lt;a href="http://infrastructure-as-code.com" rel="noopener noreferrer"&gt;IaaC&lt;/a&gt; techniques to script all aspects of environment provisioning. Here are the benefits of doing this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parity with production&lt;/strong&gt; If you create all environments dynamically based on automation, you will use exactly the same way to create testing and staging environments. The scale and nature of infrastructure may be different, but the footprint of the environment remains the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevent drift&lt;/strong&gt; If you have manual processes and manual installations, you can't really ensure that two environments are the same. But using a script to create short-lived dynamic environments prevents drift.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Efficient use of hardware and infrastructure&lt;/strong&gt; Only creating an environment when you need it and cleaning up dynamically optimizes utilization and saves infrastructure costs.&lt;/p&gt;

&lt;p&gt;Technologies such as container schedulers are all the rage these days for deploying and running applications. The diagram below is an example of a Dock - a Docker based build workflow with Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2F0aa1199207ce%2Fdownload%2FImage%25202019-05-13%2520at%25209.37.55%2520AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2F0aa1199207ce%2Fdownload%2FImage%25202019-05-13%2520at%25209.37.55%2520AM.png" alt="Environment Plan Dynamic Provisioning for Continuous Delivery"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The CI aspect of this pipeline, which is the build pipeline on the left, generates Docker images. The artifacts from this pipeline, which are Docker images, are stored in a Docker registry. Further downstream, deploy environments deploy directly to Kubernetes. You can leverage features of Kubernetes like its concept of labels to provision environments on the fly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is the part 4 of our &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html" rel="noopener noreferrer"&gt;CD of Microservices blog series&lt;/a&gt;. We have talked about environment strategy including artifact promotion and leveraging modern infrastructure for dynamic environments. In the next post, we will talk about the fourth consideration: configuration strategy.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>docker</category>
      <category>cd</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Continuous Delivery of Microservices - Trunk Based Development and Feature Toggles</title>
      <dc:creator>Sheroy Marker</dc:creator>
      <pubDate>Mon, 08 Apr 2019 16:51:48 +0000</pubDate>
      <link>https://forem.com/gocd/continuous-delivery-of-microservices-trunk-based-development-and-feature-toggles-435d</link>
      <guid>https://forem.com/gocd/continuous-delivery-of-microservices-trunk-based-development-and-feature-toggles-435d</guid>
      <description>&lt;p&gt;This is the third post in the series - &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html" rel="noopener noreferrer"&gt;CD of Microservices&lt;/a&gt;. In the &lt;a href="https://www.gocd.org/2018/05/08/continuous-delivery-microservices-test-strategy/" rel="noopener noreferrer"&gt;previous post&lt;/a&gt;, we talked about testing strategy for building CD pipelines on microservices architecture. In this post, we’ll get deep into CI practices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Continuous integration
&lt;/h2&gt;

&lt;p&gt;Continuous integration is a key practice in a successful continuous delivery strategy. Simply defined, it’s a practice that requires developers to integrate their code into a shared repository several times a day. Every checkin is verified by an automated build, allowing teams to detect problems early.&lt;/p&gt;

&lt;p&gt;We’ll focus on two key practices, trunk based development and feature toggles. These two go a long way in implementing a simple and robust CI process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trunk Based Development
&lt;/h2&gt;

&lt;p&gt;In trunk based development (TBD), developers collaborate on code in a single branch called “trunk”. The key benefit is to avoid drift in development branches and the resulting merge hell.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fb86f90a7fe30%2Fdownload%2FImage%25202019-04-04%2520at%25206.42.23%2520PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fb86f90a7fe30%2Fdownload%2FImage%25202019-04-04%2520at%25206.42.23%2520PM.png" alt="Trunk Based Development - TBD"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is contrary to the practice of maintaining long-lived feature and release branches. In a branching model, though you may be running builds on individual branches, arguably &lt;a href="https://www.gocd.org/2017/05/16/its-not-CI-its-CI-theatre/" rel="noopener noreferrer"&gt;you aren’t doing continuous integration&lt;/a&gt;. In trunk based development, you should never find your trunk in a state where your CD process is unable to deploy. All code should be checked into trunk, built and tested constantly, and the codebase deployable on demand: all of this make CD a reality.&lt;/p&gt;

&lt;p&gt;TBD results in much simpler CD workflows: you don’t have to build multiple branches in parallel, map branches to environments and re-test when the same features get merged to trunk. Simplifying workflows is very important in the context of microservices, as the complexity is exasperated as the number of microservices grows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://martinfowler.com/articles/feature-toggles.html" rel="noopener noreferrer"&gt;Feature toggles&lt;/a&gt; is an important technique for TBD.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Toggles
&lt;/h2&gt;

&lt;p&gt;Feature toggles enable commits of a combination of work-in-progress and completed features. With these toggles, you can turn off the manifestation of incomplete features in production, until the features are dev complete and tested sufficiently in pre-production environments.&lt;/p&gt;

&lt;p&gt;Here is a very simple example. The team are working on four features for the same application: search, menu, sign-in and in-app chat. The in-app chat feature is incomplete (but you still check into trunk in TBD) or you find issues with the in-app chat in pre-production testing. With feature toggles, you can simply turn in-app chat off, even at run time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fbaba3926feaa%2Fdownload%2FImage%25202019-04-04%2520at%25206.42.51%2520PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fbaba3926feaa%2Fdownload%2FImage%25202019-04-04%2520at%25206.42.51%2520PM.png" alt="Feature Toggles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feature toggles are usually stored in a specification or configuration file close to the codebase and used by automation in the CD pipeline to turn toggles on in specific environments. They are just conditions in your code base.You should separate setting these toggles from the actual release process so that you can control it in run time.&lt;/p&gt;

&lt;p&gt;Some things you should consider when implementing feature toggles:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feature toggles should be short lived&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feature toggles should be discarded once a feature has gone through the development lifecycle and is turned on in production. They are considered to be a code debt that needs to be cleaned up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use tooling to manage toggles’ lifecycles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don’t underestimate the amount of effort required to manage these toggles. You can easily run into hundreds of them. Use tooling which provides visibility into the list of toggles, what’s turned on in which environment, and which features will get turned on in production in the next release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consider building your own utilities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There isn't a lot of tooling out there, so consider writing your own utilities to solve some of these problems. Again, getting this tooling in place before you go down a microservice strategy is a wise thing to do.&lt;/p&gt;

&lt;p&gt;Once you have a mechanism for maintaining feature toggles, you could use the same mechanism to introduce other categories of toggles:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fbbdfb85bfea2%2Fdownload%2FImage%25202019-04-04%2520at%25206.43.29%2520PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl.ly%2Fbbdfb85bfea2%2Fdownload%2FImage%25202019-04-04%2520at%25206.43.29%2520PM.png" alt="Feature Toggles Permissions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This diagram is borrowed from my colleague Pete Hodgson, who has written a lot about toggles. In this diagram, release toggles is defined as toggles that control access to unfinished code, which is same as feature toggles.&lt;/p&gt;

&lt;p&gt;Ops toggles control the behavior of production code. Retail sites that have heavy seasonal traffic use Ops toggles to provide a degraded experience when they have peak loads. For example, when Apple is releasing a new iPhone and it's getting a crazy amount of traffic coming in just to buy the iPhone, they can turn off features like user recommendations during peak time to support the sales transactions.&lt;/p&gt;

&lt;p&gt;Permissions toggles are used to turn on specific behavior for privileged users, such as admin features, or provide a guest user browsing experience.&lt;/p&gt;

&lt;p&gt;Experimental toggles are used for multivariate testing. It is used to test how well a feature is received before you make it permanent. It's the same as A/B testing.&lt;/p&gt;

&lt;p&gt;One thing to note is that each of these categories of toggles has a very different lifecycle and different way to be turned on and off. You need to plan accordingly. Release toggles generally are more short-lived and only live for the duration of a few releases. Once the feature is completely released, you get rid of the toggle and remove your technical debt. An ops toggle is used frequently for functionality in production, so it lives for much longer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is the part 3 of our CD of Microservices blog series. We have talked in depth about CI practices, in particular trunk based deployment and feature toggles. In the next post, we will talk about the third consideration: environment strategy.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>microservices</category>
      <category>continuousdelivery</category>
      <category>ci</category>
    </item>
    <item>
      <title>Test Strategy for Microservices</title>
      <dc:creator>Sheroy Marker</dc:creator>
      <pubDate>Wed, 06 Feb 2019 01:09:27 +0000</pubDate>
      <link>https://forem.com/gocd/test-strategy-for-microservices-355p</link>
      <guid>https://forem.com/gocd/test-strategy-for-microservices-355p</guid>
      <description>&lt;p&gt;This is the second post in the series - &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html" rel="noopener noreferrer"&gt;Continuous Delivery for Microservices&lt;/a&gt;. &lt;a href="https://www.gocd.org/2018/04/25/five-considerations-continuous-delivery-microservices/" rel="noopener noreferrer"&gt;In my previous post&lt;/a&gt;, I gave an overview of five considerations for building CD pipelines on a microservices architecture. In this post, we’ll get deeper into test strategy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Strategy
&lt;/h2&gt;

&lt;p&gt;A microservices architecture involves many moving parts with different guarantees and failure modes. Testing and verification of these systems are significantly more nuanced and complex than testing a traditional monolithic application. An effective test strategy needs to account for both testing individual services in isolation and the verification of overall system behavior. You can broadly break testing down into two categories: pre-production testing and monitoring and testing in production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh610puekxtc6vjt71gtc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh610puekxtc6vjt71gtc.jpeg" alt="Test Strategies for Microservices" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-production testing of services
&lt;/h2&gt;

&lt;p&gt;Here’s a simple example where you have build pipelines for multiple services and you're testing a service in isolation. In this case, the traditional &lt;a href="https://martinfowler.com/bliki/TestPyramid.html" rel="noopener noreferrer"&gt;test pyramid&lt;/a&gt; helps to maintain a balance between the different types of tests.&lt;/p&gt;

&lt;p&gt;In a typical test pyramid, you have:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit tests&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Tests that cover the smallest piece of testable functionality in your software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration tests&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Integration tests, in this context, deal with testing integrations and interface defects for components within your service; these are more granular tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component tests&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
When you look at component tests for microservices, a component is a service that exposes certain functionalities. Therefore, component tests for microservice can just be acceptance tests for services and your tests need to validate whether the service provides the functionality that it promises to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contract tests&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Another category of tests that's very applicable to microservices are contract tests. They test the contracts of APIs of your services to see if the API is valid or if the microservice honors its API. A cool variation of these contract tests is consumer driven contract tests. These tests are written by consumer services of an API; the consumers codify this contract in a suite of tests that get run on every change to the API. That way, if a change to the API breaks a contract that one of its consumers expect, this breaking change is caught early in the CD pipeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End-to-end tests&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The test suites we discussed earlier are applicable to testing individual services. End-to-end tests, however, are more coarse-grained and try to test the functionality of an overall system. Depending on the deployment architecture you're going for, if you are deploying all of your services in a pre-production environment in an aggregate manner, you can run end-to-end tests there. Since end-to-end tests are usually brittle and take a long time to run, you’ll usually want to restrict the number of these tests to as few as possible. If you have microservices that are completely independent and don't get deployed to a pre-production test environment, then consider approaches that test in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring and testing in production
&lt;/h2&gt;

&lt;p&gt;This traditional style of testing has its limitations. There are categories of errors that you can’t really simulate in test environments. Examples of these sorts of issues include issues caused by eventual consistency in a highly distributed system, and hardware and network failures causing parts of the system to fail. You have to supplement traditional testing techniques with techniques that allow you to profile and monitor systems in production effectively, and the ability to take remedial action in production when things do go wrong. In this post, I will focus on testing in production, and cover remediation strategy in a later part of this series.&lt;/p&gt;

&lt;p&gt;There is a category of testing in production called &lt;a href="https://en.wikipedia.org/wiki/Fault_injection" rel="noopener noreferrer"&gt;fault-injection&lt;/a&gt;, which is introducing errors in a controlled manner in production to see if your system can hold up to those errors.&lt;/p&gt;

&lt;p&gt;A variation of in-production testing are some specific deployment strategies that are popular in these environments:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Canary deployment&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.gocd.org/2017/08/15/canary-releases/" rel="noopener noreferrer"&gt;Canary deployment&lt;/a&gt; is where you take a new release and release it to a certain subsection of your production infrastructure, see how well that goes, and keep increasing the footprint of the new service until the time you completely roll it out. If you face issues, you can start rolling back the new version of your service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6gwrmuyhjd2h3nw1psu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6gwrmuyhjd2h3nw1psu.jpeg" alt="Canary deployments" width="800" height="565"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blue-Green deployment&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.gocd.org/2017/07/25/blue-green-deployments/" rel="noopener noreferrer"&gt;Blue-green deployments&lt;/a&gt; are similar, where you have a new footprint of your new service, and then you do some testing and route some traffic through it. If everything is fine, you switch over all of your traffic to the new instance of services, otherwise, you keep the old footprint going.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F044lnv9l26h56webwjuy.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F044lnv9l26h56webwjuy.jpeg" alt="Blue green deployments" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multivariate testing&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Another interesting variation of this kind of testing is multivariate testing, where you're not really testing your new service against defects, instead, you are A/B testing new release features behind A/B testing toggles. The purpose of this type of testing is to see how well these features are received. You can decide roll it out to your entire set of users or make fixes where necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is part 2 of our &lt;a href="https://www.gocd.org/tags/cd-for-microservices.html" rel="noopener noreferrer"&gt;Continuous Delivery for Microservices&lt;/a&gt; blog series. We have talked in depth about testing strategies for microservices, which include how to apply traditional testing pyramids to pre-production testing for microservices and also new techniques for production monitoring and testing. In my next post, we will talk about the second consideration: CI practices for microservices systems.&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>testing</category>
    </item>
    <item>
      <title>5 Considerations for Continuous Delivery of Microservices</title>
      <dc:creator>Sheroy Marker</dc:creator>
      <pubDate>Mon, 04 Feb 2019 19:27:51 +0000</pubDate>
      <link>https://forem.com/gocd/5-considerations-for-continuous-delivery-of-microservices-n87</link>
      <guid>https://forem.com/gocd/5-considerations-for-continuous-delivery-of-microservices-n87</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8oni7zdeujrjaf3vils.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8oni7zdeujrjaf3vils.jpg" alt="Continuous Delivery of Microservices"&gt;&lt;/a&gt;&lt;br&gt;
A microservices architecture builds software as suites of collaborating services. These architectures are generally accepted as a better way to build apps these days.&lt;/p&gt;

&lt;p&gt;Continuous Delivery is an essential component of any software delivery practice. Regardless of the target deployment environment, you have to design a CD workflow to get software changes into production.&lt;/p&gt;

&lt;p&gt;At ThoughtWorks, while partnering with clients building business-critical software, we overcame many challenges around building CD workflows for microservices. In this blog post, I will share the considerations we keep in mind in architecture design and application development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Microservices and Continuous Delivery
&lt;/h2&gt;

&lt;p&gt;According to &lt;a href="https://martinfowler.com/articles/microservices.html" rel="noopener noreferrer"&gt;Martin Fowler&lt;/a&gt;, microservices architectures are  “a particular way of designing software applications as suites of independently deployable services.” These architectures are prevalent these days for building applications based on distributed systems concepts.&lt;/p&gt;

&lt;p&gt;Jez Humble, in his pioneering book describes continuous delivery as "the ability to get changes of all types - including new features, configuration, bug fixes, and experiments - into production, safely and quickly in a sustainable way."&lt;/p&gt;

&lt;p&gt;Regardless of the target deployment environment or your architecture choice, monolithic architecture in the past or microservices these days, it’s important to design a continuous delivery workflow to get your changes into production. A CD workflow is central to a DevOps process, and spans well across various functions in an organization including your development, QA and IT operations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four Challenges for CD on Microservices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Maintaining the integrity of complex distributed systems.&lt;/strong&gt; Since you decompose a large monolithic system into smaller, more manageable microservices, the overall complexity of the system itself increases. You now have to deal with distributed systems concerns.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Safely and rapidly releasing features constantly.&lt;/strong&gt; Managing frequent feature releases needs special consideration when your features could involve changes in one or many microservices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managing deployments of disparate technology stacks.&lt;/strong&gt; Microservice environments often include disparate technology stacks for services. Managing a deployment process across these different stacks is challenging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Process and tooling for deploying services independently and out of band.&lt;/strong&gt; There are a lot of tools available to model CD workflows. It’s daunting to initially map out your CD workflow and pick tooling that best represents this workflow.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Five Considerations for CD on Microservices
&lt;/h2&gt;

&lt;p&gt;There are five considerations I recommend keeping in mind when you design a CD workflow on microservices architectures. I will have an in-depth discussion for each of them in the following posts of this series. Here is just an overview:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Have an effective test strategy&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh610puekxtc6vjt71gtc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh610puekxtc6vjt71gtc.jpeg" alt="Effective test strategy"&gt;&lt;/a&gt;&lt;br&gt;
Testing and verification of microservice systems is significantly more nuanced and complex than testing a traditional monolithic application. An effective test strategy needs to account for both testing individual services in isolation and the verification of overall system behavior.&lt;/p&gt;

&lt;p&gt;For pre-production testing of services, especially in an isolated manner, traditional testing methodologies are still applicable and relevant. The &lt;a href="https://martinfowler.com/bliki/TestPyramid.html" rel="noopener noreferrer"&gt;test pyramid&lt;/a&gt; can still help you in maintaining a balance between the different types of tests. However, this style of testing has limited effectiveness when testing the aggregate of services. There are categories of errors that you can’t simulate in test environments, for example, issues caused by eventual consistency in a highly distributed system, hardware and network failures causing parts of the system to fail.&lt;/p&gt;

&lt;p&gt;You have to supplement traditional testing techniques with techniques like synthetic user testing, lightweight user acceptance testing and fault injection testing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Examine your CI practices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Continuous integration is a key practice in a successful continuous delivery strategy. Apart from the obvious considerations around build servers and build definitions, &lt;a href="https://trunkbaseddevelopment.com" rel="noopener noreferrer"&gt;trunk based development&lt;/a&gt; and &lt;a href="https://martinfowler.com/articles/feature-toggles.html" rel="noopener noreferrer"&gt;feature toggles&lt;/a&gt; are two key practices that go a long way in implementing a simple and robust CI process.&lt;/p&gt;

&lt;p&gt;In trunk based development, developers collaborate on code in a single branch called “trunk.” The key benefit is to avoid drift in development branches and the resulting merge hell. This is contrary to the practice of maintaining long-lived feature and release branches. In a branching model, though you may be running builds on individual branches, arguably &lt;a href="https://www.gocd.org/2017/05/16/its-not-CI-its-CI-theatre.html" rel="noopener noreferrer"&gt;you aren’t doing continuous integration&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To do trunk based development, you need to have controls called feature toggles. Feature toggles enable multiple commits of a combination of WIP and completed features. With these toggles, you can turn off the manifestation of incomplete features in production, until the features are dev complete and testing sufficiently in pre-production environments. Feature toggles are usually stored in a specification or configuration file close to the codebase and used by automation in the CD pipeline to turn toggles on in specific environments.&lt;/p&gt;

&lt;p&gt;Once you have a mechanism for maintaining feature toggles, you can use the same mechanism to introduce other categories of toggles like release toggles (to control access to unfinished code), Ops toggles (to control the behavior of production code), permissions toggles (to turn on specific behavior for privileged users), and experimental toggles (for multivariate testing - How well a feature is received before you make it permanent).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Plan your environments&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzc7vjtxo8qd4l0gf86r.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzc7vjtxo8qd4l0gf86r.jpeg" alt="Environments plan"&gt;&lt;/a&gt;&lt;br&gt;
An environment plan includes your sets of environments, the intended use of them, strategies to promote artifacts through these environments and toggle states on these environments.&lt;/p&gt;

&lt;p&gt;First, think about what environments are needed and their intended use cases. Different groups in your organization will have different competing needs. When creating an environment, you should cater to all of these competing needs. Secondly, if possible, consider using cloud infrastructure to create environments dynamically. For example, use Kubernetes’ labels capability to create on the fly test environments for automated testing rather than have long lived environments. Thirdly, have an artifact promotion strategy. CD pipelines generate a lot of artifacts. You should you think about: how many artifacts to store, how many repositories you need, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Manage configuration strategically&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An application’s configuration includes everything that varies per deployment and should be stored separately from the code. How should you treat configuration when you have suites of microservices?&lt;/p&gt;

&lt;p&gt;One technique we've seen to be useful is to manage deployment configuration centrally in repositories like &lt;a href="https://www.consul.io/" rel="noopener noreferrer"&gt;Consul&lt;/a&gt; or &lt;a href="https://www.vaultproject.io/" rel="noopener noreferrer"&gt;Vault&lt;/a&gt;. Spreading deployment configurations across tools like &lt;a href="https://www.chef.io/chef/" rel="noopener noreferrer"&gt;Chef&lt;/a&gt; and the CD pipeline just makes it hard to understand and reason.&lt;/p&gt;

&lt;p&gt;Another technique we use is to standardize processes for distributing configuration regardless of the technology stack of your services, and just let services handle the consuming of this configuration depending on the stack.  For example, we generally use the &lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;12-factor recommendations&lt;/a&gt; and avoid distributing configuration files.&lt;/p&gt;

&lt;p&gt;And lastly, secrets like certificates need a governance process to ensure they are managed appropriately. This is usually a manual process but you need to think about it earlier and get it in place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Prepare for things to go wrong&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In microservices systems, multiple services get updated frequently, how do you respond when a deployment of a service introduces instability or bugs?&lt;/p&gt;

&lt;p&gt;Roll forward, which means finding the root cause of a failure and applying the fix as soon as possible, is most times the best remediation response. A prerequisite for being able to do this is to ensure you have the capability to release from a &lt;a href="https://www.gocd.org/2017/06/20/hotfixes-rollback-rollforward/" rel="noopener noreferrer"&gt;hot fix branch&lt;/a&gt; straight to production. You may not want a fix to a production outage to go through the CD pipeline, depending on the time it takes for a change to make it through the pipeline.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tkb13umqdcxs5iplmw5.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tkb13umqdcxs5iplmw5.jpeg" alt="Hotfix process"&gt;&lt;/a&gt;&lt;br&gt;
Rollbacks are always tricky in production systems. In most cases if the change is granular and can be reasoned about, it’s easy to rollback. But if the deployment includes changes that aren’t easy to reason about, e.g., DB changes, especially ones that make schema changes, you need to deploy DB changes separately from code changes in consecutive deployments to ensure backwards compatibility of DB changes with earlier versions of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;This is the part 1 of our Continuous Delivery of Microservices blog series. We have talked about four challenges and five considerations for building CD pipelines on microservices architecture. In the next blog, I will have an in-depth discussion on the first consideration: testing strategy for a system based on microservices architectures.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>microservices</category>
      <category>continuousdelivery</category>
      <category>teststrategy</category>
    </item>
  </channel>
</rss>
