SocketsHttpHandler has been the default handler of HttpClientHandler since .NET 5. This change uses SocketsHttpHandler directly from Kiota, without going through HttpClientHandler.
This change also enables EnableMultipleHttp2Connections, which improves performance when there are over 100 concurrent requests to the same server.
This can be performance tested by starting a HTTP/2 server that holds connections open for some time, and a client which makes over 100 parallel requests. e.g.
server:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(k =>
k.ConfigureEndpointDefaults(e =>
e.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2));
var app = builder.Build();
app.MapGet("/", () => Task.Delay(100));
app.Run();
client:
var client = new ApiSdk.ApiClient(new HttpClientRequestAdapter(new AnonymousAuthenticationProvider())
{ BaseUrl = "https://localhost:5001" });
await client.GetAsync(); // warm up
var stopwatch = Stopwatch.StartNew();
await Parallel.ForEachAsync(
Enumerable.Range(0, 10_000),
new ParallelOptions { MaxDegreeOfParallelism = 200 },
async (_, cancel) => await client.GetAsync(cancellationToken: cancel));
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed);
This causes performance to continue to scale when there are over 100 connections rather than stop scaling at 100 connections. There doesn't seem to be any performance impact, positive or negative, below 100 connections.
SocketsHttpHandler
has been the default handler ofHttpClientHandler
since .NET 5. This change usesSocketsHttpHandler
directly from Kiota, without going throughHttpClientHandler
.This change also enables
EnableMultipleHttp2Connections
, which improves performance when there are over 100 concurrent requests to the same server.This can be performance tested by starting a HTTP/2 server that holds connections open for some time, and a client which makes over 100 parallel requests. e.g.
server:
client:
This causes performance to continue to scale when there are over 100 connections rather than stop scaling at 100 connections. There doesn't seem to be any performance impact, positive or negative, below 100 connections.
fixes https://github.com/microsoft/kiota-http-dotnet/issues/239