27: High Throughput Stock Exchange | Systems Design Interview Questions With Ex-Google SWE

  Рет қаралды 10,832

Jordan has no life

Jordan has no life

Күн бұрын

Пікірлер: 66
@tfk933
@tfk933 5 ай бұрын
Just made it to team matching for E5 at Meta. Your channel has been particularly helpful since you go into the actual technologies themselves and their pros and cons, which is not something you get in most systems design prep material. It is especially helpful for me coming from a startup background where I did not learn highly scalable systems on the job.
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Absolute legend - congrats and hope you're able to see it through to the offer!
@yiannigeorgantas1551
@yiannigeorgantas1551 Ай бұрын
The UDP broadcast + re-transmitting nodes is an interesting approach I hadn't considered. In my approach to the problem, I had used Kafka sharded by ticker to create a deterministic ordering of events for every market, and then have the matching engine, which in this case would be a Flink node, fan-out the events to all the clients. Essentially, I was thinking of something similar to notification service (video 19). In this approach though, we leverage UDP broadcast to fan-out, which is a lot more efficient because it operates at the network layer. The cost of using UDP though, is that we lose the message delivery guarantees, so we create re-transmitter nodes to re-implement those TCP protocol guarantees. This allows us to differ re-transmission to dedicated nodes instead of relying on the TCP protocol, which would have meant re-transmission handled by the matching engine, which would have reduced throughput.
@jordanhasnolife5163
@jordanhasnolife5163 Ай бұрын
Yeah in practice I don't believe kafka is nearly fast enough for the latency that exchanges need to operate at
@torresoso
@torresoso 5 ай бұрын
I just started working at a stock exchange, this is great timing
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Fwiw I wouldn't be surprised if the design is pretty different now! This is from like 10 years ago, but who knows!
@emenikeanigbogu9368
@emenikeanigbogu9368 5 ай бұрын
I think a Pokémon go system design video would be fire!!!
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Interesting, haven't played since like 2015, what do you think the tough parts of this one would be
@emenikeanigbogu9368
@emenikeanigbogu9368 5 ай бұрын
@@jordanhasnolife5163 Probably the caching of pokemons location as well as preventing location spoofing, scalability, real time interaction.
@Dusht98
@Dusht98 5 ай бұрын
Detecting buildings and geolocation where pokemon spawns. Real time data processing maybe.
@LawZist
@LawZist 5 ай бұрын
I guess it would be similar to nearby friends/ restaurant search using geohash
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
@@LawZist Well I'd say this is my main concern. I also can't remember whether every user sees the same pokemon or the client itself just randomly generates them lol.
@dontdoit6986
@dontdoit6986 Ай бұрын
You missed the part where high-frequency trading firms placed their servers literally in the basement or in buildings next to the stock exchanges. This gave them an edge by executing trades faster than participants coming in from the wider internet. Those milliseconds of speed even allowed them to create 'dark pools' and run hypothetical trades to evaluate outcomes before deciding whether to execute or not. This gave them a huge advantage in gaming the system. Barclays and Credit Suisse were fined. the IEX was created to add a 350 millisecond "speedbump" in processing trades from some known HFT's. Of course, nothing else changed, and they do it to this day.
@jordanhasnolife5163
@jordanhasnolife5163 Ай бұрын
Colocation is certainly a part of how money is made
@surenderthakran6622
@surenderthakran6622 3 ай бұрын
Very informative as always. One question though: why not use a log based message bus like Kafka instead on retransmitters?
@jordanhasnolife5163
@jordanhasnolife5163 3 ай бұрын
We're using UDP so messages may arrive out of order (don't even know if Kafka can work with UDP), Kafka can only store messages in the order they come in. Not sure if it's also too slow due to writing to disk.
@surenderthakran6622
@surenderthakran6622 3 ай бұрын
I meant instead of the order matcher broadcasting UDP messages it can push it's output to a message bus for the standby order matching nodes to consume. Definitely slower than UDP but much less complicated and more reliable than retransmission. It is a very interesting design though. We do not usually get to see UDP broadcast + retransmitters. I am wondering about other applications of this.
@jordanhasnolife5163
@jordanhasnolife5163 3 ай бұрын
@@surenderthakran6622 I imagine this is one of the few. Perhaps video chat retransmitting for recordings.
@surenderthakran6622
@surenderthakran6622 3 ай бұрын
@@jordanhasnolife5163 btw I had a system design round with one of the FAANG's yesterday. I was asked something similar to your top k leaderboard problem. Your video was a big help:-)
@jordanhasnolife5163
@jordanhasnolife5163 3 ай бұрын
@@surenderthakran6622 Veryglad to hear! Hope it works out, good luck!
@hello_interview
@hello_interview 5 ай бұрын
Jordan has done nothing wrong!
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Going down kicking and screaming
@beecal4279
@beecal4279 2 ай бұрын
Thanks for the video; In 14:44 is there limitation for secondary to rebuild primary's state? do secondary engine need to have captured the original Order message in order to generate msg #2 & #3 based off of #1? also, does it still wotk if it only got #2 or #3 instead of #1 msg?
@jordanhasnolife5163
@jordanhasnolife5163 Ай бұрын
Yep! The main idea here is that if we see any of the messages created by an order id we can back out the state, including the responses to it, as opposed to the original order.
@LeoLeo-nx5gi
@LeoLeo-nx5gi 5 ай бұрын
Hi Jordan, thanks for sharing your knowledge here. Just one query :- I see we mentioned cons about both the partitioning techniques, so if partition by symbol would also not work, then what should be the ideal partitioning technique? (Should it be by orderID?)
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
The ideal way of doing it is still by symbol ID, there's no perfect answer here, but you do want all the orders for the same product to be on the same node.
@seifeddinedridi4898
@seifeddinedridi4898 5 ай бұрын
Thanks for video Jordan, great work. A quick question: why not use a time-series database to store the trades? Do you think that would slow down the system considerably?
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
You might have someone listening to exchange data putting it in a tsdb, but doing this in the matching engine itself would add a network call and a disk write which probably isn't feasible.
@NBetweenStations
@NBetweenStations 4 ай бұрын
Thanks Jordan! Question about buy and sell orders. Is the idea that the actually fulfillment of the orders is handled by a service outside of this design? Thanks!
@jordanhasnolife5163
@jordanhasnolife5163 4 ай бұрын
I'm not sure what you mean fulfillment. If you mean the delivery/recording of the stock changing hands, or the payment itself, that's done by others yeah.
@aforty1
@aforty1 3 ай бұрын
Thank you Jordan! ❤
@kevinburke3941
@kevinburke3941 Ай бұрын
Hey Jordan! Off topic but if you don't mind me asking, what made you want to switch to front end?
@jordanhasnolife5163
@jordanhasnolife5163 Ай бұрын
Hehe mostly a joke I'd say I do full stack work
@htm332
@htm332 4 ай бұрын
For state machine replication does the replication happen synchronously? i.e. is the request pending until both primary and backup process it?
@jordanhasnolife5163
@jordanhasnolife5163 4 ай бұрын
I'd say asynchronously, but ideally we have enough machines listening to the matching engine that it's close to perfect in terms of not losing messages. Basically, if a message reaches a customer, it hopefully has reached at least one retransmitter.
@surajkumardwivedi7139
@surajkumardwivedi7139 4 ай бұрын
Hey guys, what was the solution for increasing throughput? since we cannot partition since cross shard call would fc us up, we cannot dedicate different server for particular stock's transaction since atomicity would get fced up then what can we do?
@surajkumardwivedi7139
@surajkumardwivedi7139 4 ай бұрын
ps: I respect your grind.
@jordanhasnolife5163
@jordanhasnolife5163 4 ай бұрын
Not really much else to be done. You can partition at the cost of atomicity across ticker symbols, or you can just try and make things run as fast as possible on an individual node via improved hardware and software.
@LokendraSingh-42
@LokendraSingh-42 5 ай бұрын
50% is adding bugs to GUI 😂
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
I had thought I said buttons but bugs works too
@lohitakshtrehan6379
@lohitakshtrehan6379 5 ай бұрын
Yay new video!!!
@MK-qp2uv
@MK-qp2uv 5 ай бұрын
Thank you so fucking much, I appreciate the time you spend to teach us. You are a legend.
@chaitanyatanwar8151
@chaitanyatanwar8151 4 ай бұрын
Thanks
@JamilaJibril-e8h
@JamilaJibril-e8h 5 ай бұрын
Oh my boy wait you don't you can't do we even have life .....
@ShellyChen-u7q
@ShellyChen-u7q 3 ай бұрын
that's that "my wife's boyfriend"?!!
@KratosProton
@KratosProton 5 ай бұрын
BitTorrent Sustem Design please
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Not too familiar with how torrenting works but I'll have to look into it
@KratosProton
@KratosProton 5 ай бұрын
@@jordanhasnolife5163 Thanks
@sohansingh2022
@sohansingh2022 5 ай бұрын
@songswithhr
@songswithhr 5 ай бұрын
Bro did someone ever tell u, u look like Garfield comic😭
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
I'm cooked
@Jordan-77777
@Jordan-77777 5 ай бұрын
infowars app system design
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Don't know anything about the app, care to elaborate on the tough parts?
@foxedex447
@foxedex447 5 ай бұрын
MY DREAMS COMING TRUE
@jordanhasnolife5163
@jordanhasnolife5163 5 ай бұрын
Well done I saw your commen
@darkstudio3170
@darkstudio3170 4 ай бұрын
FYI : Your wife is cheating on you
@jordanhasnolife5163
@jordanhasnolife5163 4 ай бұрын
You'd have scared me if I had one
@darkstudio3170
@darkstudio3170 4 ай бұрын
@@jordanhasnolife5163 I am stuck in team matching phase at Google , my recruiter told your feedback is positive but are not very great. It's been two months already, should I be hopeful 😔?
@ShellyChen-u7q
@ShellyChen-u7q 3 ай бұрын
what's this? "my wife's boyfriend"?!!!
@jordanhasnolife5163
@jordanhasnolife5163 3 ай бұрын
Are you more surprised by the fact that I have a wife, or that she has a boyfriend?
@ShellyChen-u7q
@ShellyChen-u7q 3 ай бұрын
@@jordanhasnolife5163 hahaha, both!!! thanks for replying me, what a surprise!!! You didn't expose much of your personal life, lol, I guess it is very ally with the channel name. Would definitely want to see your wife in the video one day, and, her boyfriend?!! lol, which will turn this channel to be "Jordan has drama life", hahaha
@jordanhasnolife5163
@jordanhasnolife5163 3 ай бұрын
@@ShellyChen-u7q Tragically, I have neither a wife, nor does my fictional wife have a boyfriend. It's just a r/wallstreetbets meme
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН
The Ultimate Sausage Prank! Watch Their Reactions 😂🌭 #Unexpected
00:17
La La Life Shorts
Рет қаралды 8 МЛН
DCS Disclosure Convene 11 19 2024
1:37:50
Arizona Court of Appeals Div. 1
Рет қаралды 2
How to Build an Exchange
38:17
Jane Street
Рет қаралды 185 М.
Zerodha Stock Broker System Design with @KeertiPurswani
1:07:04
Gaurav Sen
Рет қаралды 41 М.
UI/UX Course | UI/UX Free Course | UI/UX Training | Intellipaat
3:34:54
Design Twitter - System Design Interview
26:16
NeetCode
Рет қаралды 528 М.
System design interview: Design Robinhood (with ex-Google SWE)
42:32
IGotAnOffer: Engineering
Рет қаралды 37 М.
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 16 МЛН