Redis Pub/Sub for Inter-Service Communication
Date: 2026-03-10 Status: accepted
Context
Microservices need a communication mechanism. Options considered:
- HTTP/REST — simple, synchronous, but tight coupling and no built-in pub/sub
- gRPC — fast binary protocol, but adds protobuf build step and complexity
- Redis pub/sub — lightweight, already available as infrastructure, supported by NestJS microservices
- RabbitMQ/Kafka — full message brokers, but overkill at current scale
Decision
We chose Redis pub/sub via NestJS @nestjs/microservices Transport.REDIS. The API gateway sends messages to microservices using ClientProxy.send() with enum-based message patterns. Services respond through the same Redis channel.
Consequences
- Easier: Redis is already deployed for caching — no additional infrastructure needed.
- Easier: NestJS has first-class support via
@MessagePatterndecorators andClientsModule. - Easier: Message patterns are type-safe enums in
packages/shared. - Harder: Redis pub/sub has no message persistence — if a service is down, messages are lost.
- Harder: No built-in dead letter queue or retry mechanism.
- Future: May need to migrate to RabbitMQ or Kafka when reliability requirements increase.