August 25, 2014
Humans are prone to believe any complex system must be designed and managed by super smart individuals manning a set of controls to keep everything running smoothly. And yet we see examples of complex systems in nature like ant hills, beehives, and termite mounds whose basic structures have survived for millions of years, across drastic changes in ecosystems, supported by creatures with very limited intelligence. These species succeed despite the limited intelligence of individuals by following simple rules of coordinated activity, resulting in high survivability and adaptability. Macrotermitine termites in Southern Africa, for example, build mounds that maintain an internal temperature of 87°F even as outside temperatures range from 35°F to 104°F. There is no central thermostat; instead individual termites act to open and close air channels as needed.
Throughout the history of computer software the dominant design approach has been to build in complexity, and allow that complexity to grow over time within and across applications. Different components of these complex, often-called monolithic systems are big, tightly coupled and inseparable. Their bulky design makes changing them a time-consuming and error prone process. That’s because deep patterns of tight interconnections between components ultimately make change a massive coordination exercise. We need a better way to build and evolve systems. Enter microservices architectures.
Microservice architectures are emerging design patterns that implicitly attempt to recreate the collective brilliance of ants, bees and termites, while likewise keeping individual components small and limited. Each microservice is typically less than 100 lines of code and only designed to react to and execute a single task as a part of an event-driven process. A major step forward in the evolution of service-oriented architecture (SOA), microservices teach us what loose coupling truly looks like. As it turns out, we were only paying lip service to loose coupling back in the late 2000s.
The genius of the true loosely coupled, stateless systems (Netflix, Gilt, and Condé Nast being some of the published examples) becomes evident when you consider how malleable and adaptive they are. Microservices clear a path for a more continuous flow of changes to a system.
In a microservices architecture (MSA), loose coupling depends on three factors:
- limited, but very targeted intelligence and thus independence built into the microservices themselves,
- uber intelligence removed from the messaging medium,
- tolerance for many versions of similar microservices – no forced coordination of changes.
That’s how the decoupling happens. If you don’t get rid of smart message medium and use a simpler message passing pipe such as Apache Kafka, you don’t really have loose coupling. That’s a primary reason why first-generation SOA with all the complicated messaging that seemed to be necessary wasn’t successful.
Think for a minute about traditional integration approaches such as enterprise service buses, and how in some ways, even the most advanced ESBs have their heritage in remote procedure call or RPC-based systems. While RPC is an imperative approach to messaging, MSA messaging is reactive. In other words, imperative messages in the old RPC style told the actors (i.e., the services) what to do. In MSA messaging, the actors (the microservices) know what to do—they don’t need to be told.
Microservices need to know how to do one thing: react. Each reaction constitutes a step in the process. Each step can instantly be added to or removed from an event-triggered system (Thanks to Ali Kheyrollahi for his post on Reactive Cloud Actors for his explanation of this phenomenon.)
Fred George, developer and co-founder of Outpace Systems, considers an MSA to mimic a biological system, but the whole dynamic reminds me of ant colonies. Of course, ants are a quite a bit more complicated than microservices, but they’re similarly reactive. Fundamentally, worker ants are food collecting, building machines that function in a collective intelligence mode. When a curious child steps on an anthill and crushes part of it to see what happens, the worker ants immediately react by rushing out to avoid being crushed, but also rush impulsively to protect the queen, the food source and eventually rebuild the tunnels. Ant colonies are complex adaptive systems with very effective collective intelligence. By implication, systems that emulate ant colonies can become adaptive also.
This illustration explains the comparison and contrast we’re are making between microservices and ant colonies. What metaphor would you use? Would be curious to hear your thoughts about messaging styles, the nature of true loose coupling and enabling responsiveness in enterprises.
Bo Parker contributed to this post.