<?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.us-east-2.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>Forward Proxy vs Reverse Proxy: The Complete Guide Every Developer Should Know</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Thu, 25 Jun 2026 03:26:11 +0000</pubDate>
      <link>https://dev.to/jatin09/forward-proxy-vs-reverse-proxy-the-complete-guide-every-developer-should-know-13do</link>
      <guid>https://dev.to/jatin09/forward-proxy-vs-reverse-proxy-the-complete-guide-every-developer-should-know-13do</guid>
      <description>&lt;p&gt;If you've ever worked with Nginx, Cloudflare, Load Balancers, CDNs, Kubernetes, or Microservices, you've probably heard the terms Forward Proxy and Reverse Proxy.&lt;/p&gt;

&lt;p&gt;Many developers memorize the definitions but struggle during interviews when asked:&lt;br&gt;
&lt;strong&gt;&lt;em&gt;"What's the difference between a Forward Proxy and a Reverse Proxy?"&lt;/em&gt;&lt;/strong&gt;&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7nxg26fxnr66mmvvij8.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc7nxg26fxnr66mmvvij8.png" alt="Forward proxy vs reverse proxy infographic" width="800" height="984"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a Proxy Server?&lt;/strong&gt;&lt;br&gt;
A Proxy Server is a middleman between two systems.&lt;br&gt;
Instead of communicating directly, requests pass through a proxy first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Proxy → Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The proxy receives the request, processes it, and forwards it to the destination.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Think of it as a receptionist in an office:&lt;/li&gt;
&lt;li&gt;You don't directly meet the CEO.&lt;/li&gt;
&lt;li&gt;You first talk to the receptionist.&lt;/li&gt;
&lt;li&gt;The receptionist forwards your request.
The same idea applies in networking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Why Do We Need Proxies?&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Proxies are used for:&lt;/p&gt;

&lt;p&gt;✅ Security&lt;/p&gt;

&lt;p&gt;✅ Privacy&lt;/p&gt;

&lt;p&gt;✅ Caching&lt;/p&gt;

&lt;p&gt;✅ Load Balancing&lt;/p&gt;

&lt;p&gt;✅ Monitoring&lt;/p&gt;

&lt;p&gt;✅ Access Control&lt;/p&gt;

&lt;p&gt;✅ Hiding Network Details&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Proxy Servers&lt;/strong&gt;&lt;br&gt;
There are two major types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Forward Proxy&lt;/li&gt;
&lt;li&gt;Reverse Proxy&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The main difference is:&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;| Proxy Type    | Hides  |
| ------------- | ------ |
| Forward Proxy | Client |
| Reverse Proxy | Server |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you remember only one thing from this article, remember this table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Understanding Forward Proxy&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
A Forward Proxy sits between the client and the internet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Forward Proxy → Internet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The website sees the proxy's IP instead of the client's IP.&lt;br&gt;
Forward Proxy 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 |
+--------+
     |
     v
+---------------+
| Forward Proxy |
+---------------+
     |
     v
+------------+
| Website    |
| Server     |
+------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How Forward Proxy Works&lt;/strong&gt;&lt;br&gt;
Step 1&lt;br&gt;
The client sends a request to the proxy.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Step 2&lt;br&gt;
The proxy forwards the request to the website.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Step 3&lt;br&gt;
The website sends a response back to the proxy.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Step 4&lt;br&gt;
The proxy sends the response to the client.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;What Does Forward Proxy Hide?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
It hides the client.&lt;br&gt;
The server doesn't know who the real client is.&lt;/p&gt;

&lt;p&gt;It only sees the proxy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Actual Client ❌ Hidden

Proxy IP ✅ Visible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Real-Life Example&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine your company blocks social media websites.&lt;br&gt;
You use a proxy server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You → Proxy → Facebook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Facebook sees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request from Proxy
&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;Request from You
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your identity is hidden.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Uses of Forward Proxy&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Privacy
Hide user's IP address.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;Anonymous browsing&lt;/li&gt;
&lt;li&gt;Privacy protection&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Access Control
Organizations control internet access.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Block YouTube&lt;br&gt;
Block Gaming Websites&lt;br&gt;
Block Social Media&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Content Filtering
Schools and colleges often use proxies.&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;Student → Proxy → Internet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Proxy blocks unwanted websites.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Caching
Frequently visited websites are cached.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster loading&lt;/li&gt;
&lt;li&gt;Reduced bandwidth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular Forward Proxy Tools&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Squid Proxy&lt;/li&gt;
&lt;li&gt;HAProxy&lt;/li&gt;
&lt;li&gt;Privoxy&lt;/li&gt;
&lt;li&gt;Blue Coat Proxy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding Reverse Proxy&lt;br&gt;
A Reverse Proxy sits between users and servers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Reverse Proxy → Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Clients think they are talking directly to the server.&lt;/li&gt;
&lt;li&gt;In reality, the reverse proxy handles everything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reverse Proxy Architecture&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;                 +-----------+
                 | Server 1  |
                 +-----------+

Client
   |
   v
+----------------+
| Reverse Proxy  |
+----------------+
   |
   +------------&amp;gt; +-----------+
                  | Server 2  |
                  +-----------+

   |
   +------------&amp;gt; +-----------+
                  | Server 3  |
                  +-----------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How Reverse Proxy Works&lt;/strong&gt;&lt;br&gt;
Step 1&lt;br&gt;
Client sends request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Reverse Proxy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2&lt;br&gt;
Proxy chooses a backend server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reverse Proxy → Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3&lt;br&gt;
Server processes request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server → Reverse Proxy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 4&lt;br&gt;
Proxy returns response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reverse Proxy → Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What Does Reverse Proxy Hide?&lt;br&gt;
It hides the servers.&lt;/p&gt;

&lt;p&gt;Clients don't know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of servers&lt;/li&gt;
&lt;li&gt;Server IP addresses&lt;/li&gt;
&lt;li&gt;Internal architecture
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server Details ❌ Hidden
Proxy Address ✅ Visible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Real-Life Example&lt;/strong&gt;&lt;br&gt;
Suppose Amazon receives millions of requests.&lt;/p&gt;

&lt;p&gt;Instead of exposing backend servers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Users
   |
   v
Cloudflare / Nginx
   |
   +--&amp;gt; Server 1
   +--&amp;gt; Server 2
   +--&amp;gt; Server 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Users only see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amazon.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They never see actual backend servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Reverse Proxy Is So Important&lt;/strong&gt;&lt;br&gt;
