andreyka26_se
In the system design diagram there are: - 3 chats, - every chat has 4 users. - GW -> socket gateway server that handles client's socket. - Chat API is separate for simplicity to not cover processing of the messages on the GW itself You can see that ifβ¦
Other way to show it. In this diagram (screen 1), we have only 1 chat with 4 participants per chat and 1 message per second coming to this chat from one of the clients (out of scope).
Do you see it? Every WS Gateway have to process all messages, as chat participants are connecting randomly (or deterministically but based on user_id property).
From now on, unless number of WS Gateways is more than max number of participants in chat - it will always be the case. Check screen 2, number of nodes = 5 > participants per chat = 3 (top 3 clients => chat1, bottom 3 clients => chat2). Now WS gateways process 1 message per second, except WS Gateway1, because he has users from both chats.
Screen 3 - is the same scaled situation but with single chat
Do you see it? Every WS Gateway have to process all messages, as chat participants are connecting randomly (or deterministically but based on user_id property).
From now on, unless number of WS Gateways is more than max number of participants in chat - it will always be the case. Check screen 2, number of nodes = 5 > participants per chat = 3 (top 3 clients => chat1, bottom 3 clients => chat2). Now WS gateways process 1 message per second, except WS Gateway1, because he has users from both chats.
Screen 3 - is the same scaled situation but with single chat
π₯6
Daily (240/373 streak until LC cap)
Today is good problem, not bullshit, I like when it has some sort of simulation and objects to play with.
https://leetcode.com/problems/walking-robot-simulation/description/?envType=daily-question&envId=2026-04-06
#daily #medium
Today is good problem, not bullshit, I like when it has some sort of simulation and objects to play with.
https://leetcode.com/problems/walking-robot-simulation/description/?envType=daily-question&envId=2026-04-06
#daily #medium
β€5
andreyka26_se
So, it is the time. Do you want to try yourself for System Design? You remember I said I don't know the good real prod solution for Messenger System Design? It is time to shine and give your ideas, while I'm prepping the article, so that I can consider allβ¦
So,
Guys, I am finishing the article.
Anything except:
1. Chat api pushing message updates directly to GW nodes (socket stateful nodes)
2. Chat api publishes message update to queue per user
3. Chat api publishes message update to queue per chat
These are typical what I have seen on the forums.
Shout if you have some different approach in your mind. It is okay that it might be not correct. Also can be the real solution and I will defeat with my arguments
Guys, I am finishing the article.
Anything except:
1. Chat api pushing message updates directly to GW nodes (socket stateful nodes)
2. Chat api publishes message update to queue per user
3. Chat api publishes message update to queue per chat
These are typical what I have seen on the forums.
Shout if you have some different approach in your mind. It is okay that it might be not correct. Also can be the real solution and I will defeat with my arguments
π₯6
Daily (241/373 streak until LC cap)
Interesting problem, a bit bullshit as there is no pattern to learn, but fun, with funny corner case xD
https://leetcode.com/problems/walking-robot-simulation-ii/description/?envType=daily-question&envId=2026-04-07
#daily #medium #nopattern
Interesting problem, a bit bullshit as there is no pattern to learn, but fun, with funny corner case xD
https://leetcode.com/problems/walking-robot-simulation-ii/description/?envType=daily-question&envId=2026-04-07
#daily #medium #nopattern
π4
Daily (242/373 streak until LC cap)
Should be easy instead of mid, 2 mins to solve, just simulate what is written. The only thing that worries me the number "I" in the title. Probably tomorrow we gonna have fucking hell problem.
https://leetcode.com/problems/xor-after-range-multiplication-queries-i/description/?envType=daily-question&envId=2026-04-08
#daily #medium #nopattern
Should be easy instead of mid, 2 mins to solve, just simulate what is written. The only thing that worries me the number "I" in the title. Probably tomorrow we gonna have fucking hell problem.
https://leetcode.com/problems/xor-after-range-multiplication-queries-i/description/?envType=daily-question&envId=2026-04-08
#daily #medium #nopattern
π₯3π2
andreyka26_se
Daily (242/373 streak until LC cap) Should be easy instead of mid, 2 mins to solve, just simulate what is written. The only thing that worries me the number "I" in the title. Probably tomorrow we gonna have fucking hell problem. https://leetcode.com/problems/xorβ¦
Daily (243/373 streak until LC cap)
Told you guys :) Don't do this nonsense, it is legit nonsense. I would rather spend time tomorrow and eventually finish fucking article.
https://leetcode.com/problems/xor-after-range-multiplication-queries-ii/description/?envType=daily-question&envId=2026-04-09
#daily #hard #nopattern
Told you guys :) Don't do this nonsense, it is legit nonsense. I would rather spend time tomorrow and eventually finish fucking article.
https://leetcode.com/problems/xor-after-range-multiplication-queries-ii/description/?envType=daily-question&envId=2026-04-09
#daily #hard #nopattern
π3
Daily (244/373 streak until LC cap)
Easy one, actually good for some simple leetcode patterns. Recommended
https://leetcode.com/problems/minimum-distance-between-three-equal-elements-i/description/?envType=daily-question&envId=2026-04-10
#daily #easy #pattern
Easy one, actually good for some simple leetcode patterns. Recommended
https://leetcode.com/problems/minimum-distance-between-three-equal-elements-i/description/?envType=daily-question&envId=2026-04-10
#daily #easy #pattern
π3
This media is not supported in your browser
VIEW IN TELEGRAM
Back in the game. Also want to try again some group trainings for a couple of times to remind myself some youth moments
π₯15
Daily (245/373 streak until LC cap)
The same problem as yesterday with stricter constraints. (Yesterday's optimized solution will work)
https://leetcode.com/problems/minimum-distance-between-three-equal-elements-ii/description/?envType=daily-question&envId=2026-04-11
#daily #medium #pattern
The same problem as yesterday with stricter constraints. (Yesterday's optimized solution will work)
https://leetcode.com/problems/minimum-distance-between-three-equal-elements-ii/description/?envType=daily-question&envId=2026-04-11
#daily #medium #pattern
π5
https://andreyka26.com/messenger-system-design-is-wrong
Eventually, after 1 month, I did it π
Please share your thoughts. It is just article that explains the problem but does not have a solution
#systemdesign
Eventually, after 1 month, I did it π
Please share your thoughts. It is just article that explains the problem but does not have a solution
#systemdesign
andreyka26 tech
Messenger System Design is WRONG
Why do all popular Messenger System Design solutions - Direct GW, Pub/Sub by user, Pub/Sub by chat - fail to linearly scale for large chats with 10k+ participants? This article breaks down the fundamental bottleneck in WebSocket Gateway scaling and proposesβ¦
1π₯19β€2
andreyka26_se pinned Β«Oookay, now I hit System Design problem I am not able to solve(partially). Problem: Design Messenger, but not pussy Whatsapp with 250 user/chat, but rather gigachad Telegram scale with 200k user/chat. I already consulted with 3 principals, 2 of them fromβ¦Β»
Daily (246/373 streak until LC cap)
Good problem to remind yourself DP. Not hard tbh (at least topdown)
https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/description/?envType=daily-question&envId=2026-04-12
#daily #hard #pattern
Good problem to remind yourself DP. Not hard tbh (at least topdown)
https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/description/?envType=daily-question&envId=2026-04-12
#daily #hard #pattern
π3β€2
Daily (247/373 streak until LC cap)
For tomorrow. Easy problem for 1 min, go and collect the coin
https://leetcode.com/problems/minimum-distance-to-the-target-element/description/?envType=daily-question&envId=2026-04-13
#daily #easy #nopattern
For tomorrow. Easy problem for 1 min, go and collect the coin
https://leetcode.com/problems/minimum-distance-to-the-target-element/description/?envType=daily-question&envId=2026-04-13
#daily #easy #nopattern
π5
Daily (248/373 streak until LC cap)
Interesting problem, but pretty hard to come up with DP recursion here, wasn't intuitive for me.
https://leetcode.com/problems/minimum-total-distance-traveled/description/?envType=daily-question&envId=2026-04-15
#daily #hard #pattern
Interesting problem, but pretty hard to come up with DP recursion here, wasn't intuitive for me.
https://leetcode.com/problems/minimum-total-distance-traveled/description/?envType=daily-question&envId=2026-04-15
#daily #hard #pattern
π2
Daily (249/373 streak until LC cap)
Nice and easy problem, no specific pattern, 2 mins coding.
https://leetcode.com/problems/shortest-distance-to-target-string-in-a-circular-array/description/?envType=daily-question&envId=2026-04-15
#daily #easy
Nice and easy problem, no specific pattern, 2 mins coding.
https://leetcode.com/problems/shortest-distance-to-target-string-in-a-circular-array/description/?envType=daily-question&envId=2026-04-15
#daily #easy
π2