question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GRPC dotnet very slow with .net 5 framework

See original GitHub issue

Hello all I’m facing a very weird behavior. I’m using GRPC .net client package (version 2.45.0) on .NET framework 5 as a very stupid client for a grpc server written in Golang. The client -> server communication is in streaming. With GRPC core package the client/server communication run about 15000 operations per second. With GRPC .net client package the communication is about 1200 ops/s.

Please find here below the cliente code:

GRPC core code: ` var chanel = new Channel(“172.25.0.100”, 4424, ChannelCredentials.Insecure); var service = new GrpcService.GrpcServiceClient(chanel); var call = service.AppendItems();

foreach (var i in grpcItems) { await call.RequestStream.WriteAsync®.ConfigureAwait(false); } await call.RequestStream.CompleteAsync(); `

GRPC .net client code: ` var chanel = GrpcChannel.ForAddress(“http://172.25.0.100:4424/”, new GrpcChannelOptions { HttpHandler = new SocketsHttpHandler { EnableMultipleHttp2Connections = true, PreAuthenticate = false, UseCookies = false, PooledConnectionIdleTimeout = Timeout.InfiniteTimeSpan, }, }); var service = new GrpcService.GrpcServiceClient(chanel); var call = service.AppendItems();

foreach (var i in grpcItems) { await call.RequestStream.WriteAsync®.ConfigureAwait(false); } await call.RequestStream.CompleteAsync(); `

Using .net 6 frameworks times are almost the same but I was expecting something faster. Can you kindly point me out on how to improve performances.

Thank you

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ogxdcommented, May 17, 2022

Hello, I’ve encountered the same situation when migrating to Grpc.Net.Client from Grpc.Core where the performance is quite worse. Unfortunately this can be difficult to reproduce, so I made a simple repro here:
➡️ https://github.com/ogxd/grpc-net-client-migration-perf-repro
Just run the unit test, it will setup a server and create clients in both Grpc.Core and Grpc.Net.Client and push some load.

Here are the results when I ask for 10,000 QPS: image

It gets even worse if I ask for 20,000 QPS: image

Tested on a windows laptop with dotnet 6 in release mode.

0reactions
ogxdcommented, Oct 17, 2022

Because the conclusion was that the difference would only be there when under workstation GC and because my application uses server mode GC, I switched to Grpc.Net.Client. There is however an important difference in performance still 😦

image

EDIT: I have experimented a bit and I think this one is unrelated, it looks more related to cancellation management. I have created another issue https://github.com/grpc/grpc-dotnet/issues/1917

Read more comments on GitHub >

github_iconTop Results From Across the Web

gRPC performance improvements in .NET 5
NET 5 client performance is 230% faster than .NET Core 3.1. Stephen Toub discusses dotnet/runtime changes in his Performance Improvements in .
Read more >
Performance best practices with gRPC
There are a couple of workarounds for .NET Core 3.1 apps: Create separate gRPC channels for areas of the app with high load....
Read more >
gRPC performance improvements in .NET 5 : r/dotnet
You can with grpc-web but it is much slower. Better stick to plain fetch or signalr for now between server and spa.
Read more >
Performance Best Practices for Using gRPC on .NET
If you need to make many calls, this may slow down your system substantially. In C#, the gRPC channel is represented by the....
Read more >
Performance slowness while hitting gRPC endpoints first ...
I have a gRPC server running using the protobuf-net.gRPC using .NET Core 3.1. It uses ASP.NET Core framework and Kestrel behind the scenes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found