cat blog/microservices-laravel-or-nestjs.md
Microservices: Laravel or NestJS?
Solution Architect


Contents
In my previous article, Laravel or NestJS: how I choose for each project, one question in the decision tree sent you straight to NestJS: real-time, messaging or microservices? This article digs into that last case.
The verdict fits in one sentence: for services that talk to each other, NestJS is the tool built for it; Laravel remains excellent for a business service with its back-office, but not as the backbone. And before even choosing, you need to ask whether you really need microservices.
Before choosing: do I really need microservices?
Microservices solve an organizational problem before a technical one: letting several teams ship their part without blocking each other. Alone, that problem doesn't exist. But I pay every cost: several repositories or a monorepo to manage, a message broker, one database per service, partial failures, scattered logs.
My starting point is therefore almost always a modular monolith: a single application, but split into well-separated modules that don't share their tables and communicate through internal events. The day a module really needs to live on its own, I extract it as a service without rewriting everything.
I split into real microservices when at least one of these situations arises:
one part has a very different load from the rest, for example file processing or mass notifications, and must scale on its own;
one part must stay available even when the rest is under maintenance;
different technologies are justified, for example a computation service in Python;
several teams work in parallel on distinct domains;
many external systems must subscribe to the same events.
If none applies, the best framework choice for microservices is… not to build them.
Why NestJS is built for it
NestJS includes microservices in the framework itself, with the @nestjs/microservices package. I don't have to invent how my services talk to each other: the framework provides it.
Several transports, one API. TCP, Redis, NATS, RabbitMQ, Kafka, MQTT or gRPC: I change the transport in configuration, not in business code.
Two communication styles built in.
@MessagePatternfor a request awaiting a response,@EventPatternfor a fire-and-forget event.Hybrid applications. The same service can expose an HTTP API for the front end and listen to messages at the same time.
Node's asynchronous model. A service spends most of its time waiting on the network, which Node handles very well.
Shared types. Message contracts (
OrderCreatedEvent, for example) live in a common library, imported by both sender and receiver.
A service listening to events on RabbitMQ fits in a few lines:
// main.ts of the notifications service
const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
transport: Transport.RMQ,
options: {
urls: [process.env.RABBITMQ_URL],
queue: 'notifications',
},
});
await app.listen();// notifications.controller.ts
@Controller()
export class NotificationsController {
constructor(private readonly mailer: MailerService) {}
@EventPattern('order.created')
async onOrderCreated(@Payload() event: OrderCreatedEvent) {
await this.mailer.sendConfirmation(event.customerEmail, event.orderId);
}
}And on the sender side, a single call is enough: this.client.emit('order.created', event).
What Laravel can do, and where it stops
Laravel isn't helpless in a distributed architecture. It has very good tools for background work and talking to other systems:
queues and jobs, with Redis or a database, and Horizon to monitor them;
events and listeners, which can run on a queue;
the built-in HTTP client, to call other services' APIs;
Octane, to keep the application in memory and handle more requests.
Where it stops: its queues are designed for the application to talk to itself, not for several services to exchange events. To publish an event that three other services consume through RabbitMQ or Kafka, you go through community packages and define the message format yourself. It's doable, but nothing is standardized like in NestJS.
That's why I use Laravel in a distributed architecture for a well-defined service: the one carrying the business logic and its administration. It emits events to the broker, and the other services react.
The architecture I would build
On a project that really justifies microservices, I don't pick one framework against the other: I give each the role where it excels. Here's an example for an ordering platform.


The gateway and technical services are in NestJS; the service carrying the business logic and its back-office stays in Laravel. Each service has its own database: none reads another's tables, they inform each other through events published on the broker. When an order is confirmed, the Orders service publishes order.created, and the Notifications service sends the confirmation without the two knowing each other.
The comparison, criterion by criterion
Criterion | Laravel | NestJS |
|---|---|---|
Communication between services | Community packages, format to define | Built in ( |
Transports | Redis, database; RabbitMQ or Kafka via packages | TCP, Redis, NATS, RabbitMQ, Kafka, MQTT, gRPC |
Request/response between services | HTTP calls |
|
Events | Internal to the application | Shared between services ( |
Message contracts | Documented separately | Shared TypeScript types |
HTTP API + messages in one service | Two processes (web + worker) | One hybrid application |
A service's back-office | Dedicated tools (Filament, Nova), very fast | To build |
Rich business service | Excellent | Good, with more assembly |
The dividing line is clear: NestJS wins everything about the links between services, Laravel keeps the edge inside a business-rich service.
Solo or in a team: what changes
Alone, as I am today, I stay on a modular monolith as long as I can. If a real need appears, I extract one service at a time, often in NestJS, next to a Laravel application that keeps the business logic and back-office. I limit the number of moving parts: a simple broker (Redis or RabbitMQ), a monorepo, and the same deployment pipeline for everything.
In a team, microservices make full sense, and the choice becomes sharper:
NestJS as the standard for services. Its enforced structure makes every service look like the others: a developer switching teams finds their way immediately.
A shared contracts library. Message types live in a common, versioned package: a format change breaks compilation, not production.
Laravel for back-office-heavy domains. A team dedicated to management (catalog, users, content) saves considerable time with Eloquent, built-in queues and the Laravel ecosystem's admin tools.
Shared rules rather than a single framework. Event format, queue names, logs and traces: that's what lets Laravel and NestJS services coexist without friction.
In short
For a real microservices architecture, NestJS is the natural choice: communication between services is built in, transports are interchangeable and contracts are typed. Laravel has its full place, but as a business service, with its back-office, rather than as the backbone.
And the best architecture is often the simplest: a well-split monolith, from which you extract a service the day it truly deserves it. Microservices are an answer to a growth problem, not a starting point.
subscribe --blog
Get new posts by email
One email per new post, nothing else. Unsubscribe in one click.
Your address is only used to send you new posts. Privacy
ls ./related-articles



