Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HttpClient resilience benchmarks #4100

Merged
merged 4 commits into from
Jun 26, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Jun 22, 2023

Addiing a new benchmark that compares no-resilience, standard resilience and standard hedging resilience.

BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22621.1848), VM=Hyper-V
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK=8.0.100-preview.6.23309.5
  [Host] : .NET 8.0.0 (8.0.23.30704), X64 RyuJIT AVX2

Job=MediumRun  Toolchain=InProcessEmitToolchain  IterationCount=15
LaunchCount=2  WarmupCount=10

|                    Method |       Mean |    Error |   StdDev | Ratio | RatioSD |   Gen0 | Allocated | Alloc Ratio |
|-------------------------- |-----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
|             DefaultClient |   236.4 ns |  2.24 ns |  3.28 ns |  1.00 |    0.00 | 0.0191 |     488 B |        1.00 |
| StandardResilienceHandler | 4,101.4 ns | 21.96 ns | 32.19 ns | 17.35 |    0.22 | 0.1602 |    4152 B |        8.51 |
|    StandardHedgingHandler | 8,060.2 ns | 58.09 ns | 85.15 ns | 34.10 |    0.35 | 0.2289 |    5880 B |       12.05 |
Microsoft Reviewers: Open in CodeFlow

@martintmk martintmk self-assigned this Jun 22, 2023
@RussKie
Copy link
Member

RussKie commented Jun 22, 2023

compares no-resilience, standard resilience and standard hedging resilience.

Could you give me a high level overview of these? I'm new to this space, and I'm trying to understand why there's such a significant difference:

Method Mean Allocated
DefaultClient 236.4 ns 488 B
StandardResilienceHandler 4,101.4 ns 4152 B
StandardHedgingHandler 8,060.2 ns 5880 B

Thanks

@martintmk
Copy link
Contributor Author

compares no-resilience, standard resilience and standard hedging resilience.

Could you give me a high level overview of these? I'm new to this space, and I'm trying to understand why there's such a significant difference:

Method Mean Allocated
DefaultClient 236.4 ns 488 B
StandardResilienceHandler 4,101.4 ns 4152 B
StandardHedgingHandler 8,060.2 ns 5880 B
Thanks

Sure!

  • DefaultClient: plain HttpClient without any handlers
  • StandardResilienceHandler: this handler combines 5 Polly V7 policies to improve the resilience. It's the handler we recommend to all production services that required HTTP communication. It consists of these policies:
    • Overal Timeout
    • Rate Limiting
    • Retry
    • Circuit Breaker
    • Attempt Timeout
  • StandardHedgingHandler: hedging handler replaces the retry with hedging policy that is able to improve latency by sending multiple concurrent requests if the pending ones are too slow. Improves p95 latency. In general, used for more advanced scenarios as it requires multiple remote endpoints to work correctly. It consists of these policies:
    • Overal Timeout
    • Rate Limiting
    • Hedging
    • Circuit Breaker
    • Attempt Timeout

@RussKie RussKie requested a review from geeknoid June 26, 2023 03:22
@martintmk martintmk merged commit 04608fd into main Jun 26, 2023
@martintmk martintmk deleted the mtomka/improve-http-benchmarks branch June 26, 2023 06:36
@ghost ghost added this to the 8.0 Preview7 milestone Jun 26, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants