Multiplex to Run Multiple Services on One Port

Multiplexing allows you to serve different services on the same port. This makes your service easier to use: there’s less documentation, less configuration, and fewer connections to manage. And you can serve multiple services even when a firewall constrains you to one port. There’s a slight perf hit on each new connection because the multiplexer reads the first bytes to identify the connection, but for long-lived connections that performance hit is negligible. And you must be careful you don’t accidentally expose a service.

Many distributed services that use Raft multiplex Raft with other services, like an RPC service. Running gRPC with mutual TLS makes multiplexing tricky because we want to multiplex ...

Get Distributed Services with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.