DEV Community

Cover image for How I Built a Scalable, Free URL Shortener.
Asadbek Karimov
Asadbek Karimov

Posted on • Updated on

How I Built a Scalable, Free URL Shortener.

Introduction

URL shorteners are in high demand for their ability to manage and share links effectively. They simplify long URLs, provide tracking analytics, and support branding. However, many services come with high costs or limitations for advanced features.

The Problem

However, most services offer only a limited free tier—typically allowing just 2-5 short links—which is often inadequate for real use. Additionally, free URL shorteners often lack essential features and are frequently developed by amateurs. Many users find that free options, especially those as browser extensions, are not taken seriously unless they come with a paid version.

The Solution:

Building a URL shortener from scratch? Nah, you’re crazy! Instead, we grabbed a trusty open-source solution that’s already been battle-tested. By using this ready-made tool, we skipped the drama of starting from zero and cut our development time way down. This gave us more time to focus on making our app and management system even better—plus, it saved us from pulling out our hair!

Next step on building this system we will have to check the 3 pillars of Designing data intensive application which are


three 3 pillars of Designing data intensive application

RELIABILITY

  • Redundancy: Run two instances of Shlink on separate VPS servers.
  • Monitoring and Alerts: Use a free status pinger for basic monitoring.
  • Preventing Misuse: To avoid Google flagging your domain for misuse, check URLs through GCP Web Risk before shortening. This helps identify and avoid malicious URLs.

Scalability

  • Cloud Hosting: Renting VPS servers and using Coolify for container management is cost-effective.
  • Load Balancing: Use NGINX for distributing traffic.
  • Caching: Utilize Redis Upstash for caching.

Maintainability

  • Rate Limiting: Implement rate limiting with Redis Upstash.
  • Bot Detection: Use Shlink’s built-in bot detection and consider adding reCAPTCHA to enhance security, especially for unauthenticated users.
  • Quota Management: Implement hard limits to ensure fair usage for all users.

Result

URL Shortener Mylinx: A free, scalable, and cost-effective URL shortener. With the current cost of just $20/month, it supports up to 10 million visits a month and can generate 10-20 million short URL links.

Free URL Shortener 1

Free URL Shortener 2

Free URL Shortener 3

Conclusion

In conclusion, building and managing a URL shortener can be both challenging and rewarding. By leveraging existing open-source tools and implementing strategies for reliability, scalability, and maintainability, you can create a robust and cost-effective solution. As part of our ongoing efforts to provide value to the community, I plan to release a Docker file for the Mylinx URL shortener in the near future. This will make it easier for others to deploy and use the service. Stay tuned for updates if you're interested in this public release!

Top comments (6)

Collapse
 
alindebian profile image
alin

This arricle is for your resume?! Give us more details, please.

Collapse
 
shikkaba profile image
Me

$20/month is not free

Collapse
 
asadk profile image
Asadbek Karimov • Edited

I am currently paying $20/month to support over 1,000 users on my Mylinx platform. Initially, I managed to run it on a $1.40/month VPS, which is extremely affordable even by third-world standards.
Image description

for example Bitly charges $35/month for the basic tier

Collapse
 
shikkaba profile image
Me

That's great, but your title is incorrect.

Thread Thread
 
asadk profile image
Asadbek Karimov

I'm working on the Docker file and plan to write a post on how to set up this project on an AWS EC2 t2.micro instance, which is available under the free tier. :)

Thread Thread
 
shikkaba profile image
Me

That's cool, really. However I was just pointing out that you said you made a free shortener for this post, but then said how much it was. That's all. It would be an accurate title if you removed the mention of it being free.