<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jatin Gupta</title>
    <description>The latest articles on DEV Community by Jatin Gupta (@jatin09).</description>
    <link>https://dev.to/jatin09</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3974641%2F7b97afb2-cf33-411a-8c26-4a562c3e065c.jpeg</url>
      <title>DEV Community: Jatin Gupta</title>
      <link>https://dev.to/jatin09</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jatin09"/>
    <language>en</language>
    <item>
      <title>Have you ever wondered how Zoom works?</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Fri, 12 Jun 2026 03:22:08 +0000</pubDate>
      <link>https://dev.to/jatin09/have-you-ever-wondered-how-zoom-works-3ppj</link>
      <guid>https://dev.to/jatin09/have-you-ever-wondered-how-zoom-works-3ppj</guid>
      <description>&lt;p&gt;&lt;em&gt;If only two people are talking, does Zoom send the video?&lt;br&gt;
And if 100 people join a meeting, how can everyone see each other without your laptop sending 99 separate videos?&lt;/em&gt;&lt;br&gt;
Let's understand the complete architecture (Peer-to-Peer (P2P), WebRTC, and SFU) in a simple way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhdgf496e0for580b0sd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhdgf496e0for580b0sd.png" alt="Zoom architecture explained in detail" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Basic Idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever you join a &lt;a href="https://zoom.us/join" rel="noopener noreferrer"&gt;Zoom meeting&lt;/a&gt;, there are actually multiple types of data traveling over the internet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🎤 Audio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🎥 Video&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;💬 Chat messages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📄 Live transcript&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🖥️ Screen sharing&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;These are called Real-Time Media Streams because they need to reach everyone almost instantly.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
   │
   ├── Audio
   ├── Video
   ├── Chat
   ├── Screen Share
   └── Transcript
        │
        ▼
      Zoom
        │
        ▼
Other Participants
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What happens in a 1-on-1 call?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Suppose&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
Your friend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only two participants exist.&lt;br&gt;
In this case, Zoom can establish a Peer-to-Peer (P2P) connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You  ------------------&amp;gt; Friend
        Direct Connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your laptop sends one video stream directly to your friend's laptop.&lt;br&gt;
&lt;em&gt;Similarly&lt;/em&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Friend -------------&amp;gt; You
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One stream each.&lt;br&gt;
No complicated routing is required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do two devices connect?&lt;/strong&gt;&lt;br&gt;
They usually use WebRTC (Web Real-Time Communication).&lt;/p&gt;

&lt;p&gt;WebRTC allows browsers and applications to exchange:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Video&lt;/li&gt;
&lt;li&gt;Audio&lt;/li&gt;
&lt;li&gt;Data
in real time. However, before sending media, both devices need to discover each other.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This process is called &lt;strong&gt;&lt;em&gt;Signaling&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
   │
Signaling
   │
STUN Server
   │
Signaling
   │
Friend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After exchanging connection information, media can flow directly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You  ==========&amp;gt; Friend
        Video

Friend ========&amp;gt; You
        Video
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is a STUN Server?&lt;/strong&gt;&lt;br&gt;
A STUN Server helps devices discover their public IP address and determine how they can communicate through NAT (Network Address Translation).&lt;br&gt;
&lt;em&gt;Think of it like this:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You ask,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"What address does the outside world see for me?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The STUN server replies with that information so the two peers can attempt a direct connection.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why P2P is great.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Very low latency&lt;/li&gt;
&lt;li&gt;Less server cost&lt;/li&gt;
&lt;li&gt;Fast communication&lt;/li&gt;
&lt;li&gt;Direct transmission
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You ---&amp;gt; Friend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Simple and efficient.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But what happens when more people join?&lt;br&gt;
&lt;em&gt;Imagine&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
Person B
Person C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you must send your video to both people.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      You
     /   \
    /     \
   B       C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now upload 2 streams.&lt;/p&gt;

&lt;p&gt;Suppose there are 10 participants.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        You
      / / | \ \
     A B C D E F G H I
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your laptop must upload 9 different video streams.&lt;br&gt;
That is a huge problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is this impossible?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Because your&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internet upload bandwidth is limited&lt;/li&gt;
&lt;li&gt;CPU is limited&lt;/li&gt;
&lt;li&gt;Memory is limited&lt;/li&gt;
&lt;li&gt;Battery is limited
If each stream is 2 Mbps,&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For 10 people:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2 Mbps × 9

= 18 Mbps upload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most users cannot continuously upload this much.&lt;br&gt;
If 100 participants exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2 Mbps × 99

≈198 Mbps upload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Practically impossible.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;So how does Zoom solve this?&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Instead of sending separate streams to everyone,&lt;br&gt;
You upload only one stream.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
   │
   │
   ▼
 Zoom Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Zoom server then distributes that stream to everyone else.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             You
              │
              ▼
        Zoom Server
        /    |     \
       /     |      \
      B      C       D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your laptop uploads only once.&lt;br&gt;
The server does the rest.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;This server is called SFU&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
SFU stands for&lt;br&gt;
&lt;em&gt;&lt;strong&gt;Selective Forwarding Unit&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It is a media server.&lt;br&gt;
Its job is simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Receive your stream&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Forward it to other participants&lt;/em&gt;
It does not create new videos.
It simply forwards them intelligently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How SFU works&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Step 1&lt;/p&gt;

&lt;p&gt;You upload one stream.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
   │
   ▼
 SFU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2&lt;/p&gt;

&lt;p&gt;SFU receives it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You
   │
   ▼
 SFU
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3&lt;/p&gt;

&lt;p&gt;SFU forwards it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        SFU
      /  |  \
     /   |   \
    B    C    D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now each participant does the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        A
         \
          \
           SFU
         / |  \
        B  C   D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone uploads only one stream.&lt;br&gt;
The SFU distributes everything.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why is it called "Selective" Forwarding?&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Because it forwards only what is needed.&lt;br&gt;
&lt;em&gt;Example&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;If your screen shows only 9 participants,&lt;br&gt;
The SFU may send only those visible videos in high quality.&lt;br&gt;
If someone is hidden or inactive,&lt;br&gt;
The server can reduce quality or stop forwarding temporarily.&lt;/p&gt;

&lt;p&gt;This saves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bandwidth&lt;/li&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;li&gt;Battery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Does SFU mix videos together?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
No.&lt;br&gt;
&lt;em&gt;It simply forwards.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You ---&amp;gt; SFU ---&amp;gt; B

You ---&amp;gt; SFU ---&amp;gt; C

You ---&amp;gt; SFU ---&amp;gt; D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No video mixing happens.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Then what is MCU?&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Another architecture is MCU (Multipoint Control Unit).&lt;br&gt;
MCU receives all streams,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A
 \
  \
B ---&amp;gt; MCU
  /
 /
C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It decodes everything,&lt;br&gt;
mixes videos,&lt;br&gt;
creates one combined video,&lt;br&gt;
then sends that back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        MCU
          │
          ▼
     Combined Video
          │
          ▼
     All Participants
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;SFU vs MCU&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| SFU                              | MCU                              |
| -------------------------------- | -------------------------------- |
| Simply forwards streams          | Mixes streams                    |
| Faster                           | More processing                  |
| Lower latency                    | Higher latency                   |
| Less CPU on server               | Heavy server computation         |
| Scales well                      | More expensive                   |
| Used by many modern meeting apps | Used in some specialized systems |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Why Zoom uses SFU&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Because it allows&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Millions of users&lt;/li&gt;
&lt;li&gt;Lower latency&lt;/li&gt;
&lt;li&gt;Better scalability&lt;/li&gt;
&lt;li&gt;Lower upload requirements&lt;/li&gt;
&lt;li&gt;Efficient bandwidth usage
Instead of every laptop sending many streams,
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❌ You → B
❌ You → C
❌ You → D
❌ You → E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;it becomes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✅ You
      │
      ▼
     SFU
   / / | \ \
  B C D E F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only one upload from your device.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete Flow&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User

   │

Capture Camera

   │

Encode Video

   │

Upload One Stream

   │

──────────────

       SFU

──────────────

Receives Stream

Forwards Stream

──────────────

Participants

B

C

D

E

F
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Final Takeaway&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1-on-1 calls can often use Peer-to-Peer (P2P) with WebRTC, where devices communicate directly after signaling and STUN-based connection setup.&lt;/li&gt;
&lt;li&gt;Group calls cannot rely on P2P because each participant would need to upload many separate streams, quickly exhausting bandwidth and device resources.&lt;/li&gt;
&lt;li&gt;To solve this, Zoom uses an SFU (Selective Forwarding Unit). Each participant uploads one media stream to the SFU, and the SFU intelligently forwards that stream to the other participants.&lt;/li&gt;
&lt;li&gt;This architecture keeps latency low, reduces upload bandwidth requirements, and allows Zoom to scale to meetings with many participants efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In one line&lt;/strong&gt;:&lt;br&gt;
&lt;em&gt;"P2P works well for 1-to-1 calls, but for group meetings Zoom scales by using an SFU, where you upload one stream and the server forwards it to everyone else."&lt;/em&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>techtalks</category>
      <category>coding</category>
      <category>interview</category>
    </item>
    <item>
      <title>How URL Shorteners Generate Unique Links Instantly</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Thu, 11 Jun 2026 08:41:19 +0000</pubDate>
      <link>https://dev.to/jatin09/how-url-shorteners-generate-unique-links-instantly-2ag4</link>
      <guid>https://dev.to/jatin09/how-url-shorteners-generate-unique-links-instantly-2ag4</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhn9ikjna1zlipcw5j8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhn9ikjna1zlipcw5j8h.png" alt="URL shortener system design workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every day, billions of links are shared through services like &lt;a href="https://bitly.com/" rel="noopener noreferrer"&gt;Bitly&lt;/a&gt;, &lt;a href="https://tinyurl.com/" rel="noopener noreferrer"&gt;TinyURL&lt;/a&gt;, and many custom URL shorteners.&lt;br&gt;
But have you ever wondered:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;How can they generate unique short URLs instantly, even when millions of users are creating links at the same time?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Let's understand the complete system step by step-&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a URL Shortener?&lt;/strong&gt;&lt;br&gt;
A URL shortener converts a long URL into a shorter and easier-to-share URL.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
Long URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://www.example.com/blog/how-url-shorteners-work-in-distributed-systems
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://short.ly/g8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;When someone opens short.ly/g8, the service redirects them to the original long URL.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Main Challenge&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Imagine&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;Millions of users creating links&lt;br&gt;
Thousands of requests every second&lt;br&gt;
No duplicate short URLs allowed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The system must:

✅ Generate links quickly

✅ Never create duplicates

✅ Scale to millions of users

✅ Keep URLs short
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt; 1: Using URL Prefix&lt;br&gt;
One simple method is:&lt;br&gt;
Take the first few characters of the original URL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://linkedin.com/jobs
→ link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Problem&lt;/em&gt;:&lt;br&gt;
Many URLs start with the same letters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://linkedin.com/jobs
https://linkedin.com/feed
https://linkedin.com/profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates collisions.&lt;br&gt;
Therefore, real-world systems don't use this approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt; 2: Unique Counter + Base62 Encoding&lt;br&gt;
This is one of the most common approaches used in large systems.&lt;br&gt;
The process looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User submits URL
        ↓
Generate unique ID
        ↓
Convert ID to Base62
        ↓
Store mapping
        ↓
Return short URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 1: User Sends Long URL&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://www.linkedin.com/posts/example-post

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request reaches the backend server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Generate a Unique Number&lt;/strong&gt;&lt;br&gt;
Instead of generating random strings, the system first generates a unique number.&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1000
1001
1002
1003
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every new URL gets the next number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Not Use Database Auto Increment?&lt;/strong&gt;&lt;br&gt;
Databases can generate IDs, but under very high traffic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Database becomes a bottleneck&lt;/li&gt;
&lt;li&gt;Slower performance&lt;/li&gt;
&lt;li&gt;Increased load
Therefore, many systems use Redis.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What is Redis?&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://redis.io/" rel="noopener noreferrer"&gt;Redis &lt;/a&gt; is an extremely fast in-memory database.&lt;br&gt;
It stores data in RAM instead of disk.&lt;br&gt;
Because RAM is much faster than disk:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Database → milliseconds
Redis → microseconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes Redis perfect for counters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis INCR Command&lt;/strong&gt;&lt;br&gt;
Redis provides a command called:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;INCR&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It increases a number by 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Counter &lt;span class="o"&gt;=&lt;/span&gt; 1000

Request 1:
INCR
→ 1001

Request 2:
INCR
→ 1002

Request 3:
INCR
→ 1003
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Redis INCR Is Special&lt;/strong&gt;&lt;br&gt;
Redis operations are atomic.&lt;br&gt;
&lt;em&gt;Atomic means&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Only one operation happens at a time.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 million requests arrive simultaneously
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Redis guarantees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1001
1002
1003
1004
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No duplicates.&lt;br&gt;
No race conditions.&lt;br&gt;
No conflicts.&lt;br&gt;
This is why Redis is commonly used in URL shortening systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is a Race Condition?&lt;/strong&gt;&lt;br&gt;
Imagine two users create a URL at exactly the same moment.&lt;br&gt;
Without atomic operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User A gets ID 1001
User B gets ID 1001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now both URLs have the same short code.&lt;br&gt;
System breaks.&lt;br&gt;
Redis prevents this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Convert Number to Base62&lt;/strong&gt;&lt;br&gt;
Now we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using this directly would make URLs long.&lt;br&gt;
So we convert it into Base62.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is Base62?&lt;/strong&gt;&lt;br&gt;
Base62 uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a-z  → 26 characters
A-Z  → 26 characters
0-9  → 10 characters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Total:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;26 + 26 + 10 = 62 characters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Character set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why Base62?&lt;br&gt;
&lt;em&gt;Because it is:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✅ URL friendly

✅ Compact

✅ Easy to encode

✅ No special characters
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example Base62 Conversion&lt;/strong&gt;&lt;br&gt;
Suppose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1000 → g8
1001 → g9
1002 → ga
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://short.ly/g8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is much shorter than:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://short.ly/1000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How Base62 Conversion Works&lt;/strong&gt;&lt;br&gt;
Think of it like converting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Decimal → Binary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Decimal → Base62
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1000 ÷ 62
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repeated division generates characters from the Base62 character set.&lt;br&gt;
The resulting string becomes the short code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How Many URLs Can Base62 Create?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Formula&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;62ⁿ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;62 = available characters
n = length of short code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1 Character&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;62 combinations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2 Characters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;62² = 3,844
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3 Characters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;62³ = 238,328
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6 Characters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;626ⁿ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;56,800,235,584
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Over 56 billion URLs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Store Mapping&lt;/strong&gt;&lt;br&gt;
The system saves:&lt;br&gt;
Short Code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Short Code | Original URL                                                           |
| ---------- | ---------------------------------------------------------------------- |
| g8         | &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;https://example.com/very-long-url&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://example.com/very-long-url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; |
| g9         | &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;https://linkedin.com/post&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://linkedin.com/post&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                 |
| ga         | &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;https://youtube.com/watch?v=abc&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://youtube.com/watch?v=abc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Database record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"shortCode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"g8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"originalUrl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://example.com/very-long-url"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-06-08"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"expiryDate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Return Short URL&lt;/strong&gt;&lt;br&gt;
Backend returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://short.ly/g8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user can now share this URL anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Redirection Process&lt;/strong&gt;&lt;br&gt;
When someone visits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://short.ly/g8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reads g8&lt;/li&gt;
&lt;li&gt;Finds corresponding URL&lt;/li&gt;
&lt;li&gt;Returns HTTP redirect&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;g8
↓
Database lookup
↓
Original URL found
↓
302 Redirect
↓
User reaches destination
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why Not Use Random Strings?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a8KzP1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Random generation causes problems:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Collision checks required&lt;/li&gt;
&lt;li&gt;More database queries&lt;/li&gt;
&lt;li&gt;Slower performance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Generated:
abc123

Already exists?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Need extra lookup.&lt;br&gt;
Counter + Base62 avoids this completely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System Design Used by Large Companies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A simplified architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
  ↓
Load Balancer
  ↓
Application Servers
  ↓
Redis (INCR Counter)
  ↓
Database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Redis&lt;/em&gt;&lt;br&gt;
Generates unique IDs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Application Server&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Converts IDs to Base62.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Database&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Stores URL mappings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Load Balancer&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Distributes traffic among servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interview Question: Why Base62 Instead of Base64?&lt;/strong&gt;&lt;br&gt;
Many people confuse Base62 and Base64.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Base64 Characters&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A-Z
a-z
0-9
+
/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+
/
=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Special characters are not ideal inside URLs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ab+c/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Needs encoding.&lt;/p&gt;

&lt;p&gt;Base62 Characters&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a-z
A-Z
0-9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No special characters.&lt;br&gt;
Completely URL-friendly.&lt;br&gt;
Therefore URL shorteners usually use Base62, not Base64.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-World Optimizations&lt;/strong&gt;&lt;br&gt;
Large URL shorteners also add:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching&lt;/strong&gt;&lt;br&gt;
Frequently accessed URLs stay in Redis.&lt;/p&gt;

&lt;p&gt;Analytics&lt;/p&gt;

&lt;p&gt;Track:&lt;br&gt;
Click count&lt;br&gt;
Device type&lt;br&gt;
Browser&lt;br&gt;
Country&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Expiration&lt;/em&gt;&lt;br&gt;
Links can expire automatically.&lt;/p&gt;

&lt;p&gt;Custom Aliases&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;short.ly/jatin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;short.ly/g8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A modern URL shortener works like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User submits URL
        ↓
Redis INCR generates unique ID
        ↓
ID converted to Base62
        ↓
Mapping stored in database
        ↓
Short URL returned
        ↓
User opens short URL
        ↓
Database lookup
        ↓
Redirect to original URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key Takeaways&lt;/p&gt;

&lt;p&gt;Redis INCR generates unique IDs atomically.&lt;br&gt;
Atomic operations prevent duplicate URLs.&lt;br&gt;
Base62 makes IDs short and URL-friendly.&lt;br&gt;
6 Base62 characters can generate over 56 billion unique combinations.&lt;br&gt;
This approach is fast, scalable, and widely used in production URL shortening systems.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is why services like Bitly can create unique short URLs almost instantly, even when handling millions of requests every second. 🚀&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>tutorial</category>
      <category>systemdesign</category>
    </item>
  </channel>
</rss>
