DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Cloud-Native Microservices With Circuit Breakers and Service Discovery

Cloud-Native Microservices With Circuit Breakers and Service Discovery

Because monoliths aren't realistic anymore, new design patterns have to emerge to solve the challenges of independent, distributed microservices.

Kai Wähner user avatar by
Kai Wähner
CORE ·
Jan. 24, 17 · Opinion
Like (11)
Save
Tweet
Share
56.56K Views

Join the DZone community and get the full member experience.

Join For Free

Cloud-native microservices offer many benefits. You can develop, test, 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 reason, 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 in which you have even more independent, distributed, and scaled business logic. Thus, as I discussed around two years ago, microservices might be the death of the Enterprise Service Bus, but integration and middleware (and other things like API management and cloud-native concepts) will be needed more than ever before for microservice architectures.

Circuit Breaker Design Pattern

The circuit breaker is one of the cloud-native design patterns. It offers the following benefits.

  • 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. In a microservice architecture, there can be many reasons or issues. The rejection is configured by various parameters such as request volume threshold and error threshold percentage.

Martin Fowler has a great explanation of the circuit breaker design pattern. Therefore, I will just explain it using one of his graphics:

circuit breaker diag

The circuit is closed in the beginning. All service requests get a successful response from the service. If a threshold of five failures is reached, the circuit is opened. New service requests are rejected. After a timeout of one 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.

Hystrix: The Netflix Open-Source Implementation

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 and 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:

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.

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 developers 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 breakers and service discovery and integrate natively with 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 it did before it was leveraging cloud-native concepts.

The following shows the demo setup for the two videos recordings below. It includes several cloud-native components.

architecture diagram

With a focus on Circuit Breakers, we use TIBCO's BWCE, Docker, and Netflix’s 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:

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.

Conclusion

The following video shows how to use BWCE with Netflix’s Hystrix to develop, deploy, and monitor cloud-native middleware microservices:

In the next video, you can see how to deploy an independent middleware microservice using 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.

microservice Service discovery Circuit Breaker Pattern Kubernetes Discovery (law) Architecture Middleware Open source Docker (software)

Published at DZone with permission of Kai Wähner, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Was the Question Again, ChatGPT?
  • API Design Patterns Review
  • Microservices Discovery With Eureka
  • 7 Awesome Libraries for Java Unit and Integration Testing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: