Message queue

image

What is it?

Publish/subscribe messaging = asynchronous service-to-service communication used in serverless and microservices architectures. In a pub/sub model, any message published to a topic is immediately received by all of the subscribers to the topic

They are used to send data, operations, where publisher and subscribers do not know each other.

  • Publisher — they push data to topics. Topics are channels of specific information.
  • Subscriber — clients subscribe to topics, and read data.
  • Topic — topics are saved in brokers (persistent storage, databases). We can use sharding, replication.
  • Message — data, operation, that are relevant to subscriber, so that they are subscribed.

Why we can’t use simple database?

In simple database systems, a client sends a request directly to the database server to retrieve or update data. In a pub-sub system, however, a client can subscribe to certain topics or channels, and then receive updates or notifications when new data is published to those topics or channels.

Pros

  • Decoupling: Pub-sub systems can decouple senders and receivers, allowing them to evolve independently of one another.
  • Scalability: Pub-sub systems can handle a large number of clients and handle high throughput of messages.
  • Real-time data: The publish-subscribe pattern allows for real-time updates, so that data can be received and processed as soon as it becomes available, rather than at set intervals or in response to a client's request.
  • Ordering of messages, they are read in order.

Cons

  • Maintenance, cost, latency.
SuperMade with Super