This article is featured in the new DZone Guide to Continuous Delivery. Get your free copy for more expert advise on optimizing your CD pipeline, industry statistics, and more.
As software organizations continue to invest in achieving Continuous Delivery (CD) of their applications, we see increased interest in microservices architectures, which–on the face of it–seem like a natural fit for enabling CD.
In microservices (or its predecessor, “SOA”), the business functionality is decomposed into a set of independent, self-contained services that communicate with each other via an API. Each of the services has their own application release cycle, and are developed and deployed independently often using different languages, technology stacks and tools that best fit the job.
By splitting the monolithic application into smaller services and decoupling interdependencies (between apps, dev teams, technologies, environments and tooling), microservices allow for more flexibility and agility as you scale your organization’s productivity.
While things may move faster on the Dev side, microservices do introduce architectural complexities and management overhead, particularly on the testing and Ops side. What was once one application, with self-contained processes, is now a complex set of orchestrated services that connect via the network. This has impact on your automated testing, monitoring, governance and compliance of all the disparate apps, and more.
A key prerequisite for achieving Continuous Delivery is automating your entire pipeline– from code check-in, through Build, Test and Deployments across the different environments–all the way to the production Release. In order to support better manageability of this complex process, it’s important to leverage a platform that can serve as a layer above any infrastructure or specific tool/technology and enable centralized management and orchestration of your toolchain, environments and applications. I’d like to focus on some of the implications microservices have on your pipeline(s), and some best practices for enabling CD for your microservices-driven application.
The Challenges of Managing Delivery Pipelines for Microservices
The “Mono/Micro” Hybrid State
It’s very hard to design for microservices from scratch. As you’re starting with microservices (as a tip: only look into microservices if you already have solid CI, test and deployment automation), the recommendation is to start with a monolithic application, then gradually carve out its different functions into separate services. Keep in mind that you’ll likely need to support this Mono/Micro hybrid state for a while. This is particularly true if you’re rearchitecting a legacy application or are working for an organization with established processes and requirements for ensuring security and regulatory compliance.
As you re-architect your application, you will also need to architect your delivery pipeline to support CD (I’ll expand more on this later on). It’s important that your DevOps processes and automation be able to handle and keep track of both the “traditional” (more long-term) application release processes of the monolith, as well as the smaller-batch, microservices/CD releases. Furthermore, you need to be able to manage multiple microservices – both independently and as a collection – to enable not only Continuous Delivery of each separate service, but of the entire offering.
Increase in Pipeline Variations
One of the key benefits of microservices is that they give developers more freedom to choose the best language or technology to get the job done. For example, your shopping cart might be written in Java, but the enterprise messaging bus uses Erlang. While this enables developers to ‘go fast’ and encourages team ownership, the multitude of services and the different technologies that your pipeline automation would need to support grows considerably.
This need for flexibility creates challenges in terms of the complexity of your pipeline, and its reusability and repeatability. How do you maximize your efforts and reuse established automation workflows across different technologies and tools?
Ensuring Governance and Compliance
With so many independent teams and services, and the diversity of tools and processes, large organizations struggle to standardize delivery pipelines and release approval processes to bring microservices into the fold with regards to security, compliance and auditability.
How do you verify that all your microservices are in compliance? If there’s a breach or failure, which service is the culprit? How do you keep track of who checked-in what, to which environment, for which service, and under whose approval? How do you pass your next audit?
Integration Testing Between Services Becomes More Complex
When testing a service in isolation, things are fairly simple: you do unit testing and verify that you support the APIs that you expose. Testing of microservices is more complicated and requires more coordination. You need to decide how you’re handling downstream testing with other services: do you test against the versions of the other services that are currently in production? Do you test against the latest versions of the other services which are not yet in production? Your pipeline needs to allow you to coordinate between services to make sure that you don’t test against a version of the service that is about to become obsolete.
Supporting the Proliferation of Heterogeneous Environments
Microservices often result in a spike in deployments that you now need to manage. This is caused by the independent deployment pipelines for each service across different stacks/environments, an increase in the number of environments throughout the pipeline, and the need to employ modern deployment patterns such as Blue/Green, Canary, etc.
Deployment automation is one of the key prerequisites for CD, and microservices require that you do a lot of it. You don’t only need to support the volume of deployments; your pipeline must also verify that the environment and version are compatible, that no connected services are affected and that the infrastructure is properly managed and monitored. While not ideal, at times you will need to run multiple versions of your service simultaneously, so that if a service requires a certain version and is not compatible with the newer one, it can continue to operate (if you’re not always backwards compatible).
In addition, microservices seem to lend themselves well to Docker and container technologies. As Dev teams become more independent and deploy their services in a container, Ops teams are challenged to manage the sprawl of containers, and to have visibility into what exactly goes on inside that box.
System-level View and Release Management
System-level visibility is critical not only for compliance, but also for effective release management on both the technical and business sides. With complex releases for today’s microservices-driven apps, you need a single pane of glass into the real-time status of the entire pathof theapplication release process. That way, you ensure you’re on schedule, on budget and with the right set of functionality. Knowing your shopping cart service will be delivered on time does you no good if you can’t also easily pin-point the status of the critical ERP service and all related apps that are required for launch.
Best Practices for Designing CD Pipelines for Microservices
You want to embrace microservices as a means to scale and release updates more frequently, while giving Operations people the platform to not only support developers, but to also operationalize the code in production and be able to manage it. Because microservices are so fragmented, it is more difficult to track and manage all the independent, yet interconnected components of the app. Your goal should be to automate the releases of microservices-driven apps so these are reliable, repeatable and as painless as possible.
When Constructing Your Pipeline, Keep in Mind
- Use one repository per service. This isolation will reduce the engineer’s ability to cross-populate code into different services.
- Each service should have independent CI and Deployment pipelines so you can independently build, verify and deploy. This will make set-up easier, require less tool integration, provide faster feedback and require less testing.
- Plug-in all of your tool chain into your DevOps Automation platform – so you can orchestrate and “automate all the things”: CI, testing, configuration, infrastructure provisioning, deployments, application release processes, and production feedback loops.
- Your solution must be tools/environment agnostic so you can support each team’s workflow and tool chain, no matter what they are.
- Your solution needs to be flexible to support any workflow – from the simplest two-step web front-end deployment to the most complex ones (such as in the case of a complex testing matrix or embedded software processes).
- Your system needs to scale to serve the myriad services and pipelines.
- Continuous Delivery and microservices require a fair amount of testing to ensure quality. Make sure your automation platform integrates with all of your test automation tools and service virtualization.
- Auditability needs to be built into your pipeline automatically so you always record in the background the log of each artifact as it makes its way through the pipeline. You also need to know who checked-in the code, what tests were run, pass/fail results, on which environment it was deployed, which configuration was used, who approved it and so on.
- Your automation platform needs to enable you to normalize your pipelines as much as possible. Therefore, use parameters and modeling of the applications/environment and pipeline processes so you can reuse pipeline models and processes between services/teams. To enable reusability, planning of your release pipeline and any configuration or modeling should be offered via a unified UI.
- Bake in compliance into the pipeline by binding certain security checks and acceptance tests, and use infrastructure services to promote a particular service through the pipeline.
- Allow for both automatic and manual approval gates to support regulatory requirements or general governance processes.
- Your solution should provide a real-time view of all the pipelines’ statuses and any dependencies or exceptions.
- Consistent logging and monitoring across all services provides the feedback loop to your pipeline. Make sure your pipeline automation plugs into your monitoring so that alerts can trigger automatic processes such as rolling back a service, switching between blue/green deployments, scaling and so on.
Keep in Mind
For both Continuous Delivery and microservices, a highly-focused and streamlined automation pipeline is critical to reduce bottlenecks, mitigate risk and improve quality and time-to-market. While some may choose to cobble together a DIY pipeline, many organizations have opted for a DevOps Automation or Continuous Delivery platform that can automate and orchestrate the entire end-to-end software delivery pipeline. This is particularly useful as you scale to support the complexities of multitudes of microservices and technologies. You don’t build your own email server, so why build this yourself?
For more tips on microservices, to learn if it is right for you and how to start decomposing your monolith, checkout the video below of my talk on “Microservices: Patterns and Processes” from the recent DevOps Enterprise Summit.
Now, do it yourself:
Download the community edition of ElectricFlow to build your pipelines and deploy any application, to any environment— for free.
Get your free copy of the new DZone Guide to Continuous Delivery for more insights on DevOps tools, securing your pipeline, plus original research on dev and ops collaboration tools and techniques, release pain points, container adoption rates, barriers to CD, and more.
Latest posts by Anders Wallgren (see all)
- Microservices design: Get scale, availability right - November 18, 2016
- Planning microservices: Know the tradeoffs with monolithic design - November 17, 2016
- Continuous Discussions (#c9d9) Podcast: Episode 55 – Special Episode with Gene Kim and the DOES16 Speakers #4 - October 25, 2016