Man, I just went through the worst System Design interview. We were working out a system that involved WebSocket connections. The interviewer asked me how I'd handle a server restart. So I lay it out for him - when a server restarts, you cannot do much. The client usually has to take responsibility for reconnecting. Sure, you might have some details about the client under certain conditions, like their IP address, but that doesn't cut it if they're behind a shared network connection. But the interviewer turns around and tells me that's not quite right. According to him, the typical process is to save the WebSocket connection and just pick up where you left off after the server restarts. I don't claim to be the world's leading expert on WebSockets, but that just doesn't sound right to me. His response? He just brushed me off, saying something like, "don't worry, WebSockets are tricky for a lot of people." I mean, really? I'd have appreciated it if he could at least explain his point of view or provide some solid information instead of just dismissing my concerns. Anyways, just needed to vent that out. WebSockets, am I right? #meta ** UPDATE ** Clearly, I did not do a good job describing the situation. This was purely from the Server side. Not about steps to take on the client side, not about monitoring, protocols, safeguards, etc... **UPDATE 2** The sheer number of individuals commenting confidently despite a clear lack of understanding or expertise on the subject matter is incredible. It's a wonder we get anything to production.
AMA
Yesterday
666
PM Manager, early 40s, married and ENM (Ethical Non Monogamous) AMA
Tech Industry
Yesterday
2784
What happens when most of your team is Indian?
Personal Finance
2d
1752
$10 million is the new $1 million
Health & Wellness
Yesterday
557
Lasik cost
Tech Industry
Yesterday
1572
Women, help me understand why this is inspirational
The interviewer asked me how I'd handle a server restart. So I lay it out for him - when a server restarts, you cannot do much. - This You cannot do much is wrong. Imagine a user facing a server restart, does a user ever notice it? How does a company handle it? Eg take facebook messenger. Does your messages get lost often during server restarts, if not how do they handle this? Pub sub, save into sqs queue and process it later? "I can't do much" is most likely a bad answer in almost every situation " I'd have appreciated it if he could at least explain his point of view or provide some solid information instead of just dismissing my concerns." __ I agree with this part, but nothing stops you from learning it for the next time around
This was not about handling incomplete transactions or how we would handle the lost connection. This was literally about reestablishing connections. So yes, I can always learn more, but in this case, he was wrong.
If might be have been worded badly but maybe that's what was needed? If I were you, I would have clarified, "do you mean how we should handle incase connections are lost"? At the end we are all addressing consumer problems, thinking in those terms will always help you
An interviewer is there to collect signal and evaluate you, not to educate you. Most interviewers will not take time to teach you unless they have enough signal about you because it’s not a good use of interview time.
👆 Unfortunate your experience was not good. Don’t expect interviewers to get into beyond what helps them get signals about you that they want to capture that helps them make a recommendation decision.
It's a waste of a time of a candidate if your only objective is to get a signal from them
I was recently coding gRPC to create a weakly consistent cache on a client. The client has a list of files which it checks on server for updates asynchronously and runs in a for loop. If the server dies, it will come back up on the same ip and same port. The client should be able to connect and restart the process again. Doesn't matter it starts a fresh or from where it left
If the server dies, i guess this means just the connection broke right? Or it shouldnt even matter whether the server closed connection or completely restarted, because ultimately, the data is being fetched from a database and not from in-system memory. I think thats where the interviewer probably was hinting
Both should be possible in asynchronous RPC call ? It's upto the server to determine if it needs to return the file from memory or make a dB call
It seems like he was a bad interviewer and you were a bad candidate. The point about system design is not to establish who is right. It’s to articulate all assumptions and explains trade offs. An interviewer in this case has an upper hand to be vague. This is an opportunity to demonstrate your knowledge by missing gaps in the question. The intent to understand if both of you can work with each other. In this case the interviewer himself was biased. Smart thing to nod your head and look for next interview. my experience with interviewing laid off 20 year old principle meta engineers is that they think their ideas are facts because they were rewarded based on these ideas. Not their fault. Their CEO invested 10B dollar into glasses after watching sci fi movie ready player one.
Your mistake, as well, is that you generalize all meta employees based on their CEO. I guess there will always be bias in interviews
It’s not generalization. It’s cultural difference. In most companies you have to work with a problem with given constraints. Most of Meta employees believe you can redo the infrastructure or change the way things are done to get desired results. They would probably not hire me for the same reason.
Nop if websocket is directly connected to server it wont work, but if you are using api gateway that can be done
So there is one comment below saying websockets are persistent. If there is no api server, tcp underneath websocket would close right?
Yup it will close. Just think, server restarts, every connection is flushed. Os has no idea what was there. Api gateway will create a false sense that everything is alright, by creating a new connection from gateway to server, while client always keeps talking with api gateway connection, which is on.
This seems like clear case of ego. You need to go back and learn not start crying. You can think of questions you may have asked before answering “Nothing can be done”. I have seen cases like this. Long back I interviewed a candidate for Data Engineer role, Can you think about an approach where you need to refresh your data more in real-time? He gave a batch approach but when I pointed out then he spend 10 minute talking that why ETL processing in real-time is bad vs thinking any approach. I rejected him and he messaged me on LinkedIn that I don’t know anything about data processing.
So how's etl done real time ? You read a Kafka message , then what how does it get ingested real time
There a lot of approaches you can go back and read. There are pre-build solutions like iceberg, Hudi or delta lake that provide options to have data compacted in async manner. You may even choose CDC approach. You just need to ask right questions vs thinking that question is wrong. Like is it one to one table or a complex ETL that require 10s of tables or what is delta of data from source. With 90% people the problem is that they don’t want to understand clear problem they just want to solve it quickly.
Just move on. If it was just a rant. I understand...
Was it for Swe or production engineer?
Never argue with interviewer, even if you know they’re wrong. Nothing to gain. It’s not a real project that needs to be done right.
This 👆 I had a 3 yoe “senior swe” interviewer who told me that my system wasn’t perfect, and I’m like yeah, there are trade offs. You really think there’s a perfect design
Definitely not
Weird, how do you recover a lost TCP connection?
a flashlight, a good dog and a lot of patience
You just do it. Sheesh. Don't worry though. This is tricky for a lot of people.