#When to use microservices over queues?

1 messages · Page 1 of 1 (latest)

minor bear
#

It's not very clear to me what are the best use cases for using microservices (@nestjs/microservices) vs. using queues (@nestjs/bull).

To make matters even more confusing, the microservices docs contain stuff about queues, e.g., MQTT, NATS, RabbitMQ, Kafka.

honest sleet
#

There's some overlap in functionality. One difference is that messages from @nestjs/microservices can use enhancers (guards, interceptors, exception filters...), but bull queue processors can't. Also you would generally use bull queues inside a single service logical service. But the only actual difference is semantics - bull is for "job queues" and microservice transports based on brokers are for "message queues".

minor bear
honest sleet
#

bull is great when you want to balance load within a single service (say, you have a service that generates image thumbnails, you put each new job to a queue and let it process then one by one), on the other hand, you'd use microservices approach to pass messages to and query data from other services in the system.