InterviewSolution
| 1. |
How does Hystrix implement Bulkhead Design Pattern? |
|
Answer» The bulkhead implementation in Hystrix limits the number of CONCURRENT calls to a component/service. This way, the number of resources (typically threads) that are waiting for a reply from the component/service is limited. Let's assume we have a fictitious web e-commerce application as shown in the figure below. The WebFront communicates with 3 different components using remote network calls (REST over HTTP).
Now let's SAY due to some problem in Product Review Service, all requests to this service start to hang (or timeout), eventually causing all request handling threads in WebFront Application to hang on waiting for an answer from Reviews Service. This would make the entire WebFront Application non-responsive. The resulting behavior of the WebFront Application would be same if request volume is high and Reviews Service is taking TIME to respond to each request. The Hystrix Solution Hystrix’s implementation for bulkhead pattern would limit the number of concurrent calls to components and would have saved the application in this case by GRACEFULLY degrading the FUNCTIONALITY. Assume we have 30 total request handling threads and there is a limit of 10 concurrent calls to Reviews Service. Then at most 10 request handling threads can hang when calling Reviews Service, the other 20 threads can still handle requests and use components Products and Orders Service. This will approach will keep our WebFront responsive even if there is a failure in Reviews Service. |
|