NestJS supports microservice architectures with first-class transporters (TCP, Redis, NATS, Kafka, MQTT, gRPC, RabbitMQ). This lesson introduces creating microservice and hybrid applications.
Creating a Microservice App
Instead of (or in addition to) HTTP, a Nest microservice listens for messages on a transporter. Controllers use @MessagePattern / @EventPattern instead of HTTP route decorators.
Avoid a distributed monolith: do not share one database blindly across services. Prefer clear APIs and events between bounded contexts.
Common Mistakes
Turning every method call into a network hop without measuring latency cost.
Assuming messages arrive exactly once.
Sharing TypeORM entities across services instead of explicit contracts.
Missing timeouts and retries on ClientProxy calls.
Key Takeaways
Nest microservices use transporters and message/event patterns.
Hybrid apps can expose HTTP and microservice endpoints together.
ClientProxy.send / emit call other services.
Design for at-least-once delivery and clear service boundaries.
Pro Tip
Start with a modular monolith when the team is small; introduce Nest microservices when scaling, ownership, or deploy independence truly requires separate processes.
You now know Nest microservices basics. Next, learn Message Patterns for RPC-style calls.