Git Product home page Git Product logo

grpcvsrest's Introduction

Benchmark gRPC x REST no .NET Core

Este repositório contém o benchmark que possibilita a comparação entre o desempenho em relação ao tempo de execução do gRPC (HTTP/2 com Protobuf) e do REST (HTTP com JSON).

Para geração dos resultados foi utilizada a library open-source BenchmarkDotNet.

Para executar os projetos, em um prompt de comando, seguir as instruções abaixo.

API REST

cd gRPCvsREST\RestAPI

dotnet run -c Release

Serviço gRPC

cd gRPCvsREST\GrpcService

dotnet run -c Release

Benchmark (gRPC x REST)

cd gRPCvsREST\Client

dotnet run -c Release

Resultado do Benchmark

BenchmarkDotNet=v0.12.1, OS=macOS Catalina 10.15.2 (19C57) [Darwin 19.2.0]
Intel Core i5-7267U CPU 3.10GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.0.101
  [Host]     : .NET Core 3.0.1 (CoreCLR 4.700.19.51502, CoreFX 4.700.19.51609), X64 RyuJIT
  DefaultJob : .NET Core 3.0.1 (CoreCLR 4.700.19.51502, CoreFX 4.700.19.51609), X64 RyuJIT
Method IterationCount Mean Error StdDev Median
GrpcGetMessage 100 529.1 μs 33.57 μs 92.46 μs 488.9 μs
RestGetMessage 100 1,672.9 μs 134.39 μs 370.14 μs 1,578.7 μs
GrpcGetMessage 200 502.1 μs 19.31 μs 55.70 μs 485.5 μs
RestGetMessage 200 1,321.6 μs 43.17 μs 117.45 μs 1,274.3 μs

Tempo de execução: 00:05:33 (333.29 segundos)

Legenda

  • IterationCount: valor do parâmetro 'IterationCount'
  • Mean: média aritmética de todas as medições
  • Error: metade do intervalo de confiança de 99,9%
  • StdDev: desvio padrão de todas as medições
  • Median: valor que separa a metade mais alta de todas as medições
  • 1 us: 1 microssegundo (0.000001 segundo)

Gráfico

O gRPC apresentou desempenho melhor que o REST, conforme evidenciado no benchmark. O gRPC foi projetado para HTTP/2, uma revisão importante do HTTP que fornece benefícios significativos de desempenho. As mensagens gRPC são serializadas usando o Protobuf, um formato de mensagem binária eficiente. Protobuf serializa muito rapidamente no servidor e cliente.

grpcvsrest's People

Contributors

dependabot[bot] avatar lsilvadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

grpcvsrest's Issues

Problema de performance

HttpClient client = new HttpClient();

O seu teste está sendo impactado pela criação continua do HttpClient. Ele é um objeto pesado que por boa prática, é interessante reutilizá-lo.

Veja a documentação oficial.

https://docs.microsoft.com/pt-br/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net

Disable Console logging

When console logging is disabled in appsettings file both gRPC and REST - you will find that REST is far superior to gRPC. This contradicts with the initial gains observed with logging enabled. What are your thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.