About Lesson
1. System Goals
The primary goals of a TinyURL system are:
1.1. URL Shortening
- Convert long URLs into short, unique identifiers.
- Ensure that the generated short URLs are easy to share and memorable.
1.2. URL Redirection
- When users visit a short URL, the system should quickly redirect them to the original URL.
- Ensure low latency for a smooth user experience.
1.3. Scalability
- The system should handle millions of requests per day.
- Support both read-heavy and write-heavy workloads efficiently.
1.4. Uniqueness & Collision Avoidance
- Ensure that every short URL is unique.
- Avoid collisions in the URL generation process.
1.5. High Availability & Reliability
- The service should have minimal downtime.
- Use distributed systems to handle traffic spikes.
1.6. Security & Abuse Prevention
- Prevent brute force attacks and unauthorized access.
- Block malicious URLs that lead to spam or phishing websites.
1.7. Optional Features
- Custom Short URLs: Users can specify their own short links.
- Expiration & Deletion: URLs may expire after a set time.
- Analytics: Track clicks, geographic data, and usage trends.
- API Support: Allow developers to integrate the URL shortener into their applications.
2. Functional Requirements
These define what the system should do.
2.1. Core Features
- Shorten URL – Convert long URLs into short ones.
- Redirect URL – Map short URLs to original URLs for redirection.
- Ensure Uniqueness – Generate unique short URLs for different long URLs.
2.2. User Features (Optional)
- Custom Short URLs – Allow users to choose their own short link.
- Link Expiry – Users can set an expiration time for the URL.
- Analytics – Track usage metrics for each shortened URL.
- Delete URLs – Users can delete their shortened URLs if needed.
- API Access – Provide an API for programmatic URL shortening.
3. Non-Functional Requirements
These define system constraints and performance expectations.
3.1. Performance & Speed
- URL redirection should happen in less than 100ms.
- Caching mechanisms (like Redis) should be used to speed up lookups.
3.2. Scalability
- The system should handle high traffic efficiently.
- Load balancing and replication should be used to distribute the load.
3.3. Reliability & Fault Tolerance
- Data should be stored in a replicated distributed database to prevent data loss.
- The system should be resilient to failures and support failover mechanisms.
3.4. Security
- Prevent brute-force attacks on short URLs.
- Implement rate limiting to prevent abuse.
- Scan and block malicious URLs that lead to phishing sites.
3.5. Storage Efficiency
- Use a compact encoding scheme (Base62) to store short URLs efficiently.
- Delete expired or unused URLs to free up space.