What is the best order to apply multiple Polly policies?

Viewed 1234

The order in which Polly policies are encapsulated change the final result. Which is the best order if I want to use the following policies? This is the best order I could think of: the retries should be submitted to the bulkhead limits, and the circuit breaking is a lower-level policy that follows the timeout policy. Makes sense?

services.AddHttpClient<IService, Service>()
                .AddPolicyHandler(PolicyConfig.RetryPolicy);     
                .AddPolicyHandler(PolicyConfig.BulkheadPolicy)
                .AddPolicyHandler(PolicyConfig.CircuitBreakingPolicy)
                .AddPolicyHandler(PolicyConfig.TimeoutPolicy)
0 Answers
Related