Comparing REST and gRPC performance

Hello, Habr. For future students of the "Highload Architect" course we prepared a translation of the material.



We also invite you to register for an open webinar on the topic "Replication as a Pattern of Storage Scale- Out " with Vladislav Rodin (Team Leader and Java Enterprise Development Specialist). In this lesson, participants will walk through replication, one of the database scaling techniques.






I have several microservices that communicate with each other using JSON over REST, and it seems to me that soon they will reach the VPS performance limit, and I will need to upgrade it so that there is no performance drawdown.





, gRPC ( ) , , , gRPC.





gRPC?

, gRPC, gRPC โ€” (RPC, remote procedure calls), Google, . , (, , ) - IDL (stub), . REST ASP.NET Core WebAPI.





JSON REST, gRPC Protocol Buffers โ€” . gRPC REST. Protocol Buffers protoc, proto-. , gRPC HTTP/2, , HTTP- .





, :





  • -. , .





  • . . .





  • , . .





  • ModelLibrary REST gRPC-. , , , , . NASA , 1000 , .





Sample NASA Meteorite Data
NASA

gRPC- Protocol Buffers .





Protocol Buffer Definitions for Messages
Protocol Buffer

(stream) gRPC GetLargePayload



.





Protocol Buffer Definitions for Services
Protocol Buffer
  • RestAPI WebAPI, , : , .





ASP.NET MVC Core routing
ASP.NET MVC Core

, , .





Reducing the logging level for ASP.NET MVC Core WebAPI
ASP.NET MVC Core WebAPI
  • GrpcAPI gRPC-. , GetLargePayload



    , .





GrpcAPI service implementation
GrpcAPI
  • RESTvsGRPC , 100 200 , . , 100 200 .





RESTvsGRPC benchmark
RESTvsGRPC

 

, gRPC , . REST. gRPC , . , HTTP/2, , HTTP.





Benchmark results in Linux
Linux

Windows . Windows .





Benchmark results in Windows
Windows
REST vs GRPC performance
REST vs GRPC

, EmperorRXF/RESTvsGRPC





, .





RestAPI: dotnet run -p RestAPI -c Release







GrpcAPI: dotnet run -p GrpcAPI -c Release







.





: dotnet run -p RESTvsGRPC -c Release







gRPC REST . Protocol Buffers HTTP/2 gRPC.





gRPC 45 10 WebAPI. , REST , ( , ASP.NET Core MVC) ( ). gRPC, , , , protoc, Visual Studio . , , ItemGroup "Protobuf" csproj-. , gRPC ASP.NET Core 3.0.





, gRPC. 






"Highload Architect".





ยซ ยป








All Articles