You'll get access to over 3,000 product manager interview questions and answers
Recommended by over 100k members
Clarifying Questions
To make sure – we’re talking about how tinyURL actually generates a shortened URL, right?
Yes
You want me to focus on technical user journey?
Yes
Focus on user path of generating a single URL one-time? In other words, we aren’t looking at some type of a link tree or something with a custom domain?
Yes
Describe the product
User journey:
User finds a link they want to share with a friend or print on a poster, etc.
User enters URL into tinyURL
User receives shortened URL that is valid for X days or hours
User sends the URL to a friend or prints on a page
Friend or other person enters URL into the browser
Person is redirected to the original URL
Attributes
Time limit the link is valid
Time to redirect when the second user enters the URL into their browser
Length of the URL (shorter is better)
Readability of the URL – how easily can somebody copy this down or, better yet, remember it?
Number of collision-resistant URLs
Database size/cost of hash map etc. for tiny URLs
Goal
Skip – not necessary here
Attributes (prioritized)
Number of collision-resistant URLs
Length of the URL
Database size/cost
Readbility
Design the product
One way hash w lookup
Hash the original
Return shortened URL w hash
Store key-value pair with generation and expiration dates
When user retrieves URL, lookup in table
Two-way hash
No DB required
Two-way hash function can either generate or retrieve a URL
Random name generator
Use random dictionary of names and DB
Tradeoffs
One way hash function requires DB
Two-way hash function does not have expiration, does not require DB
Two-way hash function is more likely to have collision errors (probably)
Random name generator more likely to have collisions
Needs routine updating and maintenance or shorter life time
Summary
Probably would go with one way hash with lookup for free tier
Longer expiration and readable names become possible with paid tier
Revenue can pay for maintenance and DB costs
Google technical interview question: How does TinyURL work?
Clarifying Question –
1. Just to make sure we are on the same page TinyURL is URL shortening service where a user enters a really long such as mydomain.com/reallylongstuffhere/morelongstuf/maybeishouldhaveshorterurls
and in exchange TinyURL gives the user
tinyurl.com/ hashkey.
When someone puts the tinyurl.com/ hashkey into their browser they end up at mydomain.com/reallylongstuffhere/morelongstuf/maybeishouldhaveshorterurls
2. And when you say works – you would like me to describe the technical journey behind a user entering tinyurl.com/hashkey into their browser and ending up at mydomain.com/reallylongstuffhere/morelongstuf/maybeishouldhaveshorterurls
Technical answer
A user generates a tinyurl by entering into a tinyurl website or via API. Tiny url uses a hashing algorithm to convert the long url into a hash key. This hashkey is stored as a lookup key that returns the long url. The hashkey can be stored in a highly indexed fashion to speed retrieval. The hashkey as is used as the main identifier in the url. Tinyurl.com/hashkey
Lets switch sides to the a user who enters the tinyurl into their browser.
The user enters tinyurl.com/hashkey into their browser the user’s browser sends that request to the users ISP where a domain server translates the text into an IP address. An IP address is a string of numbers that uniquely identifies where that web request should be routed.
In this case the user is routed to TinyURl.com.
Tinyurl must return the data very quickly so the request is sent into a load balancer that accounts for both the users geographic location and server load. And routes the request a close server with capacity.
The hashkey is likely stored in a memory-based cache layer – or at least those urls (hashkey) that have been used recently. This eliminates the need for a disk or origin lookup. If not in cache then the hash is looked up in the DB. The hashkey is associated to the full url and the user is redirected to the full url.
diagram at https://ibb.co/7pWV0zM
So the really short answer is that tinyurl works a lot like a mail forwarding service.
A simple way to understand its working is with the help of an analogy.
You and your mom have gone to a local store to purchase some goods. The store is named "THE GREAT INDIAN STORE". Now you forgot the cash and the digital payment systems are down. However, as you have a good relationship with the store owner and you are a frequent buyer the owner has asked you to pay when the digital payment systems are good.
You save the mobile number as "TGIS" because you are lazy and don't want to type the whole name.
You go home and pay the bill using net banking and now you want to call the store owner. Your mother asks you to call "THE GREAT INDIAN STORE" but you call it "TGIS" because you know you have saved the number with that name.
And there you go!
Clarification question:
Tiny URL is shortened version of an otherwise long URL:
google.com/photos/album/12312/ - > tiny.url /123
Applications:
- SMSs where length is short
- Mktg communication,
- etc
Key attributes: Tiny URL is:
- Fast to create
- Fast to redirect
- Easy to remember – shorter the better
Goal:
How does tiny URL work
Answer:
Following is the flow of request/ response and how the systems work together:
It is linear to and fro flow:
(facing some challenges uploading a screen shot of flow, hence typing it here)
Step 1: User browser:
User enters a long URL to shorten: google.com/photos/album/123123
or
User enters/ clicks tiny URL to access the website
Step 2: Hashes cached
Existing hashes are cached on edge server for quick search and response.
When user types in a tiny URL, the cached hashes are searched and DB is not hit
Step 3: Mapping cached
Mapping of Hashes to URL is cached on edge server for quick search and response.
When an exsiting hash is identified, URL is identified from this mapping. Again DB is not hit.
Step 4: Hashes creation/ storing in DB (Stores list of used hashes)
When a request for new tiny URL creation comes in, a hash creation algo is run.
The algo must has a criteria along length of hash to keep the URL short.
DB is where the data is actually stored. Once a record is created, it updates the cache.
12 13 |
322 |
Top Google interview questions
- What is your favorite product? Why?89 answers | 263k views
- How would you design a bicycle renting app for tourists?62 answers | 82.5k views
- Build a product to buy and sell antiques.54 answers | 66.8k views
- See Google PM Interview Questions
Top Technical interview questions
- Imagine you're the product manager for Facebook Marketplace. Since many sellers don't mark items as sold, what existing functionality and metrics could you use to determine whether an item has likely sold?7 answers | 20.9k views
- What happens when you enter a URL in your browser?6 answers | 10.8k views
- How would you determine how to rank posts in the newsfeed?4 answers | 3.3k views
- See Technical PM Interview Questions
Top Google interview questions
- How would you improve Google Maps?53 answers | 228k views
- A metric for a video streaming service dropped by 80%. What do you do?50 answers | 135k views
- How would you design a web search engine for children below 14 years old?36 answers | 42.9k views
- See Google PM Interview Questions
Top Technical interview questions
- The Chrome team is looking to reduce power utilization on mobile phones when using the browser. How would you go about solving this problem?3 answers | 3.7k views
- How would you map the ocean?3 answers | 2.9k views
- Create an API design for third-party integration for payments.3 answers | 4.2k views
- See Technical PM Interview Questions