wasAsked.

Polly — Failure Modes & Real Production Scenario: You mentioned using Polly for handling failure modes — what failures did it need to address, and was there a real scenario where the circuit breaker actually tripped?

Dodge Construction Network · Senior Developer · technical

Published

Asked in 2026 · Software Engineering

Community answers

Posted by wasAsked editorial collection

Answer from your real experience: name the failure modes, the policies you used and, if possible, a real incident. Here is the knowledge to structure that answer. Failures resilience policies typically address - Transient network errors: connection resets, DNS hiccups, brief packet loss. - Timeouts from slow dependencies (overloaded third-party APIs, database failovers). - HTTP 5xx errors (502, 503, 504) during deployments or outages of downstream services. - HTTP 429 throttling from rate-limited APIs (respecting Retry-After). - Database transient errors (SQL Azure failovers, deadlocks) — EF Core's EnableRetryOnFailure covers many of these. - Long outages, where retries would make things worse — the circuit breaker's job. Typical Polly setup (.NET 8+ with Microsoft.Extensions.Http.Resilience, built on Polly v8) builder.Services.AddHttpClient<ShippingClient>(...) .AddResilienceHandler("shipping", p => { p.AddTimeout(TimeSpan.FromSeconds(10)); // total time budget p.AddRetry(new HttpRetryStrategyOptions { MaxRetryAttempts = 3, BackoffType = DelayBackoffType.Exponential, UseJitter = true }); p.AddCircuitBreaker(new HttpCircuitBreakerStrategyOptions { FailureRatio = 0.5, MinimumThroughput = 20, SamplingDuration = TimeSpan.FromSeconds(30), BreakDuration = TimeSpan.FromSeconds(30) }); p.AddTimeout(TimeSpan.FromSeconds(2)); // per-attempt timeout }); How the circuit breaker behaves - Closed: calls pass through while failures are monitored. - Open: after the failure ratio threshold is exceeded, calls fail immediately with BrokenCircuitException for the break duration — protecting threads, connection pools and the struggling dependency. - Half-open: a few trial calls test recovery; success closes the circuit, failure opens it again. Describing a real scenario (example structure) "Our shipping-rate provider had an outage of about 15 minutes during a sale. Retries handled the first intermittent errors; when failures exceeded 50%, the circuit opened. Instead of each checkout waiting up to 10 seconds, calls failed fast and we showed a flat shipping estimate as a fallback, so checkout continued. We saw the circuit state changes in our logs and an alert fired from the circuit-open metric. Afterwards we added a per-attempt timeout (initially we only had an overall timeout) and reduced the retry count to avoid amplifying load." If you have not had a real trip in production, say so and explain how you validated it: fault injection with WireMock.Net or Polly's chaos strategies (Simmy), and staging experiments verifying alerts and fallbacks. Honest answers hold up better under follow-up questions.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics