Cloud-native microservices offer many benefits. You can develop, test and deploy and maintain independent lightweight services. You can easily combine various technologies, including programming languages such as Java or Go, and tools like integration middleware.
However, as you do not build monoliths anymore, ”that complexity has moved and […] increased [to] the outer architecture” as Gartner states. For this reasons, new design patterns have to emerge to solve the challenges of independent, distributed microservices.
Middleware is used to interconnect everything. This is even more important in microservice architectures, where you have even more independent, distributed and scaled business logic. Thus, as I discussed around two years ago already: Microservices might be the death of the Enterprise Service Bus, but integration and middleware (and other things like API Management or cloud native concepts) will be needed more than ever before for microservice architectures.
Circuit Breaker Design Pattern for Resilient Microservice Architectures
The Circuit Breaker is one of these cloud-native design patterns. It allows:
- Fail fast and rapidly recover
- Prevent cascading failures
- Latency tolerance logic
- Fault tolerance logic
- Fallback options
This is realized by rejecting service requests if a service is not available for whatever reason, and in a microservice architecture there can be many reasons or issues. The rejection is configured by various parameters such as request volume threshold or error threshold percentage.
Martin Fowler has a great explanation of the Circuit Breaker design pattern. Therefore, I will just explain it shortly using one of his graphics:
The circuit is closed in the beginning. All service requests get a successful response from the service. If a threshold of 5 failures is reached, the circuit is opened. New service requests are rejected. After a timeout of 1 minute, a new service request tries if the service is available again; therefore the circuit is half open in this state. Depending on the success or failure, the circuit is opened or closed after this service request.
This relatively simple pattern can get very powerful (depending on the configuration options) and allows us to build resilient microservice architectures with reduced latency and lowered resource consumption.
The Netflix Open Source Implementation: ‘Hystrix’
Hystrix was open sourced by Netflix a few years ago and is by far the most widely used framework for using the circuit breaker pattern in a microservices architecture.
Microservice architectures and cloud-native platforms such as CloudFoundry or Kubernetes can leverage Hystrix to build resilient microservice deployments. In addition, you can use the Hystrix Dashboard to get some near real time visualization. The video “Hystrix Dashboard – Tech Talk and Demo” shows a great introduction. Here is a screenshot explaining the key aspects of the dashboard:
The dashboard does its job. But in a more sophisticated microservices architecture, you might leverage the benefits or a real time streaming analytics visualization tool such as Zoomdata, Striim or TIBCO Live Datamart. This allows not just monitoring live streaming data, but also applies continuous aggregations, rules, consolidation and predictive analytics for automated or human-driven decision-making instead of just showing a monitoring dashboard for every microservice.
Resilient Integration Microservices with Netflix’ Hystrix and Middleware
A resilient architecture is even more important for integration services because they interconnect everything. If the integration service is not resilient, fails all the time or get irresponsive, the complete enterprise gets into trouble. Therefore, circuit breakers can help a lot to make integration services more resilient.
A few middleware vendors already adopted cloud-native principles and offer native out-of-the-box support in their offerings. For example, Red Hat’s Middleware Services run on the Kubernetes-based OpenShift PaaS. WSO2 is another open source middleware vendor which already supports cloud-native platforms like Kubernetes. TIBCO offers BusinessWorks Container Edition (BWCE), which allows to build, test and package an integration microservice once, and deploy it everywhere, including Docker, Kubernetes and CloudFoundry.
Note that cloud-native means much more than just putting your middleware into a Docker container! You need to support cloud-native concepts like circuit breaker or service discovery and integrate natively with these frameworks like Hystrix, Consul or Eureka! If you just put your existing application or middleware software into a container, then you just “cloud wash” your solution and your architecture still looks like before not leveraging cloud-native concepts.
The following shows the demo setup for the two videos recordings below. It includes several cloud native components:
With focus on Circuit Breakers, we use TIBCO BusinessWorks Container Edition (BWCE), Docker and Netflix’ Hystrix. The same could be achieved on other cloud-native platforms like Kubernetes or CloudFoundry in the same way.
BWCE offers out-of-the-box support for circuit breakers. You just enable it and configure the required parameters:
Details about the configuration and options can be found in the BWCE documentation. In the same way, you can also leverage service discovery frameworks like Consul or Eureka, and combine that with cloud-native platforms like Kubernetes or CloudFoundry.
Live Video: Development, Deployment and Monitoring with TIBCO BWCE and Hystrix Dashboard
The following video shows how to use BWCE with Netflix’ Hystrix Open Source Implementation of the Design Pattern ‘Circuit Breaker’ to develop, deploy and monitor cloud native middleware microservices.
In the next video you can see how to deploy an independent middleware microservice Docker, Kubernetes and Cloud Foundry without re-compiling, re-testing or re-packaging:
I appreciate any feedback or questions about cloud-native middleware or any other related topic.