Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Red Hat Summit: Lowering the risk of monolith to microservices

May 21, 2018
Doug Tidwell
Related topics:
Microservices
Related products:
Red Hat OpenShift

Share:

    Christian Posta, Chief Architect at Red Hat, presented the story of a fictitious company1 moving a monolithic application to microservices.

    When considering risk, we think we know the bad things that can happen and the probabilities of those bad things actually happening. Christian defines a monolith as a large application developed over many years by different teams that delivers proven business value while being very difficult to update and maintain. Its architecture, elegant at one point, has eroded over time. That makes it difficult to assess the risk of migrating a monolith.

    Let's hear from the new school:

    Microservice is a highly distracting word that serves to confuse developers, architects, and IT leaders into believing that we can actually have a utopian application architecture.

    Um, no. While that's cynical but true, the correct definition is:

    Microservices are an architectural optimization that treats the modules of an application as independently owned and deployed services for the purpose of increasing an organization's velocity and eliminating technical debt.

    The performance of an IT organization has a strong correlation to business performance, boosting productivity, profitability, and market share2. Statistics over the last few years for high performers versus low performers include moving code from commit to production 200x faster3, deployments being 46x more frequent, and the lead time for changes being 440x faster4. Technologies and techniques such as containers, automated testing, and deployment pipelines enable teams to go faster. In addition, high-performing teams are introducing errors at a much lower rate and are recovering from the errors they do create at a much higher rate.

    When considering microservices, the goal is not to pursue a microservice architecture mindlessly. The goal is to use microservices where they make sense. Specifically, to use microservices to speed up development, to lower the risk of bad things happening, and to make it simpler to understand and recover from bad things when they happen. (Which, of course, they probably will.)

    The case study Christian covered is the TicketMonster demo. Originally written for JBoss, the code has been around for at least a decade and has become, in Christian's words, "a morass of stuff." Maintaining this or any other monolith is a major pain for a long list of reasons:

    • Making changes in one place negatively affects unrelated areas
    • We have low confidence that reasonable changes won't break something somewhere else
    • We spend lots of time coordinating work among team members
    • The structure of the application has eroded or is non-existent
    • We have no way to quantify how long code merges will take
    • Development is tedious because the project is so big (the IDE bogs down, running tests take forever, bootstrap times are long, etc.)
    • Changes to one module force changes across other modules
    • Sunsetting outdated technology is difficult
    • We may have to base new applications on old approaches like batch processing
    • The monolith gets in its own way when managing resources, allocations, and computations.

    All of these factors make microservices attractive. But it's important to remember that microservices are about optimizing for speed. You need to ask yourself the question, "Is the architecture of our application the bottleneck that keeps us from moving faster?" If it's not, Christian prescribes a three-step process:

    1. Figure out what is keeping you from moving faster.
    2. Fix that.
    3. Come back and look at microservices again.

    If microservices are a good fit for you, the question is how to break a monolith into microservices. Some common approaches include, "Do one thing and do it well," "Organize around verbs," "Organize around nouns," and "Focus on products not projects." We said similar things about SOA back in the day, however. "Services are autonomous," "Loose coupling is vital," "Boundaries are explicit," were equally high-minded goals that often eluded us. So we have platitudes on what the system should be, but no real guidelines on how to make it happen. A more sophisticated approach:

    • Identify modules and boundaries (aka use domain-driven design)
    • Align to business capabilities
    • Identify data entities responsible for features and modules
    • Break out those entities and wrap them with APIs or services
    • Update old code to call the new APIs

    That's all well and good, but it misses a lot of detail5. As usual, reality rears its ugly, pointy little head, presenting difficult problems that can't be waved away:

    • It's not easy to modularize a monolith. If it were, the teams that maintained the monolith over the years would have kept it modular.
    • There are often tight couplings and integrity constraints with an SQL database. This is often overlooked. The database backing the monolith probably has normalized tables and referential integrity in place. Disregarding that can be disastrous. (In fact, it almost certainly will be disastrous.)
    • It's difficult to understand which modules use which tables in the database.
    • As appealing as it might be, we can't shut down the enterprise to do migrations.
    • There will be some ugly migration steps that can't be wished away. You'll have to undo the existing technical debt accrued over the years.
    • Finally, there is probably a point of diminishing returns at which it simply doesn't make sense to break any more things out of the monolith6.

    Yet another list—you need to make sure that these things are in place:

    • Test coverage for the existing project7 (consider Arquillian for integration testing. Also consider Michael Feathers' book Working Effectively with Legacy Code.)
    • Some level of monitoring to detect issues, exceptions, etc.
    • Some level of black-box system tests and load testing in place (JMeter and Gatling can help here)
    • The ability to deploy to an environment reliably (OpenShift or Kubernetes)
    • Some kind of CI/CD pipeline to make changes economical

    Moving on to the sample monolith...the Ticket Monster code has the UI baked in to it. If possible, a good first step is to break the UI out of the monolith. That gives you the freedom to bring the UI into the modern era, and it also sets the stage for the separation of concerns that is promised by a microservices architecture. Start by making a copy of the UI code separate from the monolith by taking out all the JavaScript, CSS, etc. The new UI simply calls the back-end systems of the monolith. You can then do a dark launch or a canary deployment of the new UI, sending only some production traffic to it as you verify that the new UI is functionally equivalent to the original.

    With that in mind, Christian stressed the difference between deployments and releases. A deployment is simply code that lives on a production server but doesn't get any traffic. It isn't considered a release until it's using live data in a production environment. A deployment should be a non-event to the business. Developers should be able to deploy code without approvals or intervention by administrators or the ops staff. Deciding to route production traffic to the deployment, on the other hand, is a business decision made once the deployment has been tested thoroughly.

    The Istio service mesh makes this easy in an OpenShift / Kubernetes environment. It is an infrastructure that allows you to separate deployments and releases. (Read Don Schenck’s excellent Introduction to Istio blog series to fully understand this technology.) Istio lets you say that only 1% of the traffic should go to the new deployment or that only users who have certain characteristics should see the new deployment. Another definition:

    A service mesh is a decentralized application networking infrastructure among your services that provides resiliency, security, observability, and routing control. A service mesh is comprised of a control plane and a data plane.

    Istio works via sidecar proxies. Every service in the service mesh has a proxy beside it. Any traffic meant for a service first goes to the sidecar proxy. Istio controls the sidecar proxy to determine how or when or if that traffic is actually delivered to the service. This approach allows you to manage all the microservices in your service mesh without changing any code..

    Continuing the refactoring of the monolith, we can take a particular function of the monolith and move that code into a service. The starting point, once again, is to copy the code from the monolith and put it into a separate module. Then we can use Istio to route only some of the traffic to the new service. To maximize the value of our investment, the service we choose should be something that provides significant business value. In other words, we look at the monolith and determine that some part of the system could give us a substantial ROI if we made it more agile and flexible. In the Ticket Monster example, the order processing functions could be far more valuable to the business if they were in a separate module that could be enhanced independently of the monolith. For example, if that code was written a decade ago, it doesn't support things like ApplePay or Venmo. A low-risk architecture for adding new methods of payment would clearly help the business stay current.

    To sum up:

    • Write lots of tests. For the monolith if you can, but definitely for the new services.
    • Use advanced techniques such as canary deployments and other fine-grained traffic control to manage the transition from deployments to releases.
    • Reduce boilerplate code for data integration in the initial service implementation.
    • Use technical debt to your advantage.
    • Have lots of monitoring in place.
    • Leverage your deployment and release infrastructure to experiment and learn about your system as you go forward.

    This was a great session with lots of practical advice based on real-world experience. If you'd like to get it from the source, the video of Christian's presentation is one of the 100+ Red Hat Summit 2018 breakout sessions you can view online for free.

    Good luck with your enterprise modernization!

    Learn more about microservices architecture on developers.redhat.com.

    Resources:

    • Christian's slides for this presentation on SlideShare
    • Christian and Burr Sutter's new book: Introducing Istio Service Mesh for Microservices
    • Christian's book: Microservices for Java Developers: A Hands-on Introduction to Frameworks and Containers
    • Christian's articles on developers.redhat.com/blog

    Footnotes:

    1. Fictitious, but based on a true story. Many of them, in fact.
    2. See Puppet.com: 2014 State of DevOps report.
    3. See Puppet.com: 2015 State of DevOps report.
    4. See Puppet.com: 2017 State of DevOps report.
    5. What, you were expecting a full, prescriptive recommendation from a blog post? Sorry, but the real world is more complicated than that.
    6. You can stab it with your steely knives, but you just can't kill the beast.
    7. One definition of legacy code is "code that doesn't have any tests."’
    Last updated: June 27, 2023

    Recent Posts

    • How Trilio secures OpenShift virtual machines and containers

    • How to implement observability with Node.js and Llama Stack

    • How to encrypt RHEL images for Azure confidential VMs

    • How to manage RHEL virtual machines with Podman Desktop

    • Speech-to-text with Whisper and Red Hat AI Inference Server

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue