Grokking the System Design Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Hi Team,"Our service will ensure that only expired links will be deleted, althou...

Pramod Kumar

Oct 13, 2021

Hi Team, "Our service will ensure that only expired links will be deleted, although some expired links can live longer but will never be returned to users."

As per our current implementation for purging, We will check if the url is expired or not, Only when any user requests for that url.

Based on the above statement : Point 1: So if it is a hot url and when accessed, Are we going to check every time if the url has expired or not which will add to response time.

Point 2: So what if the url is never accessed after creation, Then we will have lot of url's which are eating up our storage space.

Need your inputs for point 1 and point 2.

0

0

Comments
Comments
Design Gurus
Design Gurus4 years ago

Hi there,

For Q-1: We delete the expired link on its first access. Further reads of that link will get an error. From the chapter:

"Whenever a user tries to access an expired link, we can delete the link and return an error to the user."

For Q-1: The DB cleanup servi...

A
anand zanwar3 years ago

"We delete the expired link on its first access. Further reads of that link will get an error."

How system decides to give error ? For hot url does it make DB call for and if it does not find in DB, it gives error ?

M
Mike Xu3 years ago

I guess we have two options:

  1. we assume an invalid/expired link will not be a hot link so we don't worry too much about db round trip time.
  2. we can cache that this link is invalid/expired just like how we cache the valid links.
Design Gurus
Design Gurus3 years ago

Every hot link will be cached to make things fast.

An expired hot link could be cached too, so that we could return the error quickly.

One think to take care would be to invalidate the cache when an expired link got recreated. So that the cache now points to the corre...

On this page

  1. Why do we need URL shortening?

Try it yourself

Designing URL Shortener (video)

  1. Requirements and Goals of the System
  1. Capacity Estimation and Constraints
  1. System Interface Definition
  1. Create Short URL API
  1. Redirect API
  1. Analytics API
  1. URL Management API
  1. Delete Short URL API
  1. Database Design
  1. Basic System Design and Algorithm

a. Encoding actual URL

b. Generating keys offline

  1. Data Partitioning and Replication
  1. Cache
  1. Load Balancer (LB)
  1. Purging or DB cleanup
  1. Telemetry
  1. Security and Permissions