Tech IndustrySep 1, 2019
Oscar🐨koala

I am back but I need help with system design

I said I wouldn’t come back until I get an offer lol but I really need help brainstorming. Interview in one week. I am studying “rate limiter”. I know the various algorithms, but I am stuck with what exactly to discuss. Here is my plan: 1. Clarifying goals with the interviewers 2. High level of client -> proxy -> backend and establish I want to implement rate limiter at the proxy level (and explain why) 3. Discuss a couple rate limiter algorithms like leaky bucket 4. Then I might suggest a discussion on Little’s Law and AIMD. Essentially on how to address overprovisioned limit - client A asked for 50 rps but 99.99% of the time using 10rps, but system has capacity of 100 rps and later client A bursts to 60 rps and could be allowed (?) and how to rate limit when latency and error rate increasez I think the latter case should be implemented using circuit breaker. 5. Finally I have to account for running rate limiter in a distributed environment (multiple proxies). I suppose I need to have a gloabl table to check current user’s rate limit. But remote network communication is expensive, so I choose to run a redis local to the proxy and periodically syncs to a global redis as a backup. This might just work if user lands on a proxy using consistent hashing with bounded load algorithm (google reseafch, available in haproxy) so they always land on the same proxy server. Sorry for the long post. What you think? Really frustrated at myself right now. Any help is always appreicated.

Add a comment
Facebook vjuiu Sep 1, 2019

Remember the whole idea of consistent hashing is that you can drop a server and not rehash. There’s not guarantee it goes to the same server if it was the dropped server. Intra DC calls are low latency (~10ms). Having a local and a global Redis seems overly complex. Just make sure your Redis calls are atomic. CAP theorem will always apply so figure out which one you can trade off.

Oscar 🐨koala OP Sep 1, 2019

Thanks vjuiu! But if you drop a server, all the original clients have no where to go but onto a different server (the “new” destination server would take responsibility of more clients). And yes 10ms isn’t that bad indeed. I will keep a note of that.

Facebook vjuiu Sep 1, 2019

Basically, I was referring to the reliance on local values will not work since the server can fail and the caller will get redirected to a new server where the server thinks the caller has not used any quota.

Roku cruella Sep 1, 2019

Koala. When did u say u weren't going to be back??

Oscar 🐨koala OP Sep 1, 2019

Hello. Check out this post! "See y’all later! (Misc.)" https://us.teamblind.com/s/dTv0YmY6

Roku cruella Sep 1, 2019

So u leave without me noticing and now u r back. Why do I care? Jk koala. I care. I was just locked out of my blind. So didn’t notice.

Workday tdf Sep 1, 2019

Lol welcome back!

Oscar 🐨koala OP Sep 1, 2019

Thanks 🙏

Oscar 🐨koala OP Sep 1, 2019

Yeah. But it is too basic hence why I went into the rabbithole of finding stuff like little’s law and netflix’s adaptive rate limit lol but thanks

Amazon cuang Sep 1, 2019

Wtf. Now we have people grinding design problems? Interviews are increasingly becoming an arms race of shit instead of a way to assess experience

Oscar 🐨koala OP Sep 1, 2019

Grinding of any sort definitely isn’t fun, though the stuff I learn from system design are interesting. Another way to look at this system grinding is writing up a design doc. Well, you never know 100% of anything so you do research; maybe run some simulation and finally finish your design doc and present. It’s effectively the same IMO.

New
LCGrind Sep 1, 2019

@koala, what resources are you using for preparing system design. Thanks and welcome back.

Oscar 🐨koala OP Sep 1, 2019

Grokking, youtube and a lot of googling lol. Like I would spend hours on just understand on little piece of buzz word. I hope my hard work will pay off... and also a book called Designing Data intensive applications