Middleware (2) message queue and middleware Message Queue
Message Queue is also an important middleware for building large-scale website architectures.
Message Queue
All those who have used message queues know that the two most common scenarios of message queues are:
1. Decoupling is generally used for message communication between applications when a large website is split for business.
2. asynchronous: for operations that do not require synchronous execution and can be executed later, asynchronous operations can be used, such as sending emails and text messages. In fact, using message queues for asynchronous processing can also improve performance, because the processing speed of the Message Queue Server is much higher than that of the database server.
The most common message queue components are RabbitMQ and Kafka. The following describes the differences between them.
RabbitMQ vs Kafka
Basic Information
Take a look at the following table:
The following conclusions can be drawn: Kafka is more popular and the version of rabbitMQ is faster.
Architecture Model
RabbitMQ:
Kafka:
As you can see, both RabbitMQ and Kafka have message producers and consumers, but the two are different in broker processing. RabbitMQ has the concept of exchange switch, but Kafka does not.
Performance Comparison
There is no comparability because the application scenarios are different. Test Conditions: normal pc, dual-core cpuKafka: 100 k msg/sRabbitMQ: 40 k msg/s
Application scenarios
When it comes to application scenarios, let's look at the differences between the two in application scenarios:
RabbitMQ: built in to support high concurrency (erLang language features), supports higher reliability of transactions and message validation, and is generally used for inter-Application Communication.
Kafka: stream data, big data processing, does not support transactions and message validation. It is generally used in log collection because occasional message loss is allowed.