April 15, 2021
Here is the link.
System design : Design messaging or chat service like facebook messenger.
https://redis.io/topics/cluster-tutorial
https://docs.datastax.com/en/cassandr...
https://en.wikipedia.org/wiki/WebSocket
High quality content. I like to play a few more times and then write down some notes. After the first play, I decided to look into Redis and learn architecture of Redis by myself quickly.
Facebook messages vs whatsapp / signal
Features/ topics
- one to one chating
- online / sent/ read
- Sending pictures or big file
- database
- Security
Deep dive on the above topics:
Load balancer
User A
Cassandra
Redis - distributed cache
HTTP - Server cannot initiate request to client - not working
Alternative: websocket, BOSH, long polling over http
websocket works best for chat application - sticky
Heartbeat information
Redis - distributed cache
Add heartbeat information to Redis - master/ slave, back and forth
Keep memory - advantages - hold all the information in the memory
User | | Date time
User A | N2 |
userB | N3 | ... time info
If N2 dies, User A will figure out, User A will get hooked to N3 instead N2 since N2 dies.
If user A dies, then the information can be retrieved from Redis, last heartbeat happens.
User A likes to send message to user B.
N2 send hi to N3, N2 will not send message directly to userB; the flow is different from N3.
Database - Cassandra DB
Picture - how two users chats
Minimum three tables:
User Table Encryption
-------------
User1 User2
Conversation table
Unread table
toUser fromUser time
userC userB t5
read table
--------------
fromUser toUser time
userA userC t5
That is my architecture, race condition.
Next userA to send a picture to userB using messager.
Picture - encrypted using key,
Blob storage - every company has a blob storage
Send thumbnail, and if user has interest, then it will be downloaded.
User case: Send message to a user offline
----------------------
conversation id time text
s t1 {..}
5 t2 {hello}
N1, N2, N3 manages thousands of sessions.
Let us talk about optimization, basic search about this ...
Conversation
Optimize the storage - last few days conversation to blog storage - combined, saved as url - go back to history, it is slow - pull information from Blob storage, download - optimization for storing data
Search - by text - reversed index, search on chat history
group chat - use it in group chat, group table, and then ...
No comments:
Post a Comment