andreyka26_se
1.12K subscribers
1.1K photos
142 videos
7 files
614 links
Hey, I'm software engineer at Microsoft, with 8+ years of experience. Here we are talking about F(M)AANG big tech interviews: leetcode, system design and corpo life.

YouTube: @andreyka26_se
Instagram: andreyka26_se
TikTok: @andreyka26__
Download Telegram
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 we have much larger participants count than number of GW nodes we end up every GW node handle ALL large chats, thus causing broadcast.

===

This is one of the canonical solution that I saw on the internet for Messenger: you connect user to random GW and this GW gets (somehow) the message to deliver to the users that are connected to it. The solution is actually the way it works in Telegram and other Messengers, you have only single socket connection, it does not change when you switch chat.

First screen: 2 GW, 4 users per large chat => 4 / 2 = 2 users on EACH GW for EACH large chat
Second screen: we scaled GW nodes by 2 = 4 GW nodes -> and it didn't fix the broadcast, thus non linearly scalable
πŸ”₯5
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…
chat.excalidraw
165.4 KB
Please let me know about your ideas, as today-tomorrow I plan to finish the article, so that you can test your idea as well, as I gonna write bunch of simulations, calculations, POC etc.

In case someone would want to play with diagrams, attaching excalidraw for the diagrams
πŸ”₯3
Daily (239/373 streak until LC cap)

Easy and 'free' problem basically, you need 30 seconds for it

https://leetcode.com/problems/robot-return-to-origin/description/?envType=daily-question&envId=2026-04-05

#daily #easy #nopattern
πŸ‘3
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
πŸ”₯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
❀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
πŸ”₯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
πŸ‘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
πŸ”₯3😁2
This media is not supported in your browser
VIEW IN TELEGRAM
😁6
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
πŸ‘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
Wtf, maybe stop? What happens with market, every single day I am poorer and poorer. Wondering if it is related to my first oncall shifts
🀯9
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
πŸ‘5
Champ’s dinner, 1:30 AM 😁😁😁
I need to fix my schedule, and food in general. At least there is pepperπŸ˜†
1😁11
Today is drop.
I promised myself in the morning that I'm not leaving office until I'm finished.
I'm finished. Going home and will deploy

28 pages of nerdish text about why everyone around is wrong😁😁😁😁
1πŸ”₯12