Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grpc.Net vs Grpc.Core: What are the server side differences?

It seems like Grpc.Net requires ASP.NET Core in order to host a service whereas Grpc.Core doesn't? What are the differences? Which one is preferred?

Grpc.Net

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseRouting();

    app.UseEndpoints(endpoints =>
    {
        // Communication with gRPC endpoints must be made through a gRPC client.
        // To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909
        endpoints.MapGrpcService<GreeterService>();
    });
}

Grpc.Core

Server server = new Server
{
    Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
    Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
};
server.Start();
like image 827
Andrew Pham Avatar asked Oct 23 '25 17:10

Andrew Pham


1 Answers

Grpc.Core is a library that is based on the native implementation of gRPC. It is basically a binding to the native library that makes it possible to use “the original” gRPC directly for both client and server purposes.

Grpc.AspNetCore is a managed reimplementation for gRPC that is built on top of the Kestrel server stack. This makes Grpc.AspNetCore in general a lot more efficient compared to the native implementation. Being built for ASP.NET Core itself, it also integrates a lot more nicely into ASP.NET Core applications which also allows you to host gRPC services side-by-side with other ASP.NET Core endpoints. In contrast, it may not support all gRPC features and is also limited to the server-side aspect.

like image 88
poke Avatar answered Oct 26 '25 20:10

poke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!