filmov
tv
Redis pub-sub vs Kafka? What to use for a chat application?
![preview_player](https://i.ytimg.com/vi/73Utd7nDYDs/maxresdefault.jpg)
Показать описание
This video is about a specific question around System design of a chat application, which generally remains un-addressed unless you actually have a design discussion. The question is : In the publisher subscriber section, why did we use Redis? Why not Kafka?
The short answer is : Redis is the right choice for the use case of real time chat application.
There are 4 reasons
1. SPEED
Redis is in-memory , so it is faster. Where was Kafka has to make disk operations.
2. STORAGE REQUIREMENT
Redis does not store messages , they just pass through to all the consumers
So, you only need to increase the processing and not the storage. Where-as in Kafka you need both compute and storage.
3. COST OF CREATING A TOPIC
Kafka: Has extra cost because the partition needs to be created in all the Redis: no cost of creating a new channel. In fact no channel is created, you just send a message to a channel and you are good.
4. COST OF DELETING TOPIC
Deleting a topic in Kafka is not straight forward. Sometimes, delete topic operation takes long time and then you have to manually delete the topics from server.
COMMANDS
Redis:
Start redis server: redis-server
connect to redis server: redis-cli
subscribe channel: SUBSCRIBE channel
publish command: PUBLISH channel1 "hey"
Observation : fast message sending and receive
Kafka
00:00 Intro
01:30 Redis & Kafka Basics
05:45 problem statement
07:08 Traditional solution
10:00 Demo and explanation
25:55 Conclusion
You can also DM me if you need guidance as a software engineer.
The short answer is : Redis is the right choice for the use case of real time chat application.
There are 4 reasons
1. SPEED
Redis is in-memory , so it is faster. Where was Kafka has to make disk operations.
2. STORAGE REQUIREMENT
Redis does not store messages , they just pass through to all the consumers
So, you only need to increase the processing and not the storage. Where-as in Kafka you need both compute and storage.
3. COST OF CREATING A TOPIC
Kafka: Has extra cost because the partition needs to be created in all the Redis: no cost of creating a new channel. In fact no channel is created, you just send a message to a channel and you are good.
4. COST OF DELETING TOPIC
Deleting a topic in Kafka is not straight forward. Sometimes, delete topic operation takes long time and then you have to manually delete the topics from server.
COMMANDS
Redis:
Start redis server: redis-server
connect to redis server: redis-cli
subscribe channel: SUBSCRIBE channel
publish command: PUBLISH channel1 "hey"
Observation : fast message sending and receive
Kafka
00:00 Intro
01:30 Redis & Kafka Basics
05:45 problem statement
07:08 Traditional solution
10:00 Demo and explanation
25:55 Conclusion
You can also DM me if you need guidance as a software engineer.
Комментарии