Almost every large-scale application uses it.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Netflix&lt;/li&gt;
&lt;li&gt;Amazon&lt;/li&gt;
&lt;li&gt;YouTube&lt;/li&gt;
&lt;li&gt;Facebook&lt;/li&gt;
&lt;li&gt;Instagram&lt;/li&gt;
&lt;li&gt;Uber&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Features of Reverse Proxy&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Load Balancing
Distributes traffic across multiple servers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without Load Balancer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1000 Requests
      |
      v
   Server 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server crashes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With Reverse Proxy:&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;1000 Requests
      |
      v
 Reverse Proxy
   /   |   \
  /    |    \
 S1   S2    S3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Traffic gets distributed.&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better performance&lt;/li&gt;
&lt;li&gt;High availability&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Security
Backend servers remain hidden.
Attackers cannot directly access them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDoS Protection&lt;/li&gt;
&lt;li&gt;IP Masking&lt;/li&gt;
&lt;li&gt;Firewall Integration&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;SSL Termination
Reverse proxy handles HTTPS.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client (HTTPS)
      |
      v
Reverse Proxy
      |
      v
Server (HTTP)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Backend servers don't need SSL certificates.&lt;br&gt;
This reduces server workload.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Caching
Frequently requested responses are cached.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster responses&lt;/li&gt;
&lt;li&gt;Lower server load&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Compression
Can compress data before sending it.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;ul&gt;
&lt;li&gt;Faster website loading&lt;/li&gt;
&lt;li&gt;Less bandwidth usage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Most Popular Reverse Proxy Solutions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Nginx&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Most widely used reverse proxy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    listen 80;

    location / {
        proxy_pass http://backend;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;HAProxy&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Excellent for load balancing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cloudflare&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Acts as a global reverse proxy.&lt;/p&gt;

&lt;p&gt;Provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DDoS Protection&lt;/li&gt;
&lt;li&gt;CDN&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Traefik&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Popular in Docker and Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Forward Proxy vs Reverse Proxy&lt;/em&gt;&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;| Feature           | Forward Proxy            | Reverse Proxy              |
| ----------------- | ------------------------ | -------------------------- |
| Sits In Front Of  | Clients                  | Servers                    |
| Hides             | Client                   | Server                     |
| Used By           | Users                    | Website Owners             |
| Purpose           | Privacy &amp;amp; Access Control | Security &amp;amp; Scalability     |
| Traffic Direction | Outgoing                 | Incoming                   |
| Main Goal         | Hide Client Identity     | Hide Server Infrastructure |
| Example           | VPN, Squid Proxy         | Nginx, Cloudflare          |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy Interview Trick&lt;br&gt;
If interviewer asks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;"How do I remember the difference?"&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use this rule:&lt;br&gt;
&lt;em&gt;Forward Proxy&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;FORWARD = FOR USER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hides the client.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Reverse Proxy&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;REVERSE = FOR SERVER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hides the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interview Questions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Q1: What is a Proxy Server?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A proxy server acts as an intermediary between a client and a server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q2: What is Forward Proxy?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A server that sits between the client and the internet and hides the client identity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q3: What is Reverse Proxy?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A server that sits between users and backend servers and hides server details.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q4: Which Proxy Provides Load Balancing?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reverse Proxy.
Examples:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Nginx&lt;/li&gt;
&lt;li&gt;HAProxy&lt;/li&gt;
&lt;li&gt;Traefik&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Q5: Which Proxy Is Used for Privacy?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Forward Proxy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q6: Does Cloudflare Work as a Reverse Proxy?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes.
&lt;em&gt;Cloudflare sits between users and origin servers.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q7: Does Nginx Act as a Reverse Proxy?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes.
&lt;em&gt;Nginx is one of the most commonly used reverse proxy servers.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q8: Why Is Reverse Proxy Used in Microservices?&lt;br&gt;
Because it provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Load Balancing&lt;/li&gt;
&lt;li&gt;SSL Termination&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Service Discovery&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Why Companies Like Google Prefer gRPC for Microservices</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Sun, 21 Jun 2026 03:39:42 +0000</pubDate>
      <link>https://dev.to/jatin09/why-companies-like-google-prefer-grpc-for-microservices-5flm</link>
      <guid>https://dev.to/jatin09/why-companies-like-google-prefer-grpc-for-microservices-5flm</guid>
      <description>&lt;p&gt;&lt;strong&gt;REST vs gRPC&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;REST changed how applications communicate over the internet. But when companies started building hundreds of microservices that needed to talk to each other millions of times per second, REST began to show its limitations. That's where gRPC came in.&lt;/em&gt;&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9tu5a2b4gu18w19beodj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9tu5a2b4gu18w19beodj.png" alt="REST vs gRPC architecture overview" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
If you've built APIs before, you've probably used REST.&lt;br&gt;
A client sends an HTTP request, the server responds with JSON, and everything works perfectly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But what happens when&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Thousands of services communicate internally?&lt;/li&gt;
&lt;li&gt;Low latency becomes critical?&lt;/li&gt;
&lt;li&gt;Network traffic becomes massive?&lt;/li&gt;
&lt;li&gt;Multiple programming languages are involved?
This is exactly the challenge Google faced while running its enormous distributed systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve this problem, Google developed gRPC (Google Remote Procedure Call) and open-sourced it in 2015.&lt;/p&gt;

&lt;p&gt;Today, companies like Google, Netflix, Uber, Square, and many cloud-native applications use gRPC for internal service communication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is REST?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;REST (Representational State Transfer) is an architectural style for designing APIs.&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
A REST API exposes resources through 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;GET /users/101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Response:&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;{
  "id": 101,
  "name": "Jatin Gupta",
  "email": "jatin@example.com"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;REST commonly uses&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP/1.1&lt;/li&gt;
&lt;li&gt;JSON&lt;/li&gt;
&lt;li&gt;URLs&lt;/li&gt;
&lt;li&gt;GET, POST, PUT, DELETE methods&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;REST Workflow&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;Client
   |
HTTP Request
   |
Server
   |
JSON Response
   |
Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is RPC&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;RPC stands for Remote Procedure Call.&lt;br&gt;
Instead of accessing resources, the client directly calls a function that exists on another machine.&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;user = getUser(101)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though the function runs on a remote server, it feels like calling a local method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is gRPC&lt;/strong&gt;?&lt;br&gt;
gRPC is a modern implementation of RPC created by Google.&lt;br&gt;
It allows services to communicate efficiently using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP/2&lt;/li&gt;
&lt;li&gt;Protocol Buffers (Protobuf)&lt;/li&gt;
&lt;li&gt;Code Generation&lt;/li&gt;
&lt;li&gt;Bi-directional Streaming
Instead of exchanging JSON, gRPC exchanges compact binary data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;gRPC 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 Service   |
+-------------------+
          |
          |
          v
+-------------------+
|   gRPC Channel    |
+-------------------+
          |
          |
          v
+-------------------+
|   Server Service  |
+-------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The client calls a method directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;userService.getUser(101)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network communication happens automatically behind the scenes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How gRPC Works&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Step 1&lt;/strong&gt;: Define Service&lt;br&gt;
&lt;em&gt;Create a .proto file.&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;syntax = "proto3";

service UserService {
  rpc GetUser(UserRequest)
      returns (UserResponse);
}

message UserRequest {
  int32 id = 1;
}

message UserResponse {
  int32 id = 1;
  string name = 2;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Generate Code&lt;br&gt;
gRPC generates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java classes&lt;/li&gt;
&lt;li&gt;Go classes&lt;/li&gt;
&lt;li&gt;Python classes&lt;/li&gt;
&lt;li&gt;Node.js classes&lt;/li&gt;
&lt;li&gt;C# classes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Implement Server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public UserResponse getUser(UserRequest request) {
    return UserResponse.newBuilder()
        .setId(1)
        .setName("Jatin")
        .build();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Call From Client&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UserResponse user =
    client.getUser(request);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No manual JSON parsing.&lt;br&gt;
No URL creation.&lt;br&gt;
No request serialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;REST vs gRPC&lt;/em&gt;&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;| Feature         | REST      | gRPC             |
| --------------- | --------- | ---------------- |
| Protocol        | HTTP/1.1  | HTTP/2           |
| Data Format     | JSON      | Protocol Buffers |
| Speed           | Slower    | Faster           |
| Payload Size    | Large     | Small            |
| Streaming       | Limited   | Native           |
| Type Safety     | No        | Yes              |
| Code Generation | No        | Yes              |
| Browser Support | Excellent | Limited          |
| Microservices   | Good      | Excellent        |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why gRPC is Faster&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Binary Serialization&lt;/strong&gt;
REST uses JSON.&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;{
  "name":"Jatin"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gRPC converts the same data into compact binary format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smaller payloads&lt;/li&gt;
&lt;li&gt;Less bandwidth&lt;/li&gt;
&lt;li&gt;Faster parsing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. HTTP/2 Multiplexing&lt;/strong&gt;&lt;br&gt;
REST mostly uses HTTP/1.1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;:&lt;br&gt;
Multiple requests often require multiple connections.&lt;br&gt;
gRPC uses HTTP/2.&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple requests on one connection&lt;/li&gt;
&lt;li&gt;Reduced latency&lt;/li&gt;
&lt;li&gt;Better throughput
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Single Connection
 ├── Request 1
 ├── Request 2
 ├── Request 3
 └── Request 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;3. Strongly Typed Contracts&lt;/strong&gt;&lt;br&gt;
REST documentation can become outdated.&lt;/p&gt;

&lt;p&gt;gRPC uses &lt;strong&gt;.proto&lt;/strong&gt; files as the source of truth.&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear contracts&lt;/li&gt;
&lt;li&gt;Automatic validation&lt;/li&gt;
&lt;li&gt;Better developer experience&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Streaming: A Superpower of gRPC&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REST follows&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;Request -&amp;gt; Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gRPC supports:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Unary RPC&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;Request -&amp;gt; Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Server Streaming&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;Request -&amp;gt; Response 1
          Response 2
          Response 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Client Streaming&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;Request 1
Request 2
Request 3
        -&amp;gt; Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Bidirectional Streaming&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;Client &amp;lt;----&amp;gt; Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both can send messages simultaneously.&lt;br&gt;
This is extremely useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Live chats&lt;/li&gt;
&lt;li&gt;Gaming&lt;/li&gt;
&lt;li&gt;Video streaming&lt;/li&gt;
&lt;li&gt;IoT devices&lt;/li&gt;
&lt;li&gt;Real-time analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Google Uses gRPC&lt;/strong&gt;&lt;br&gt;
Google runs one of the world's largest distributed systems.&lt;br&gt;
A single user action may trigger dozens of services.&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;Search Service
      |
      +--&amp;gt; Ranking Service
      |
      +--&amp;gt; Ad Service
      |
      +--&amp;gt; User Profile Service
      |
      +--&amp;gt; Analytics Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If every communication used JSON:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More bandwidth&lt;/li&gt;
&lt;li&gt;More CPU usage&lt;/li&gt;
&lt;li&gt;More latency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;gRPC solves these issues by providing:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅ Smaller messages&lt;/p&gt;

&lt;p&gt;✅ Faster communication&lt;/p&gt;

&lt;p&gt;✅ Automatic code generation&lt;/p&gt;

&lt;p&gt;✅ Better scalability&lt;/p&gt;

&lt;p&gt;✅ Streaming support&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does gRPC Replace REST Completely?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No.&lt;/strong&gt;
This is one of the biggest misconceptions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;REST is still the best choice for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public APIs&lt;/li&gt;
&lt;li&gt;Browser applications&lt;/li&gt;
&lt;li&gt;Third-party integrations&lt;/li&gt;
&lt;li&gt;Mobile app backends&lt;/li&gt;
&lt;li&gt;Simpler systems
&lt;strong&gt;Example:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Frontend App
      |
     REST
      |
API Gateway
      |
     gRPC
      |
Microservices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This hybrid architecture is extremely common today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When Should You Use REST?&lt;/strong&gt;&lt;br&gt;
Choose REST when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building public APIs&lt;/li&gt;
&lt;li&gt;Working with browsers&lt;/li&gt;
&lt;li&gt;Simplicity matters&lt;/li&gt;
&lt;li&gt;Human-readable responses are needed&lt;/li&gt;
&lt;li&gt;Third-party developers consume your API&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When Should You Use gRPC?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose gRPC when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Building microservices&lt;/li&gt;
&lt;li&gt;Performance matters&lt;/li&gt;
&lt;li&gt;Low latency is critical&lt;/li&gt;
&lt;li&gt;High traffic systems exist&lt;/li&gt;
&lt;li&gt;Streaming is required&lt;/li&gt;
&lt;li&gt;Multiple programming languages are involved&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-World Example&lt;/strong&gt;&lt;br&gt;
Imagine an e-commerce platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REST Architecture&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;Frontend
   |
 REST
   |
Backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Works perfectly.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microservice Architecture&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;Frontend
    |
 REST API Gateway
    |
 --------------------------------
 |        |        |            |
User    Order   Payment   Inventory
         gRPC Services
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now hundreds of service-to-service calls happen every second.&lt;br&gt;
gRPC becomes the better option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;REST revolutionized web APIs and remains the standard for public-facing services. However, as applications evolved into large-scale distributed systems, the need for faster and more efficient communication became critical.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;That's why Google created gRPC.&lt;/strong&gt;&lt;br&gt;
The real question isn't "REST or gRPC?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;"Where should I use REST, and where should I use gRPC?"&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most successful modern systems combine both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REST for external communication.&lt;/li&gt;
&lt;li&gt;gRPC for internal microservice communication.
And that's why gRPC has become the backbone of many high-performance cloud-native applications today.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>backend</category>
      <category>microservices</category>
      <category>architecture</category>
    </item>
    <item>
      <title>"Kubernetes Sidecar Pattern Explained: The Secret Helper Container Running Beside Your App"</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Fri, 19 Jun 2026 17:34:18 +0000</pubDate>
      <link>https://dev.to/jatin09/kubernetes-sidecar-pattern-explained-the-secret-helper-container-running-beside-your-app-3l2b</link>
      <guid>https://dev.to/jatin09/kubernetes-sidecar-pattern-explained-the-secret-helper-container-running-beside-your-app-3l2b</guid>
      <description>&lt;p&gt;When developers start learning &lt;a href="https://kubernetes.io/" rel="noopener noreferrer"&gt;Kubernetes&lt;/a&gt;, they usually focus on &lt;em&gt;&lt;strong&gt;Pods, Deployments, Services, and Ingress&lt;/strong&gt;&lt;/em&gt;. But once applications grow in production, another powerful design pattern becomes very important: &lt;em&gt;&lt;strong&gt;the Sidecar Pattern&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Sidecar Pattern&lt;/strong&gt; is one of the most widely used Kubernetes patterns because it helps developers add extra functionality to an application without changing the application's code.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Felws8ltz2la9bgkeror6.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Felws8ltz2la9bgkeror6.png" alt="Kubernetes sidecar pattern explained" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the Sidecar Pattern?&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Imagine you have a car and attach a small sidecar to it.&lt;/em&gt;&lt;br&gt;
The motorcycle does its main job of transportation, while the sidecar provides additional functionality without changing the motorcycle itself.&lt;br&gt;
&lt;em&gt;The same idea exists in Kubernetes&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A Sidecar Container is an additional container that runs alongside the main application container inside the same Pod.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Both containers share&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Network&lt;/li&gt;
&lt;li&gt;Storage Volumes&lt;/li&gt;
&lt;li&gt;Lifecycle
This allows them to communicate easily and work together as a team.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Simple Representation&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;+--------------------------------+
|            POD                 |
|                                |
|  +---------+   +------------+  |
|  | Main    |&amp;lt;-&amp;gt;| Sidecar    |  |
|  | App     |   | Container  |  |
|  +---------+   +------------+  |
|                                |
+--------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main application focuses only on business logic, while the sidecar handles supporting tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Do We Need a Sidecar?&lt;/strong&gt;&lt;br&gt;
Many applications require additional features such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log collection&lt;/li&gt;
&lt;li&gt;Monitoring&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Data synchronization&lt;/li&gt;
&lt;li&gt;Traffic management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Without a Sidecar, developers often have to build these features directly into the application.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This creates several problems:&lt;/p&gt;

&lt;p&gt;❌ More code to maintain&lt;/p&gt;

&lt;p&gt;❌ Increased complexity&lt;/p&gt;

&lt;p&gt;❌ Duplicate logic across services&lt;/p&gt;

&lt;p&gt;❌ Difficult upgrades&lt;/p&gt;

&lt;p&gt;The Sidecar Pattern solves these issues by separating responsibilities.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;How Sidecar Works&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inside a Kubernetes Pod:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The main container runs the application.&lt;/li&gt;
&lt;li&gt;The sidecar container runs helper processes.&lt;/li&gt;
&lt;li&gt;Both containers share the same network namespace.&lt;/li&gt;
&lt;li&gt;They can access shared storage volumes.&lt;/li&gt;
&lt;li&gt;Kubernetes manages them together.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;Suppose your application generates logs.&lt;/p&gt;

&lt;p&gt;Instead of modifying the application to send logs to Elasticsearch or Splunk:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application writes logs to a file.&lt;/li&gt;
&lt;li&gt;Sidecar reads the file.&lt;/li&gt;
&lt;li&gt;Sidecar sends logs to a centralized logging system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application remains clean and focused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Use Cases of Sidecar Pattern&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Logging&lt;/strong&gt;&lt;br&gt;
This is one of the most popular uses of Sidecars.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
     |
Writes Logs
     |
     v
Log Collector Sidecar
     |
     v
Central Logging System
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fluent Bit&lt;/li&gt;
&lt;li&gt;Fluentd&lt;/li&gt;
&lt;li&gt;Vector&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- No logging code in application&lt;/li&gt;
&lt;li&gt;- Centralized log management&lt;/li&gt;
&lt;li&gt;- Easy replacement of logging tools&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;2. Monitoring&lt;/strong&gt;&lt;br&gt;
Applications expose metrics, while Sidecars collect and forward them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus exporters&lt;/li&gt;
&lt;li&gt;Monitoring agents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Better observability&lt;/li&gt;
&lt;li&gt;- Performance tracking&lt;/li&gt;
&lt;li&gt;- Resource monitoring&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;3. Service Mesh&lt;/strong&gt;&lt;br&gt;
Modern service meshes rely heavily on Sidecars.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Istio Envoy Proxy&lt;/li&gt;
&lt;li&gt;Linkerd Proxy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Sidecar intercepts network traffic and provides:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Load balancing&lt;/li&gt;
&lt;li&gt;- Traffic routing&lt;/li&gt;
&lt;li&gt;- Encryption&lt;/li&gt;
&lt;li&gt;- Retry mechanisms&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without changing application code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security-related functionality can be delegated to a Sidecar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TLS certificate management&lt;/li&gt;
&lt;li&gt;Authentication proxies&lt;/li&gt;
&lt;li&gt;Secret rotation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved security&lt;/li&gt;
&lt;li&gt;Centralized policy enforcement&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;5. Data Synchronization &amp;amp; Caching&lt;/strong&gt;&lt;br&gt;
Some applications need data from external systems.&lt;/p&gt;

&lt;p&gt;A Sidecar can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch data periodically&lt;/li&gt;
&lt;li&gt;Sync configuration&lt;/li&gt;
&lt;li&gt;Maintain local caches&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application simply consumes the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sidecar vs Without Sidecar&lt;/strong&gt;&lt;br&gt;
Without Sidecar&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application
 ├─ Logging Logic
 ├─ Monitoring Logic
 ├─ Security Logic
 └─ Business Logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tightly coupled&lt;/li&gt;
&lt;li&gt;Difficult maintenance&lt;/li&gt;
&lt;li&gt;Larger codebase&lt;/li&gt;
&lt;li&gt;Harder scaling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;With Sidecar&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;Application
 └─ Business Logic

Sidecar
 ├─ Logging
 ├─ Monitoring
 └─ Security
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Benefits:&lt;/p&gt;

&lt;p&gt;✅ Cleaner architecture&lt;/p&gt;

&lt;p&gt;✅ Better separation of concerns&lt;/p&gt;

&lt;p&gt;✅ Easier maintenance&lt;/p&gt;

&lt;p&gt;✅ Reusable functionality&lt;/p&gt;

&lt;p&gt;✅ Independent updates&lt;/p&gt;

&lt;p&gt;Real-World Example: Log Collection&lt;br&gt;
Let's say an e-commerce application generates logs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Main Container&lt;/em&gt;&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;E-commerce App
      |
Writes Logs
      |
      v
Shared Volume
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;Sidecar Container&lt;/strong&gt;&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;Fluent Bit Sidecar
      |
Reads Logs
      |
      v
Elasticsearch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application never needs to know where logs are stored.&lt;br&gt;
If tomorrow the company switches from Elasticsearch to another logging platform, only the Sidecar configuration changes.&lt;br&gt;
The application code remains untouched.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages of Sidecar Pattern&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Separation of Concerns&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each container focuses on a specific responsibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Reusability&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same Sidecar can be reused across multiple services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Independent Updates&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update logging or monitoring without redeploying application code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Improved Security&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sensitive functionality can be isolated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Better Maintainability&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Applications stay lightweight and easier to understand.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Challenges of Sidecar Pattern&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Although powerful, Sidecars are not free.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Resource Usage&lt;/strong&gt;&lt;br&gt;
Each Sidecar consumes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Increased Complexity&lt;/strong&gt;&lt;br&gt;
More containers mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More monitoring&lt;/li&gt;
&lt;li&gt;More debugging&lt;/li&gt;
&lt;li&gt;More configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pod Dependency&lt;br&gt;
If the Sidecar fails, application behavior may be affected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best Practices&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;Keep Sidecars Focused&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A Sidecar should have a single responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging Sidecar&lt;/li&gt;
&lt;li&gt;Monitoring Sidecar&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bad&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One Sidecar doing five different tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Monitor Resource Usage&lt;/p&gt;

&lt;p&gt;Always define:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resources:
  requests:
    cpu: 100m
    memory: 128Mi
  limits:
    cpu: 500m
    memory: 512Mi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use Shared Volumes Carefully&lt;br&gt;
Only share the data that is necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid Business Logic&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Business logic should stay in the main application.&lt;/li&gt;
&lt;li&gt;The Sidecar should only provide supporting capabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Sidecar Pattern is one of the most important Kubernetes design patterns used in modern cloud-native applications.&lt;/p&gt;

&lt;p&gt;Instead of stuffing logging, monitoring, security, and networking features into your application, Kubernetes allows you to run helper containers alongside the main container. This keeps applications clean, modular, and easier to maintain.&lt;/p&gt;

&lt;p&gt;Whether you're using Fluent Bit for logging, Prometheus exporters for monitoring, or Envoy proxies in a service mesh, chances are you're already benefiting from the Sidecar Pattern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The biggest takeaway is simple:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let your application focus on business logic, and let Sidecars handle everything else.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;That's the beauty of the Kubernetes Sidecar Pattern.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>backend</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>The Unsung Hero Behind Reliable Distributed Systems - Apache ZooKeeper</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Thu, 18 Jun 2026 03:45:20 +0000</pubDate>
      <link>https://dev.to/jatin09/the-unsung-hero-behind-reliable-distributed-systems-apache-zookeeper-475n</link>
      <guid>https://dev.to/jatin09/the-unsung-hero-behind-reliable-distributed-systems-apache-zookeeper-475n</guid>
      <description>&lt;p&gt;&lt;em&gt;If you've ever worked on distributed systems, you've probably heard people mention Apache ZooKeeper. For a long time, I knew it was important, but I didn't fully understand why so many large-scale systems depended on it.&lt;br&gt;
Then I started digging deeper into concepts like leader election, distributed coordination, service discovery, and fault tolerance. That's when ZooKeeper finally clicked.&lt;br&gt;
In this article, I'll explain ZooKeeper in simple terms, why it exists, the problems it solves, and how it works behind the scenes.&lt;/em&gt;&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%2Fur64cqkkbfghdoy04uj0.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%2Fur64cqkkbfghdoy04uj0.png" alt="Apache ZooKeeper architecture overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Do We Need ZooKeeper?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you're running a distributed application with multiple servers.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;All three servers are capable of performing the same task.&lt;br&gt;
Now suppose a cron job is scheduled to run every day at 9 AM.&lt;/p&gt;

&lt;p&gt;Without coordination:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server A → Executes Job
Server B → Executes Job
Server C → Executes Job
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of one report being generated, you now have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;3 reports&lt;/li&gt;
&lt;li&gt;3 emails sent&lt;/li&gt;
&lt;li&gt;Duplicate processing&lt;/li&gt;
&lt;li&gt;Data inconsistencies
Clearly, this is a problem.
What we really want is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server A → Executes Job
Server B → Waits
Server C → Waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only one server should be responsible for executing the task.&lt;br&gt;
But who decides which server gets the responsibility?&lt;br&gt;
This is where ZooKeeper enters the picture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Is &lt;em&gt;Apache ZooKeeper&lt;/em&gt;?&lt;/strong&gt;&lt;br&gt;
Apache ZooKeeper is a distributed coordination service that helps multiple servers agree on shared state.&lt;br&gt;
Think of it as a referee for distributed systems.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Instead of every server making independent decisions, ZooKeeper acts as a central coordination layer that answers questions like:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Who is the leader?&lt;/li&gt;
&lt;li&gt;Which servers are alive?&lt;/li&gt;
&lt;li&gt;Who owns a lock?&lt;/li&gt;
&lt;li&gt;Which node should process a task?&lt;/li&gt;
&lt;li&gt;Where is a service located?
In short, ZooKeeper helps &lt;strong&gt;distributed systems&lt;/strong&gt; stay organized.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Core Problem: &lt;em&gt;Coordination&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Distributed systems are hard because servers can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Crash unexpectedly&lt;/li&gt;
&lt;li&gt;Lose network connectivity&lt;/li&gt;
&lt;li&gt;Restart at any time&lt;/li&gt;
&lt;li&gt;Become temporarily unavailable
Without coordination, each server may make conflicting decisions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server A thinks it is leader.
Server B thinks it is leader.
Server C thinks both are dead.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your system is in chaos.&lt;br&gt;
ZooKeeper prevents these situations by maintaining a consistent view of the cluster.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;ZooKeeper Architecture&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
A ZooKeeper cluster typically consists of multiple ZooKeeper servers.&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;ZooKeeper Server 1
ZooKeeper Server 2
ZooKeeper Server 3
ZooKeeper Server 4
ZooKeeper Server 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Among them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One becomes the Leader&lt;/li&gt;
&lt;li&gt;The rest become Followers
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Leader
├── Follower
├── Follower
├── Follower
└── Follower
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The leader handles write operations while followers replicate data and serve read requests.&lt;br&gt;
This ensures consistency across the cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Multiple &lt;em&gt;ZooKeeper Servers&lt;/em&gt;?&lt;/strong&gt;&lt;br&gt;
Imagine ZooKeeper itself runs on only one machine.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If that machine crashes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Your entire distributed system becomes vulnerable.&lt;br&gt;
To avoid this, ZooKeeper runs as a cluster.&lt;br&gt;
As long as a majority of ZooKeeper nodes are alive, the system continues functioning.&lt;br&gt;
This concept is called a quorum.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Understanding Quorum&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
ZooKeeper requires a majority of nodes to be available.&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;Majority = (N / 2) + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Total Nodes | Required Majority |
| ----------- | ----------------- |
| 3           | 2                 |
| 5           | 3                 |
| 7           | 4                 |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a 5-node ZooKeeper cluster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node1
Node2
Node3
Node4
Node5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cluster continues operating 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;Node4 fails
Node5 fails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Leader Election Explained&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
One of ZooKeeper's most famous use cases is leader election.&lt;br&gt;
Suppose three application servers are running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App Server A
App Server B
App Server C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each server registers itself with ZooKeeper.&lt;br&gt;
ZooKeeper elects one server as the leader.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Leader → Server B
Followers → Server A, Server C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now only Server B executes critical tasks.&lt;br&gt;
If Server B crashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server B ❌
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ZooKeeper automatically elects a new leader.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Leader → Server A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The system keeps running without manual intervention.&lt;br&gt;
This is one of the reasons distributed systems remain highly available.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Distributed Locking&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
Another common problem:&lt;br&gt;
Two servers try to update the same resource simultaneously.&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;Server A updates Inventory
Server B updates Inventory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This may create inconsistent data.&lt;br&gt;
ZooKeeper solves this using distributed locks.&lt;/p&gt;

&lt;p&gt;Before modifying the resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server A requests lock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ZooKeeper grants it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lock Owner → Server A
&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;Server B waits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When Server A finishes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then ZooKeeper allows Server B to proceed.&lt;br&gt;
This prevents race conditions.&lt;/p&gt;

&lt;p&gt;Service Discovery&lt;br&gt;
In microservice architectures, services constantly come and go.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Payment Service
Order Service
Notification Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How does the Order Service know where the Payment Service is running?&lt;br&gt;
ZooKeeper can maintain a registry of available services.&lt;/p&gt;

&lt;p&gt;When a service starts:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When it stops:&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;Deregister Service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other services can query ZooKeeper to discover active instances.&lt;br&gt;
This process is called Service Discovery.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Cluster Membership&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
ZooKeeper continuously tracks active servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For 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;Server A ✅
Server B ✅
Server C ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If Server B crashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Server B ❌
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ZooKeeper immediately updates cluster membership information.&lt;br&gt;
Other servers become aware of the change and adjust accordingly.&lt;br&gt;
This is critical for maintaining system stability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How ZooKeeper Stores Data&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ZooKeeper stores information in a hierarchical structure called a ZNode Tree.&lt;br&gt;
It looks similar to a file system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/
├── services
│   ├── payment
│   └── order
│
├── leaders
│   └── appLeader
│
└── locks
    └── inventoryLock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each node is called a ZNode.&lt;/p&gt;

&lt;p&gt;A ZNode can store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metadata&lt;/li&gt;
&lt;li&gt;Configuration&lt;/li&gt;
&lt;li&gt;Leader information&lt;/li&gt;
&lt;li&gt;Lock ownership details&lt;/li&gt;
&lt;li&gt;Service registration data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ephemeral Nodes: The Secret Sauce&lt;/strong&gt;&lt;br&gt;
ZooKeeper provides a special type of node called an Ephemeral Node.&lt;br&gt;
These nodes exist only while the client connection remains active.&lt;/p&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;Server A registers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ZooKeeper creates:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If Server A crashes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;ZooKeeper automatically removes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This makes failure detection extremely reliable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watches: Real-Time Notifications&lt;/strong&gt;&lt;br&gt;
Instead of continuously polling ZooKeeper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Are there changes?
Are there changes?
Are there changes?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Applications can register watches.&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;Watch Leader Node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If leadership changes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;ZooKeeper immediately notifies interested clients.&lt;br&gt;
This makes coordination efficient and responsive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Real-World Systems That Use ZooKeeper&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Many large-scale distributed systems have relied on ZooKeeper, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kafka.apache.org/" rel="noopener noreferrer"&gt;Apache Kafka&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hbase.apache.org/" rel="noopener noreferrer"&gt;Apache HBase&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://solr.apache.org/" rel="noopener noreferrer"&gt;Apache Solr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://storm.apache.org/" rel="noopener noreferrer"&gt;Apache Storm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Historically, Kafka used ZooKeeper heavily for broker coordination and leader election before moving toward KRaft mode in newer versions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Advantages of ZooKeeper&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reliable Coordination&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provides a consistent source of truth for distributed systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatic Leader Election&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Handles leader selection and failover automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distributed Locking&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Prevents conflicting operations across multiple servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Service Discovery&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Helps services find each other dynamically.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Fault Tolerance&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Continues functioning even when some nodes fail.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Limitations of ZooKeeper&lt;/strong&gt;&lt;br&gt;
ZooKeeper is powerful, but it's not a database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Avoid using it for&lt;/strong&gt;&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Large data storage&lt;/li&gt;
&lt;li&gt;Heavy write workloads&lt;/li&gt;
&lt;li&gt;Analytics&lt;/li&gt;
&lt;li&gt;Transactional business data
ZooKeeper is designed for coordination metadata, not application data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;A Simple Analogy&lt;/em&gt;&lt;br&gt;
Imagine a group of friends planning a road trip.&lt;/p&gt;

&lt;p&gt;Without coordination:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Everyone books hotels.
Everyone chooses routes.
Everyone buys tickets.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Chaos.&lt;br&gt;
Now imagine one coordinator managing everything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Who drives?
Who books hotels?
Who handles payments?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone follows the same plan.&lt;br&gt;
ZooKeeper plays that coordinator role inside distributed systems.&lt;/p&gt;

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

&lt;p&gt;When people first learn distributed systems, concepts like load balancing, replication, fault tolerance, and microservices seem exciting.&lt;/p&gt;

&lt;p&gt;But behind all of these lies a less glamorous challenge: coordination.&lt;/p&gt;

&lt;p&gt;Distributed systems fail not because servers are weak, but because multiple servers struggle to agree on what should happen next.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Apache ZooKeeper solves exactly that problem.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It provides a reliable mechanism for leader election, distributed locking, service discovery, cluster membership tracking, and synchronization across nodes. Instead of every server making its own decisions, ZooKeeper ensures the entire system operates with a shared understanding of reality.&lt;/p&gt;

&lt;p&gt;The next time you hear someone mention leader election or distributed coordination in a system design interview, you'll know why ZooKeeper has been one of the most important building blocks in distributed computing for over a decade.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>software</category>
      <category>architecture</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>How File Upload Works at Scale?</title>
      <dc:creator>Jatin Gupta</dc:creator>
      <pubDate>Sat, 13 Jun 2026 08:56:12 +0000</pubDate>
      <link>https://dev.to/jatin09/how-file-upload-works-at-scale-53a6</link>
      <guid>https://dev.to/jatin09/how-file-upload-works-at-scale-53a6</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Ever wondered what actually happens after you click the "Upload" button?&lt;br&gt;
You select a file, and within seconds it appears in &lt;a href="https://drive.google.com/drive" rel="noopener noreferrer"&gt;Google Drive&lt;/a&gt; or &lt;a href="https://aws.amazon.com/pm/serv-s3/" rel="noopener noreferrer"&gt;Amazon S3&lt;/a&gt;. But behind that simple button is a highly optimized distributed system designed to handle millions of uploads every day.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The System Design Behind Google Drive &amp;amp; Amazon S3 Uploads&lt;/strong&gt;&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%2Fg7xkn0ltc96zl6m24ik5.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%2Fg7xkn0ltc96zl6m24ik5.png" alt="File upload flow to S3 diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Naive Approach ❌&lt;/strong&gt;&lt;br&gt;
A beginner might think the process is simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
    |
    |
Upload File
    |
    v
Server
    |
    |
Store File
    |
    v
Storage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seems easy...&lt;br&gt;
&lt;strong&gt;But imagine:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 GB video&lt;/li&gt;
&lt;li&gt;10 million users&lt;/li&gt;
&lt;li&gt;Slow internet&lt;/li&gt;
&lt;li&gt;Network failures&lt;/li&gt;
&lt;li&gt;Server crashes
This architecture would fail quickly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Problems:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server bandwidth becomes bottleneck&lt;/li&gt;
&lt;li&gt;High CPU usage&lt;/li&gt;
&lt;li&gt;Upload restarts if connection drops&lt;/li&gt;
&lt;li&gt;Difficult to scale
So companies use a much smarter architecture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: User Selects a File&lt;br&gt;
When you choose a file,&lt;br&gt;
the client immediately gathers metadata:&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="err"&gt;filename:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vacation.mp4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;size:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;2.1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;GB&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="err"&gt;type:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"video/mp4"&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;Notice&lt;/strong&gt;:&lt;br&gt;
The actual file is not uploaded yet.&lt;br&gt;
Only metadata is prepared.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: Client Sends Metadata to API&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
      |
      | filename
      | size
      | contentType
      |
      v
API Gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;The API validates:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User authentication&lt;/li&gt;
&lt;li&gt;Storage quota&lt;/li&gt;
&lt;li&gt;File type&lt;/li&gt;
&lt;li&gt;Permissions
If everything is valid, it proceeds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Backend Generates a Pre-Signed URL&lt;br&gt;
Instead of sending the file through the application server,&lt;br&gt;
the backend requests a secure upload URL.&lt;br&gt;
&lt;/p&gt;

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

                     |
                     |
          Generate Upload URL
                     |
                     |
                     v

                  Amazon S3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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 http"&gt;&lt;code&gt;&lt;span class="err"&gt;https://bucket.s3.amazonaws.com/file123
?signature=abcxyz
&amp;amp;expires=600
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called a &lt;strong&gt;&lt;em&gt;Pre-Signed URL&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
It is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Temporary&lt;/li&gt;
&lt;li&gt;Secure&lt;/li&gt;
&lt;li&gt;Limited permission&lt;/li&gt;
&lt;li&gt;Expires automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Use Pre-Signed URLs?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Without it:&lt;br&gt;
&lt;/p&gt;

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

     |

Application Server

     |

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

&lt;/div&gt;



&lt;p&gt;Every byte passes through your server.&lt;br&gt;
Bad idea.&lt;/p&gt;

&lt;p&gt;With &lt;strong&gt;pre-signed&lt;/strong&gt; URLs:&lt;br&gt;
&lt;/p&gt;

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

     |----------------------&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;The application server only handles authorization.&lt;br&gt;
The heavy file upload goes directly to cloud storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less server load&lt;/li&gt;
&lt;li&gt;Lower cost&lt;/li&gt;
&lt;li&gt;Better scalability&lt;/li&gt;
&lt;li&gt;Faster uploads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;: Client Uploads Directly to S3&lt;br&gt;
Now the client uploads directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client
      |
      |
      | 2 GB file
      |
      |
      v
Amazon S3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The backend is no longer in the data path.&lt;br&gt;
This is exactly why systems can support millions of users simultaneously.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt;: Storage Returns Success&lt;br&gt;
After upload:&lt;br&gt;
&lt;/p&gt;

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

  |

200 OK

  |

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

&lt;/div&gt;



&lt;p&gt;The client now knows the upload succeeded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt;: Metadata is Saved&lt;br&gt;
The application server stores information like:&lt;br&gt;
&lt;/p&gt;

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

-----------------------------------

id

userId

filename

storageKey

size

mimeType

createdAt

updatedAt

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt;:&lt;br&gt;
The database stores metadata, not the actual file.&lt;br&gt;
The actual file remains inside object storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Architecture&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;                Metadata

Client --------------------&amp;gt;

                     API

                      |

                      |

          Generate Pre-Signed URL

                      |

                      |

                      v

                    S3

                      ^

                      |

                      |

Client -----------------------&amp;gt; Upload File


                      |

                      |

               Save Metadata

                      |

                      v

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;What Happens if Internet Disconnects?&lt;/strong&gt;&lt;/em&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;Uploading...

███████████░░░░░░░░
         60%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Internet goes off.&lt;br&gt;
Without special handling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Start Again ❌
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uploading a 5 GB file again is frustrating.&lt;br&gt;
Modern systems avoid this using &lt;em&gt;Resumable Uploads&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resumable Upload&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of one huge file,&lt;br&gt;
the client divides it into chunks.&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;File

|

|

-----------------------------

Chunk 1

Chunk 2

Chunk 3

Chunk 4

Chunk 5

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Maybe&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;20 MB each
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upload Process&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Chunk 1 ✅

Chunk 2 ✅

Chunk 3 ✅

Chunk 4 ❌

Chunk 5 ❌
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Connection lost.&lt;/p&gt;

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

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

|

|

Resume

|

|

Chunk 4 ✅

Chunk 5 ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only missing chunks are uploaded.&lt;br&gt;
Huge bandwidth savings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Multipart Upload in Amazon S3&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Amazon S3 supports Multipart Upload:&lt;br&gt;
&lt;/p&gt;

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

        |

        |

Upload Part 1

Upload Part 2

Upload Part 3

Upload Part 4

        |

        |

Complete Upload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Internally, S3 assembles all parts into a single object.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Retry individual parts&lt;/li&gt;
&lt;li&gt;Parallel uploads&lt;/li&gt;
&lt;li&gt;Better reliability&lt;/li&gt;
&lt;li&gt;Faster performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Parallel Upload&lt;br&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;Chunk1

↓

Chunk2

↓

Chunk3

↓

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

&lt;/div&gt;



&lt;p&gt;Systems do:&lt;br&gt;
&lt;/p&gt;

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

Chunk2 -----&amp;gt;

Chunk3 -----&amp;gt;

Chunk4 -----&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All at once.&lt;br&gt;
This significantly reduces upload time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What About Very Large Files?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;For files like&lt;/em&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10 GB&lt;/li&gt;
&lt;li&gt;20 GB&lt;/li&gt;
&lt;li&gt;100 GB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Systems use&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;
Chunking&lt;br&gt;
Multipart upload&lt;br&gt;
Retry logic&lt;br&gt;
Checksum verification&lt;br&gt;
Background processing&lt;/p&gt;

&lt;p&gt;This ensures reliability even over unstable networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Sync Works Across Multiple Devices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Suppose you upload from your laptop.&lt;br&gt;
&lt;/p&gt;

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

      |

      |

Cloud Storage

     /   \

    /     \

Phone    Tablet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the upload completes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Metadata is updated&lt;/li&gt;
&lt;li&gt;Sync service detects changes&lt;/li&gt;
&lt;li&gt;Other devices receive notifications&lt;/li&gt;
&lt;li&gt;Only changed files are downloaded
That's why your phone quickly shows the new file without manually refreshing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Don't Companies Store Files in Databases?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Imagine storing a 2 GB video directly inside MySQL or PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problems&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Massive database growth&lt;/li&gt;
&lt;li&gt;Slow backups&lt;/li&gt;
&lt;li&gt;Expensive replication&lt;/li&gt;
&lt;li&gt;Poor performance&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Database

↓

Stores:
&lt;span class="p"&gt;
-&lt;/span&gt; filename
&lt;span class="p"&gt;-&lt;/span&gt; owner
&lt;span class="p"&gt;-&lt;/span&gt; path
&lt;span class="p"&gt;-&lt;/span&gt; size
&lt;span class="p"&gt;-&lt;/span&gt; permissions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Object Storage

↓

Stores:

Actual binary file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This separation makes systems scalable and easier to maintain.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Real Production Flow&lt;/strong&gt;&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;                    User

                      |

                      |

                Select File

                      |

                      |

             Send Metadata

                      |

                      v

               API Gateway

                      |

          Authentication

                      |

      Generate Pre-Signed URL

                      |

                      v

                Object Storage

          &amp;lt;--------------------

             Direct Upload

                      |

                      |

             Upload Success

                      |

                      |

             Save Metadata

                      |

                      v

                  Database

                      |

                      |

             Notify Sync Service

                      |

          -----------------------

          |                     |

       Laptop               Mobile

          |                     |

       Synced ✅             Synced ✅
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Interview Questions&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Q1. Why shouldn't files pass through the application server?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Because it creates a bandwidth bottleneck, increases server cost, and limits scalability. Direct uploads to object storage are more efficient.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Q2. What is a Pre-Signed URL?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A temporary, secure URL generated by the backend that allows a client to upload directly to object storage without exposing permanent credentials.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Q3. Why store metadata in a database instead of the file itself?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Databases are optimized for structured data and queries, while object storage is optimized for storing large binary files reliably and cost-effectively.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Q4. What is Multipart Upload?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;It splits a large file into multiple parts that can be uploaded independently and then combined by the storage service into one object.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Q5. What is Resumable Upload?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A mechanism where interrupted uploads continue from the last successfully uploaded chunk instead of restarting from zero.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>distributedsystems</category>
      <category>aws</category>
      <category>google</category>
    </item>
    <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>
