Home > Database > Redis > body text

The difference between redis and kafka

(*-*)浩
Release: 2019-06-18 09:59:31
Original
9396 people have browsed it

The biggest difference between Kafka and Redis PUB/SUB is that Kafka is a complete system, while Redis PUB/SUB is just a suite (utility) - no offense to Redis, after all, its main function Not PUB/SUB.

The difference between redis and kafka

redis message push (based on distributed pub/sub) is mostly used for message push with high real-time performance. Guaranteed reliability. (Recommended learning: Redis Video Tutorial)
Other mq and kafka are guaranteed to be reliable but have some delays (non-real-time systems do not guarantee delays). Redis-pub/sub will be cleared when the power is turned off. Although using redis-list as a message push has persistence, it is too weak and not completely reliable and will not be lost.

Another point, in addition to representing different topics, redis publish and subscribe does not support grouping. For example, when Kafka publishes something, multiple subscribers can be grouped, and only one subscriber in the same group will receive the message. Messages, which can be used for load balancing.

Redis, it is first of all an in-memory database. The PUB/SUB function it provides stores messages in memory (based on channel), so if your message persistence requirements are not high and the back-end application If you have a strong spending power, using Redis PUB/SUB is a more suitable usage scenario. For example, the official website provides an example of an online chat room: simulate IRC, because the channel is the server in IRC. The user initiates a connection, publishes messages to the channel, and receives messages from other users. These requirements for persistence are not high, and it is enough to use Redis PUB/SUB.

Kafka is a complete system that provides a high-throughput, distributed submission log (due to the provision of Kafka Connect and Kafka Streams, the current Kafka official website has revised itself to a distribution A streaming processing platform, Kafka’s ambition can also be seen here:-). In addition to the p2p message queue, it of course provides a PUB/SUB message model. Moreover, Kafka provides message persistence by default, ensuring that messages are not lost (at least in most cases). In addition, since the consumption metadata is stored on the consumer side, the consumer is given a great degree of freedom for consumption. A consumer can consume messages sequentially or re-consume previously processed messages. These are things that Redis PUB/SUB cannot do.

Redis PUB/SUB usage scenarios:

1. Message persistence requirements are not high
2. Throughput requirements Not high
3. Can tolerate data loss
4. The amount of data is not large

Kafka usage scenarios:

Other scenarios besides the above:)
1. High reliability
2. High throughput
3. High durability
4. Diversified consumption processing model

For more Redis related technical articles, please visitRedis database usage introductory tutorial column to learn!

The above is the detailed content of The difference between redis and kafka. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!