Creating Circuit Breaker with 100 Lines of Code

Creating Circuit Breaker with 100 Lines of Code

Creating Circuit Breaker with 100 Lines of Code. “If you want to avoid your entire service going down because one component is down, you should use a circuit breaker,”

“If you want to avoid your entire service going down because one component is down, you should use a circuit breaker,” Kevin told me when I try to design one of our microservices. We talked in front of the ramen shop on a cold winter night in New York City in 2019.

I asked him, “What is it exactly, circuit breaker?”, “Dude! It is a popular microservice pattern. Search it up!”

I pull out my phone and start typing “Circuit Breaker.” In brief, it a mechanism that helps improve the resiliency of your services. I thought to myself, I need to understand more about the tool of this. Therefore, I determined to go back that day, do more research, and implement my own circuit breaker version.

Surprise, surprise — as always, I procrastinated. Fast forward 2 years later, I have learned so much about distributed systems,  Scala, and  functional programming — and I would like to share the what and the how of circuit breaker mechanism. In this article, I would like to share how I created a circuit breaker library using scala and leveraging the concurrent primitive types.

What is Circuit Breaker

Imagine when you request an HTTP call from one service to the other. It may result in multiple conditions. You may get a successful response. However, you may also get a failure response. In case of failure, we usually will return a failure or will do a retry. If it is a retry, you usually will keep doing it in another thread until success.

scala software-engineering microservices

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

Testing Microservices Applications

In this article, look at different ways to test microservices and how you can have a suitable testing strategy to begin with.

Science and Engineering in Software Architecture

Science and Engineering in Software Architecture - We are passing through tough times, “The moment everything changed” with COVID-19, quarentine, people trying adapt their day to day…

Custom Software vs Off-the-shelf Software: How to select a better one for your business?

Custom Software or Off-the-shelf software, the question in mind for many business personnel. Read this blog to get help to make right decision that will benefit your business.

Things Every Software Engineer Should Know: The Builder Pattern

Things Every Software Engineer Should Know: The Builder Pattern - What is the builder pattern? Why is it useful?