Mohammed Manssour

Highly Scalable URL Shortner with Go

Goside projects

I recently discovered that Bitly has over 5.7 million users who create more than 256 million links each month - about 100 links per second! They also handle over 10 billion monthly interactions (clicks and scans), which works out to roughly 3,800 interactions per second. That's a total of about 4,000 requests per second - a huge workload! This inspired me to build a URL shortener that could potentially handle similar scale.

Key Features

  • Scalable Database: Starts with one physical DB shard and several logical shards. As data grows, logical shards can become physical shards to improve database performance.
  • Horizontal Scaling: Can spin up multiple app instances to handle increasing traffic and improve processing time.
  • Distributed ID Generation: Creates unique IDs across all shards without needing external tools like ZooKeeper.
  • Efficient Short Codes: Generates unique short codes directly from these IDs, eliminating database lookups for uniqueness checks.
  • Performance Optimization: Includes a cache layer to speed up read requests.
  • Secure Authentication: Uses Paseto for security tokens, which is more secure than JWT (see why).

Important Notes

⚠️ Disclaimer: This is currently a proof-of-concept project. While it demonstrates potential for handling large-scale traffic, it would need additional work before being production-ready.

💡 Architecture Note: This complex architecture is designed for applications expecting significant scale. For most startups or new projects, simpler solutions would be more appropriate and cost-effective until you reach substantial user traffic.

Source Code

Crafted with love by Mohammed Manssour