Kest

Search

Search the documentation

Microservices

Transports compared

Choose how your services' messages travel.

A transport is the road the messages travel on: a plain TCP connection, or a message broker (a server that receives messages and delivers them). Your handlers do not change when you switch: you change the module you import and the connection options.

PackageServerClientReply mechanism
microservicesTcpServer(port)TcpClient(host, port)the same connection
microservices-redisRedisServerRedisClienta reply channel per request
microservices-natsNatsServerNatsClientNATS request/reply
microservices-mqttMqttServerMqttClientTransporta reply topic
microservices-rabbitmqRabbitServerRabbitClientreplyTo queue and correlation id
microservices-kafkaKafkaServerKafkaClienta reply topic with a correlation header
microservices-grpcapp.grpc(port, schema)GrpcClientthe call itself, see gRPC

app.connectMicroservice(options) and app.startAllMicroservices() start serving; ClientsModule.register { client(name, options) } calls. Each options class takes the broker's address and group or queue names; see each page.

One contract (request and reply, events, errors, guards, roles, interceptors, filters, pipes) runs against every transport with real brokers, so they behave the same.

Loading diagram…

Which one?

ChooseWhen
TCPtwo services you control, nothing else to run
Redisyou already run Redis and want something simple (no message persistence)
NATSlow-latency request/reply, many small messages, queue groups for load sharing
RabbitMQreliable queues, routing, work distribution with acknowledgements
Kafkaa durable log you can replay, very high volume, event streams
MQTTdevices and low-bandwidth links
gRPCtyped calls with a .proto contract, streaming, many languages

When unsure, start with what your team already operates. Nothing in your handlers is tied to the choice.

Where a new service starts reading (Kafka). A consumer group that has never read a topic starts at the end, like NestJS's fromBeginning: false, so requests and events sent before the service existed are not replayed (replaying old requests would answer callers that are long gone). Pass fromBeginning = true for event processing that needs history.

Restarts are tested

Each broker is restarted under a connected server and client, and both carry on without being restarted. See Overview.

Not verified

Failover inside a broker cluster; running against a NestJS peer; and TLS or authentication options beyond what each client library accepts as connection settings.

Read more