Circuit breaker mechanism for
Microservices based architecture
Kunal Grover
Circuit Breaker
Understanding Microservices: Example Bookstore
Understanding Microservices: Example Bookstore
Designing Microservices
!! DESIGN FOR FAILURES !!
Designing Microservices
!! DESIGN FOR FAILURES !!
(A 20-minute outage at Amazon would cause the company $3.75 million approx.)
Designing Microservices
!! DESIGN FOR FAILURES !!
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
Designing Microservices
!! DESIGN FOR FAILURES !!
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
- Contain and Isolate failures
Designing Microservices
!! DESIGN FOR FAILURES !!
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
- Contain and Isolate failures
- Respect the service when it is slow
Designing Microservices
!! DESIGN FOR FAILURES !!
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
- Contain and Isolate failures
- Respect the service when it is slow
- Fail fast - Recover fast
Typical multi-threaded webapp
Our Application and Users service
• Service latency(avg) =>100ms
• Timeout =>1s
• RPS =>100
• Application threads =>100
Issues with the architectureOur Application
• Service latency(avg) =>100ms
• Timeout =>1s
• RPS =>100
• Application threads =>100
Users service goes down
• Average latency?
• Requests received by dependent
service?
• RPS served?
Did we design for failures?
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
- Contain and Isolate failures
- Respect the service when it is slow
- Fail fast - Recover fast
Circuit breaker
mechanism
Implementation detail
Threads =>
100(RPS) X 0.1(Latency) = 10
Case: Users service is down.
- How many requests get affected?
- How fast do we recover?
Did we design for failures?
- Don’t fail if your microservice goes down
- Application should not forever wait for microservice
- Contain and Isolate failures
- Respect the service when it is slow
- Fail fast - Recover fast
Testing and monitoring!
• IPTables FTW!
Drop connections from IP address: iptables -A INPUT -d 202.54.1.22 -j DROP
Drop connections from port: iptables -A INPUT-p tcp --dport 1080 -j DROP
Testing and monitoring!
• IPTables FTW!
Drop connections from IP address: iptables -A INPUT -d 202.54.1.22 -j DROP
Drop connections from port: iptables -A INPUT-p tcp --dport 1080 -j DROP
• Percentage of rejections happened?
Thank you
• Twitter: @kunalgrover05
• Email: kunalgrover05@gmail.com
• Slides: https://tinyurl.com/RootconfKunal
• Acknowledgements: Alex Koturanov (@alex_koturanov)
Pop Quiz
You have 20 microservices in your single endpoint
application. You monitor P99 latency numbers for each
microservice.
Pop Quiz
Pop Quiz
You have 20 microservices in your single endpoint
application. You monitor P99 latency numbers for each
microservice.
What are you monitoring effectively?
Pop Quiz
You have 20 microservices in your single endpoint
application. You monitor P99 latency numbers for each
microservice.
What are you monitoring effectively?
(0.99)20 = 0.81
Neglected 19% of your customers

Circuit breaker mechanism for Microservices based architecture

  • 1.
    Circuit breaker mechanismfor Microservices based architecture Kunal Grover
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
    Designing Microservices !! DESIGNFOR FAILURES !! (A 20-minute outage at Amazon would cause the company $3.75 million approx.)
  • 7.
    Designing Microservices !! DESIGNFOR FAILURES !! - Don’t fail if your microservice goes down - Application should not forever wait for microservice
  • 8.
    Designing Microservices !! DESIGNFOR FAILURES !! - Don’t fail if your microservice goes down - Application should not forever wait for microservice - Contain and Isolate failures
  • 9.
    Designing Microservices !! DESIGNFOR FAILURES !! - Don’t fail if your microservice goes down - Application should not forever wait for microservice - Contain and Isolate failures - Respect the service when it is slow
  • 10.
    Designing Microservices !! DESIGNFOR FAILURES !! - Don’t fail if your microservice goes down - Application should not forever wait for microservice - Contain and Isolate failures - Respect the service when it is slow - Fail fast - Recover fast
  • 11.
  • 12.
    Our Application andUsers service • Service latency(avg) =>100ms • Timeout =>1s • RPS =>100 • Application threads =>100
  • 13.
    Issues with thearchitectureOur Application • Service latency(avg) =>100ms • Timeout =>1s • RPS =>100 • Application threads =>100 Users service goes down • Average latency? • Requests received by dependent service? • RPS served?
  • 14.
    Did we designfor failures? - Don’t fail if your microservice goes down - Application should not forever wait for microservice - Contain and Isolate failures - Respect the service when it is slow - Fail fast - Recover fast
  • 15.
  • 16.
  • 17.
    Threads => 100(RPS) X0.1(Latency) = 10 Case: Users service is down. - How many requests get affected? - How fast do we recover?
  • 18.
    Did we designfor failures? - Don’t fail if your microservice goes down - Application should not forever wait for microservice - Contain and Isolate failures - Respect the service when it is slow - Fail fast - Recover fast
  • 19.
    Testing and monitoring! •IPTables FTW! Drop connections from IP address: iptables -A INPUT -d 202.54.1.22 -j DROP Drop connections from port: iptables -A INPUT-p tcp --dport 1080 -j DROP
  • 20.
    Testing and monitoring! •IPTables FTW! Drop connections from IP address: iptables -A INPUT -d 202.54.1.22 -j DROP Drop connections from port: iptables -A INPUT-p tcp --dport 1080 -j DROP • Percentage of rejections happened?
  • 21.
    Thank you • Twitter:@kunalgrover05 • Email: kunalgrover05@gmail.com • Slides: https://tinyurl.com/RootconfKunal • Acknowledgements: Alex Koturanov (@alex_koturanov)
  • 22.
    Pop Quiz You have20 microservices in your single endpoint application. You monitor P99 latency numbers for each microservice.
  • 23.
  • 24.
    Pop Quiz You have20 microservices in your single endpoint application. You monitor P99 latency numbers for each microservice. What are you monitoring effectively?
  • 25.
    Pop Quiz You have20 microservices in your single endpoint application. You monitor P99 latency numbers for each microservice. What are you monitoring effectively? (0.99)20 = 0.81 Neglected 19% of your customers