Grpc-dotnet: Is Grpc.AspNetCore slower than WebApi and Grpc.Core?

Created on 25 Oct 2019  路  4Comments  路  Source: grpc/grpc-dotnet

Dear all:
I am sorry to ask such a question because of my ignorance.

But I did a test to implement a SayHi service using Grpc.AspNetCore, WebApi, Grcp.Core, I tested it multiple times with loop calls and parallel calls. Then I found that Grpc.AspNetCore is slower than WebApi, and WebApi is slower than Grcp.Core. They are all based on .netcore3.0, And run in the same configuration of the Docker container, of course, the results of my local development environment test is the same.

This is my test program
I am a beginner who loves gRPC. I hope someone can answer my confusion. Thanks very much!

The following is my test results:
1000 For loop calls, inside the loop create a new connection each time

| Project / Time Lapse (ms) |Average | Minimum | Maximum |
| --------------------- | ------ | -------- | -------- |
| GrpcService(Grpc.AspNetCore) | 13.113 | 9 | 738 |
| GrpcServiceConsoleApp(Grcp.Core) | 2.854 | 1 | 176 |
| WebApi | 6.331 | 5 | 56 |

1000 For loop calls, only create a connection outside the loop

| Project / Time Lapse (ms) | Average | Minimum | Maximum |
| --------------------- | --------- | -------- | -------- |
| GrpcService(Grpc.AspNetCore) | 5.649 | 4 | 18 |
| GrpcServiceConsoleApp(Grcp.Core) | 2.178 | 1 | 131 |
| WebApi | 1.155 | 1 | 7 |

1000 Parallel parallel calls, here only tested every time a new connection is created

| Project / Time Lapse (ms) | Average | Minimum | Maximum |
| --------------------- | --------- | -------- | -------- |
| GrpcService(Grpc.AspNetCore) | 13296.676 | 10875 | 17642 |
| GrpcServiceConsoleApp(Grcp.Core) | 2350.708 | 471 | 3652 |
| WebApi | 8128.383 | 943 | 10645 |

question

Most helpful comment

I'll look into your results when I have some time.

Our benchmarks are here: https://msit.powerbi.com/view?r=eyJrIjoiYTZjMTk3YjEtMzQ3Yi00NTI5LTg5ZDItNmUyMGRlOTkwMGRlIiwidCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0NyIsImMiOjV9

Yellow is Grpc.AspNetCore, blue is Grpc.Core

image

All 4 comments

I'll look into your results when I have some time.

Our benchmarks are here: https://msit.powerbi.com/view?r=eyJrIjoiYTZjMTk3YjEtMzQ3Yi00NTI5LTg5ZDItNmUyMGRlOTkwMGRlIiwidCI6IjcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0NyIsImMiOjV9

Yellow is Grpc.AspNetCore, blue is Grpc.Core

image

My guess would be that you haven't disabled logging?

My guess would be that you haven't disabled logging?

Do you mean to disable the default log?
.ConfigureLogging(config => { config.ClearProviders(); })
I disabled the default log and tested it again to get the same result.

These are the results from perf/benchmarkapps/grpcaspnetcoreserver:

Results:
GrpcRaw-UnaryWorker request: 74876
GrpcNetClient-UnaryWorker request: 72917
GrpcNetClient-PingPongStreamingWorker request: 157353
GrpcNetClient-ServerStreamingWorker request: 2681641
JsonRaw request: 75976
JsonMvc request: 65798
GrpcCore-UnaryWorker request: 112321
GrpcCore-ServerStreamingWorker request: 681880
GrpcCore-PingPongStreamingWorker request: 163643

All of these are against the Grpc.AspNetCore server.

GrpcRaw = using raw HttpClient to send gRPC
GrpcNetClient = Grpc.Net.Client
GrpcCore = Grpc.Core
JsonRaw = JSON response from a request delegate
JsonMvc = JSON response from MVC/WebAPI

Grpc.Net.Client has some issues with unary calls but it is still faster than JSON + WebAPI.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JunTaoLuo picture JunTaoLuo  路  5Comments

JamesNK picture JamesNK  路  3Comments

damienbod picture damienbod  路  6Comments

thefringeninja picture thefringeninja  路  4Comments

JunTaoLuo picture JunTaoLuo  路  5Comments