@javarevisited I’ll first ask the interviewer to double check the question. It is affordable to have same password but not same username. if this is the case we would rather concentrating on the valid case which reduces complexity maintaining the unique user->pwd
@javarevisited 1.move data to distributed storage
https://t.co/tUP5YdV2Tr you have
https://t.co/PnLYWkiIio each chunk of clickstreatm data to a function(key,data) to return (day, no_of_unique users)
4.have a combiner / reducer to aggregate the results
5. have retry mechanisms to rerun those.
@0xlelouch_ layered approach where small chamges make big impact.
1. CDN: can you cache static data?
2. API caching at Server level ?
3. Global table if it the api belongs to minimal no.of.tables
4. Read replica if involves a lot of data
5. GraphQL - BFF if more overhead calling APIs.
@pulkit_mittal_ Concurrency Control: what if user calls rate limiter when hashmap gets reset? when 60 seconds over lock the hashmap and clear it. But what if multiple nodes runs then needs to go for inMem distributed storage.
@pulkit_mittal_ DS: {uid: 100} , get or create approach
this hashmap gets reset every one minute
keep reducing as user access if exists in DS if not uid:99
this is O(1)
@0xlelouch_ 1. DB Level lock & Managed At API Level to inform the of the user that seat is no longer available. (scalable issue as row level lock exists)
2. Distributed lock using Redis , saves DB & Faster incase of inMem cache.
@SumitM_X Indexing, date operations, counts, aggregations, joins, logical operations becomes in-efficient so I will ask Lead what are we trying to gain ? trading-off all these
@javarevisited Start protecting in below direction.
Cache -> LB -> App Servers -> DB
cache really works well if a particular content really trending e.g a video in your sys viral then cdn edge serves better.
But All depends on X in 20x
@0xlelouch_ Your app hosted in NY and your users from UK exp latency.
So u buy small server in uk and host it with small dictionary {url: response[first time from actual URL]} now just serve from this. TTL, other rules built on top of this + DNS + ISP
@0xlelouch_ Take advantage of
1. heartbeat
2. master election
if a node stopped reporting “i am fine” to master load off that node from LB pool and add a ready to launch node without cold start
if master goes down immediately slave nodes can findout and becomes master + adds node to pool