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

Is Grpc.AspNetCore slower than WebApi and Grpc.Core? #628

Closed
RiccoYuan opened this issue Oct 25, 2019 · 4 comments
Closed

Is Grpc.AspNetCore slower than WebApi and Grpc.Core? #628

RiccoYuan opened this issue Oct 25, 2019 · 4 comments
Labels
question Further information is requested

Comments

@RiccoYuan
Copy link

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
@RiccoYuan RiccoYuan added the question Further information is requested label Oct 25, 2019
@JamesNK
Copy link
Member

JamesNK commented Oct 25, 2019

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

@davidfowl
Copy link
Contributor

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

@RiccoYuan
Copy link
Author

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.

@JamesNK
Copy link
Member

JamesNK commented Nov 3, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants