ThreeMammals / Ocelot

.NET API Gateway

Home Page:https://www.nuget.org/packages/Ocelot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Circuit Breaker behavior in Polly v7 vs v8

RaynaldM opened this issue · comments

Discussed in #2083

Originally posted by anonimousspider June 1, 2024
In Polly v8, we have observed that the circuit breaker functionality is not working as expected. We have experienced issues where the circuit breaker does not trip or reset correctly, leading to inconsistent fault handling. Conversely, in Polly v7, the circuit breaker also exhibits problems, failing to operate smoothly in certain scenarios.
Circuit Breaker Not Tripping

Example

Suppose you have configured an Ocelot route with a circuit breaker policy to trip after three consecutive HTTP request failures:
Route Configuration:

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/api/StudentIdentity/Verify ",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost", "Port": 5001
        }
      ],
      "UpstreamPathTemplate": " api/student/Verify ",
      "UpstreamHttpMethod": [ "Get" ],
      "QoSOptions": {
        "ExceptionsAllowedBeforeBreaking": 3,
        "DurationOfBreak": 10000,
        "TimeoutValue": 5000
      }
    }
  ]
}

Configuration in Program.cs for V7:

services.AddLogging(logging =>
 {
     logging.ClearProviders();
     logging.AddConsole();
                            
 });
 services.AddJwtAuthentication();
 services.AddOcelot().AddPollyV7();

Configuration in program.cs using Polly V8:

services.AddLogging(logging =>
 {
     logging.ClearProviders();
     logging.AddConsole();
                            
 });
 services.AddJwtAuthentication();
 services.AddOcelot().AddPolly();

Expected Behaviour

During runtime, the downstream service fails five consecutive times. The circuit breaker should trip and stop the request to be forwarded , and move to open state as per configured.

Actual behavior

During runtime, the downstream service fails five consecutive times. Despite this, the circuit breaker does not trip and continues to forward requests, instead of moving to the open state after three failures as configured.

Scenario 1

When service response is delayed from the service configured in ocelot.
PollyV7: Its working fine
PollyV8: on applying pollyv8 in the gateway not Working.

Scenario 2

When service is giving 503 error response .
Polly v7 : Its working Fine
Polly v8: Not working.

Scenario 3

When Service is giving 404 error response.
Polly v7 : working fine.
Polly v8: Not working.


Can you please suggest, how to configure Polly v8 with the current Ocelot version 23.2.2?

@RaynaldM
I don't understand this issue description.
How did you verify the user scenarios?

Actual behavior

During runtime, the downstream service fails five consecutive times. Despite this, the circuit breaker does not trip and continues to forward requests, instead of moving to the open state after three failures as configured.

Have you test, check it out?
We have some acceptance tests but we have a problem with them. I will explain you in Slack.

Why did you mark the issue as a hotfix?