Performance: Redis transport
This affects the speed and responsiveness of message passing between microservices or modules in a NestJS application.
@EventPattern('channel') async processMessage(@Payload() message) { await heavyAsyncProcessing(message); }
@EventPattern('channel')
processMessage(@Payload() message) {
// process message synchronously
heavySyncProcessing(message);
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous message processing | N/A | N/A | N/A | [X] Bad |
| Asynchronous message processing | N/A | N/A | N/A | [OK] Good |
Redis transport in a NestJS microservice?url: 'redis://localhost:6379' inside options.import { Controller } from '@nestjs/common';
import { MessagePattern } from '@nestjs/microservices';
@Controller()
export class MathController {
@MessagePattern('sum')
sum(data: { a: number; b: number }) {
return data.a + data.b;
}
}app.connectMicroservice({
transport: Transport.REDIS,
options: {
host: 'localhost',
port: 6379
}
});
app.listen();url: 'redis://localhost:6379' inside options.Pass the test and this pattern moves unknown