From 5f481555e3911ad2c23924bbdce3fe937bf3df49 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 2 Sep 2020 11:11:37 +1200 Subject: [PATCH] Remove inter-process communication doc --- aspnetcore/grpc/interprocess.md | 95 --------------------------------- aspnetcore/grpc/performance.md | 6 --- aspnetcore/toc.yml | 2 - aspnetcore/whats-new/2020-08.md | 1 - 4 files changed, 104 deletions(-) delete mode 100644 aspnetcore/grpc/interprocess.md diff --git a/aspnetcore/grpc/interprocess.md b/aspnetcore/grpc/interprocess.md deleted file mode 100644 index 6d624258ec41..000000000000 --- a/aspnetcore/grpc/interprocess.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Inter-process communication with gRPC -author: jamesnk -description: Learn how to use gRPC for inter-process communication. -monikerRange: '>= aspnetcore-5.0' -ms.author: jamesnk -ms.date: 08/24/2020 -no-loc: ["ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR] -uid: grpc/interprocess ---- -# Inter-process communication with gRPC - -By [James Newton-King](https://twitter.com/jamesnk) - -gRPC calls between a client and service are usually sent over TCP sockets. TCP is great for communicating across a network, but [inter-process communication (IPC)](https://wikipedia.org/wiki/Inter-process_communication) is more efficient when the client and service are on the same machine. This document explains how to use gRPC with custom transports in IPC scenarios. - -## Server configuration - -Custom transports are supported by Kestrel. Kestrel is configured in *Program.cs*: - -```csharp -public static readonly string SocketPath = Path.Combine(Path.GetTempPath(), "socket.tmp"); - -public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - webBuilder.ConfigureKestrel(options => - { - if (File.Exists(SocketPath)) - { - File.Delete(SocketPath); - } - options.ListenUnixSocket(SocketPath); - }); - }); -``` - -The preceding example: - -* Configures Kestrel's endpoints in `ConfigureKestrel`. -* Calls to listen to a [Unix domain socket (UDS)](https://en.wikipedia.org/wiki/Unix_domain_socket) with the specified path. - -Kestrel has built-in support for UDS endpoints. UDS are supported on Linux, macOS and [modern versions of Windows](https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/). - -## Client configuration - -`GrpcChannel` supports making gRPC calls over custom transports. When a channel is created, it can be configured with a `SocketsHttpHandler` that has a custom `ConnectionFactory`. The factory allows the client to make connections over custom transports and then send HTTP requests over that transport. - -> [!IMPORTANT] -> `ConnectionFactory` is a new API in .NET 5 release candidate 1. - -Unix domain sockets connection factory example: - -```csharp -public class UnixDomainSocketConnectionFactory : SocketsConnectionFactory -{ - private readonly EndPoint _endPoint; - - public UnixDomainSocketConnectionFactory(EndPoint endPoint) - : base(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified) - { - _endPoint = endPoint; - } - - public override ValueTask ConnectAsync(EndPoint? endPoint, - IConnectionProperties? options = null, CancellationToken cancellationToken = default) - { - return base.ConnectAsync(_endPoint, options, cancellationToken); - } -} -``` - -Using the custom connection factory to create a channel: - -```csharp -public static readonly string SocketPath = Path.Combine(Path.GetTempPath(), "socket.tmp"); - -public static GrpcChannel CreateChannel() -{ - var udsEndPoint = new UnixDomainSocketEndPoint(SocketPath); - var socketsHttpHandler = new SocketsHttpHandler - { - ConnectionFactory = new UnixDomainSocketConnectionFactory(udsEndPoint) - }; - - return GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions - { - HttpHandler = socketsHttpHandler - }); -} -``` - -Channels created using the preceding code send gRPC calls over Unix domain sockets. diff --git a/aspnetcore/grpc/performance.md b/aspnetcore/grpc/performance.md index bb6ae7c85886..705e58c30516 100644 --- a/aspnetcore/grpc/performance.md +++ b/aspnetcore/grpc/performance.md @@ -104,12 +104,6 @@ There are many L7 proxies available. Some options are: ::: moniker range=">= aspnetcore-5.0" -## Inter-process communication - -gRPC calls between a client and service are usually sent over TCP sockets. TCP is great for communicating across a network, but [inter-process communication (IPC)](https://wikipedia.org/wiki/Inter-process_communication) is more efficient when the client and service are on the same machine. - -Consider using a transport like Unix domain sockets or named pipes for gRPC calls between processes on the same machine. For more information, see . - ## Keep alive pings Keep alive pings can be used to keep HTTP/2 connections alive during periods of inactivity. Having an existing HTTP/2 connection ready when an app resumes activity allows for the initial gRPC calls to be made quickly, without a delay caused by the connection being reestablished. diff --git a/aspnetcore/toc.yml b/aspnetcore/toc.yml index 454e80c76b43..d6842df0d0e8 100644 --- a/aspnetcore/toc.yml +++ b/aspnetcore/toc.yml @@ -720,8 +720,6 @@ uid: grpc/clientfactory - name: Use gRPC in browser apps uid: grpc/browser - - name: Inter-process communication with gRPC - uid: grpc/interprocess - name: Create JSON Web APIs from gRPC uid: grpc/httpapi - name: Configuration diff --git a/aspnetcore/whats-new/2020-08.md b/aspnetcore/whats-new/2020-08.md index fe0b9a9e93f3..d061296c18d1 100644 --- a/aspnetcore/whats-new/2020-08.md +++ b/aspnetcore/whats-new/2020-08.md @@ -40,7 +40,6 @@ Welcome to what's new in the ASP.NET Core docs from August 1, 2020 through Augus ### New articles - - Add Create JSON Web APIs from gRPC doc -- - gRPC and inter-process communication - - gRPC performance best practices - - Add Protobuf guide for .NET - - Add Create gRPC services doc