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:
You can install Redis on local by following this instruction: https://redis.io/docs/getting-started/installation/
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
go to kafka folder downloaded from apache Kafka website: https://kafka.apache.org/downloads
start zookeeper: bin/zookeeper-server-start.sh config/zookeeper.properties
start kafka: bin/kafka-server-start.sh config/server.properties
create a topic: $ bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092
start consumer: bin/kafka-console-consumer.sh --topic quickstart-events --bootstrap-server localhost:9092
start producer: bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092
00:00 Intro
01:30 Redis & Kafka Basics
05:45 problem statement
07:08 Traditional solution
10:00 Demo and explanation
25:55 Conclusion
Follow me on Linkedin: https://www.linkedin.com/in/anubhavsri/
You can also DM me if you need guidance as a software engineer.