2023 | Flipkart R1 | Low Level Design | LLD | Rejected

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-09-15Added By Anonymous
Source: Link
Flipkart | unknown | Round 1 (LLD) | 2023

Original Experience:
Introduction and Low level design(Includes Class diag and code) of "Tiny URL"


Flipkart R1: Low Level Design


//API endpoint
createURL(
apiKey,
originUrl,
userName,
preDefinedExpiryDay,
);

//ExpiryDate = CurrentDate + 3;
//insert data into DB
Database:
URL: id, originalUrl,creationDate, ShortUtl, expiryDate

nosql index based search: (Total complexity required for search ?)
json: userName.id.url

URL : {
id: varchar(4).
originalUrl: varchar(256),
}

Which algorithm will you use for generating say 8 charachter long Short URL (Refer EnjoyAlrithms.com)

My Example:
original URL: https://app.diagrams.net/?src=about#Wb!c_frDBsEvkK0E5sW8F3Cfdv5ugdBZN5CoWV27RDzXP3QIZoX5EZNSaULfjguHW21%2F01FZVREG5U4AIRLAEIKJCJZX3YBIXWWWZ7
Solution 1: base10Encode(64/128 bit) -> hashValue GHGHJGUJ$456h -> Short URL : GHGHJG (Problem -> duplication/Collisions)
Solution 2: 2 overcome above problem, define counter in given range(0-20Million) -> Counter (0-10 Million) -> EncodeBase8(counter)

Complexity for one create URL and saving the same in DB:
Convert original URL to Short URL + search + save
--------------------------------------------------------
o(n) + o(log m) + o(p)

Questions asked:
Total complexity required to generate, search for existing URL in DB and save data in DB
How will you handle server load overall ( with the help of zooKeeper -> Check enjoyAlgorithm.com)
How will you handle calculating 1M URL in one server because say one createURL is taking above complexity then creating 1M URL will take way more longer.

Continuation to create URL:
ExpiryDate concept:
1) Autosys/spring jobs to check if expired Urls -> Daily job -> delete URl from DB
2) URL hit -> search URL -> Check expiryDate -> if yes, delete DB record & throw error

Search based on id.url.ExpiringTodaydate for index based search

Master job: check 12AM daily ExpiryDate today -> get records expiring today ->
1 : 1PM
2: 4PM
3 : 8PM
:
:
:


60*24->
JIL
executeJob(1,2,3,4,5,6,7,8,....,24);

Question: How often will you execute job if you have 10M data expiring daily.





Comments