<?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: Zidane</title>
    <description>The latest articles on DEV Community by Zidane (@zidane1688).</description>
    <link>https://dev.to/zidane1688</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%2F4058907%2Feef322f6-a060-4291-ac32-969c7c7fc20f.png</url>
      <title>DEV Community: Zidane</title>
      <link>https://dev.to/zidane1688</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zidane1688"/>
    <language>en</language>
    <item>
      <title>What ACTUALLY Happens When You Type a URL google.com</title>
      <dc:creator>Zidane</dc:creator>
      <pubDate>Sun, 16 Aug 2026 08:29:26 +0000</pubDate>
      <link>https://dev.to/zidane1688/what-actually-happens-when-you-type-a-url-googlecom-58p6</link>
      <guid>https://dev.to/zidane1688/what-actually-happens-when-you-type-a-url-googlecom-58p6</guid>
      <description>&lt;h1&gt;&lt;span&gt;&lt;span&gt;What ACTUALLY Happens When You Type a URL google.com&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span&gt;&lt;span&gt;&lt;br&gt;
&lt;p&gt;"If you’ve ever interviewed for a software engineering role, you’ve probably been asked: 'What happens when you type &lt;code&gt;google.com&lt;/code&gt; into a browser and press Enter?'&lt;/p&gt;
&lt;p&gt;Most developers give the standard textbook answer: Your browser looks up the IP via DNS, opens a TCP connection, sends an HTTP GET request, and renders the HTML.&lt;/p&gt;
&lt;p&gt;While that answer might pass a Junior interview, it completely ignores the complex systems engineering happening under the hood. In reality, within less than &lt;span&gt;100 milliseconds&lt;/span&gt;, your operating system kernel, network interface card, BGP routers, TLS cryptographic primitives, and global edge networks execute a synchronized choreography involving dozens of low-level protocols.&lt;/p&gt;
&lt;p&gt;Welcome back to &lt;span&gt;Behind the Abstraction&lt;/span&gt;. Today, we’re upgrading the classic interview question to the &lt;span&gt;Senior Engineer Edition&lt;/span&gt;. Let's strip away the browser magic and trace every single packet from your keyboard to Google’s data centers."&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 1: Hardware Interrupts &amp;amp; OS Kernel Space&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"It all starts at the physical layer. The moment your finger depresses the &lt;span&gt;Enter&lt;/span&gt; key, a circuit on your keyboard closes, sending an electrical signal to your computer’s interrupt controller.&lt;/p&gt;
&lt;p&gt;The CPU pauses its current execution context and fires a &lt;span&gt;Hardware Interrupt&lt;/span&gt;. The OS Kernel catches this via an &lt;span&gt;Interrupt Service Routine (ISR)&lt;/span&gt;, translating the raw hardware keycode into a readable character event.&lt;/p&gt;
&lt;p&gt;The browser process—running in &lt;span&gt;User Space&lt;/span&gt;—receives this input event. Chrome's UI thread checks the address bar. Is &lt;code&gt;google.com&lt;/code&gt; a search query or a domain? Because it contains a top-level domain (&lt;code&gt;.com&lt;/code&gt;), Chrome recognizes it as a URL.&lt;/p&gt;
&lt;p&gt;If you have HSTS—&lt;span&gt;HTTP Strict Transport Security&lt;/span&gt;—pre-loaded in your browser binary, Chrome immediately transforms &lt;code&gt;&lt;a href="http://google.com" rel="noopener noreferrer"&gt;http://google.com&lt;/a&gt;&lt;/code&gt;&amp;nbsp;into &lt;code&gt;&lt;a href="https://google.com" rel="nofollow noopener noreferrer"&gt;&lt;/a&gt;&lt;a href="https://google.com" rel="noopener noreferrer"&gt;https://google.com&lt;/a&gt;&lt;/code&gt;&amp;nbsp;before a single network packet is even created, preventing plain-text downgrade attacks right at the starting line."&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 2: The Deep-Dive DNS Resolution Chain&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"Before your computer can send data, it needs an IP address. But DNS resolution isn't just one API call—it’s a multi-tiered fallback hierarchy.&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Browser Cache:&lt;/span&gt; Chrome checks its internal socket pool and DNS cache.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;OS Cache &amp;amp; Hosts File:&lt;/span&gt; If missed, Chrome executes a system call (&lt;code&gt;getaddrinfo&lt;/code&gt; on Linux/macOS) to query the OS DNS cache and check &lt;code&gt;/etc/hosts&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Recursive Resolver:&lt;/span&gt; If still not found, the OS network stack constructs a &lt;span&gt;UDP packet&lt;/span&gt; over port 53 and sends it to your configured Resolver (like your ISP router or &lt;code&gt;8.8.8.8&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If the resolver doesn't have the IP cached, it performs a full &lt;span&gt;Iterative Traversal&lt;/span&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It queries the &lt;span&gt;Root Name Server (&lt;code&gt;.&lt;/code&gt;)&lt;/span&gt;, which points to the &lt;span&gt;TLD Server (&lt;code&gt;.com&lt;/code&gt;)&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It queries the &lt;code&gt;.com&lt;/code&gt; TLD Server, which returns the IP of Google's &lt;span&gt;Authoritative Name Server&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, Google's Name Server returns an &lt;code&gt;A&lt;/code&gt; record (for IPv4) or &lt;code&gt;AAAA&lt;/code&gt; record (for IPv6), along with an &lt;span&gt;Anycast IP address&lt;/span&gt;."&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 3: Packet Assembly &amp;amp; MAC Address Resolution&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"Now that your OS has Google's IP address, it opens a network socket using the &lt;code&gt;socket()&lt;/code&gt; system call. But your computer doesn't know how to physically transmit packets to an IP address across the internet—it can only transmit frames to a physical &lt;span&gt;MAC Address&lt;/span&gt; on your local network.&lt;/p&gt;
&lt;p&gt;This is where the &lt;span&gt;ARP Protocol&lt;/span&gt; (Address Resolution Protocol) comes in. If your computer doesn't have your local Wi-Fi router's MAC address cached, it broadcasts an &lt;span&gt;ARP Request&lt;/span&gt; across the local network: 'Who has IP &lt;code&gt;192.168.1.1&lt;/code&gt;?' The router replies with its physical hardware MAC address.&lt;/p&gt;
&lt;p&gt;Now, your OS network stack encapsulates the payload like Russian nesting dolls:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Transport Layer:&lt;/span&gt; Adds a &lt;span&gt;TCP Header&lt;/span&gt; specifying source and destination ports (Port 443 for HTTPS).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Network Layer:&lt;/span&gt; Encapsulates the TCP segment in an &lt;span&gt;IP Packet&lt;/span&gt; with source and destination IP addresses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Link Layer:&lt;/span&gt; Wraps the IP packet inside an &lt;span&gt;Ethernet Frame&lt;/span&gt; containing your Router's destination MAC address.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The frame is converted into radio waves via Wi-Fi or light pulses over Fiber, leaving your machine."&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 4: BGP Routing, TCP Handshake &amp;amp; TLS 1.3&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"Your packet travels across the global internet infrastructure using &lt;span&gt;BGP (Border Gateway Protocol)&lt;/span&gt;. Because Google uses &lt;span&gt;Anycast Routing&lt;/span&gt;, the internet routes your request to the geographically closest Google &lt;span&gt;Edge Point of Presence (PoP)&lt;/span&gt;, rather than a distant central data center.&lt;/p&gt;
&lt;p&gt;Once the packet arrives at Google’s edge router, the two machines must establish a connection:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;TCP 3-Way Handshake:&lt;/span&gt; Your client sends a &lt;code&gt;SYN&lt;/code&gt;, Google replies with &lt;code&gt;SYN-ACK&lt;/code&gt;, and your client returns an &lt;code&gt;ACK&lt;/code&gt;. Connection established.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;TLS 1.3 Encryption Handshake:&lt;/span&gt; Because it's HTTPS, we need encryption. In modern &lt;span&gt;TLS 1.3&lt;/span&gt;, this takes just &lt;span&gt;one single round-trip (1-RTT)&lt;/span&gt;. Your browser sends a &lt;code&gt;ClientHello&lt;/code&gt; containing supported cryptographic cipher suites and a key share. Google responds with &lt;code&gt;ServerHello&lt;/code&gt;, its digital certificate, and its public key share.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Using &lt;span&gt;Elliptic-Curve Diffie-Hellman (ECDHE)&lt;/span&gt;, both sides independently calculate a shared symmetric encryption key. From this millisecond onward, all traffic is encrypted end-to-end."&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 5: Edge Reverse Proxies &amp;amp; Browser Rendering&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"Your browser sends an encrypted &lt;code&gt;HTTP/2&lt;/code&gt; or &lt;code&gt;HTTP/3&lt;/code&gt; (QUIC over UDP) &lt;code&gt;GET&lt;/code&gt; request.&lt;/p&gt;
&lt;p&gt;It hits a &lt;span&gt;GFE (Google Front End)&lt;/span&gt; reverse proxy server. The GFE terminates the TLS connection, checks its edge cache, or routes the request through Google’s internal high-speed fiber network to a backend rendering service.&lt;/p&gt;
&lt;p&gt;Google returns an HTTP &lt;code&gt;200 OK&lt;/code&gt; response along with the HTML payload, compressed via &lt;span&gt;Brotli&lt;/span&gt; or &lt;span&gt;Gzip&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Now, the browser's engine (like Blink in Chrome) takes over the &lt;span&gt;Critical Rendering Path&lt;/span&gt;:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;HTML Parser:&lt;/span&gt; Parses raw bytes into the &lt;span&gt;DOM (Document Object Model)&lt;/span&gt; tree.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Pre-loader:&lt;/span&gt; Scans ahead to fetch external CSS, JavaScript, and images in parallel.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;CSSOM &amp;amp; Render Tree:&lt;/span&gt; Parses CSS to build the CSSOM, combining it with the DOM to construct the &lt;span&gt;Render Tree&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;span&gt;Layout &amp;amp; Paint:&lt;/span&gt; Calculates exact pixel coordinates for every element (Layout) and rasterizes them onto GPU layers (Paint).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Within less than a tenth of a second, the Google search bar appears on your screen."&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;⏱️ CHAPTER 6: Conclusion &amp;amp; Senior Mindset&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;"From an electrical signal on a keyboard to OS system calls, BGP packet routing, Diffie-Hellman cryptography, and GPU rasterization—typing a single URL triggers one of the most sophisticated engineering achievements in human history.&lt;/p&gt;
&lt;p&gt;Understanding these layers isn't just about acing system design interviews. It’s what helps you debug production latency bottlenecks, optimize critical rendering paths, and build resilient, distributed architectures.&lt;/p&gt;
&lt;p&gt;If you enjoyed peeling back the layers of this system abstraction, smash the Like button and subscribe to the channel!&lt;/p&gt;
&lt;p&gt;Drop a comment below: What technical topic should we dismantle next? Thanks for watching, and I'll see you in the next one!"&lt;br&gt;&lt;br&gt;&lt;span&gt;#webzonezidane&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;#webzonetechtips&lt;/span&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/span&gt;

</description>
      <category>technology</category>
      <category>google</category>
    </item>
    <item>
      <title>Inside Facebook's News Feed Architecture</title>
      <dc:creator>Zidane</dc:creator>
      <pubDate>Sat, 08 Aug 2026 04:50:06 +0000</pubDate>
      <link>https://dev.to/zidane1688/inside-facebooks-news-feed-architecture-10n7</link>
      <guid>https://dev.to/zidane1688/inside-facebooks-news-feed-architecture-10n7</guid>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;&lt;span&gt;Inside Facebook's News Feed Architecture&lt;/span&gt;&lt;/h1&gt;
&lt;br&gt;&lt;h3&gt;&lt;br&gt;&lt;/h3&gt;
&lt;h3&gt;Chapter 1: The Scale &amp;amp; SLA Challenge&lt;/h3&gt;"Every single day, more than three billion people around the globe unlock their phones and launch Facebook. Within a split second, a personalized feed appears on their screen—populated with photos from close friends, trending videos, group discussions, and targeted announcements. To the average user, this feels like magic. But beneath this clean mobile interface lies one of the most sophisticated and terrifyingly complex distributed systems ever engineered by humankind.&lt;p&gt;Consider the sheer operational scale. At any given moment, there are tens of thousands of candidate posts competing for space on your screen. If Facebook used a naive SQL database query to search through billions of posts across millions of friends, the network would freeze immediately. Yet, the engineering requirement—the strictly enforced Service Level Agreement—mandates that your news feed must render in less than three hundred milliseconds with high availability. How do you filter, rank, and assemble a totally unique content stream for billions of concurrent users in the blink of an eye? Let’s step behind the curtain and dissect the architecture."&lt;/p&gt;
&lt;h3&gt;Chapter 2: Graph Data Modeling with TAO&lt;/h3&gt;
&lt;p&gt;"To understand how Facebook processes connections, we must first look at how data is stored. Traditional relational databases rely on rows, columns, and expensive table JOIN operations. At Facebook's scale, joining user tables with post tables across global data centers is an absolute non-starter.&lt;/p&gt;
&lt;p&gt;Instead, Facebook built &lt;b&gt;TAO&lt;/b&gt;—which stands for The Association Object. TAO is a geographically distributed, read-optimized graph database. Rather than thinking in terms of database tables, TAO treats the entire social network as a massive graph made of &lt;b&gt;Nodes&lt;/b&gt; and &lt;b&gt;Edges&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;Nodes represent concrete entities—such as a User, a Photo, a Comment, or a Page. Edges represent the directed relationships between these entities—such as 'User A is Friends with User B', 'User A Liked Photo C', or 'User B Commented on Post D'. TAO handles trillions of edge queries every day. By storing these relationships directly in memory across massive distributed caching tiers, TAO allows the system to traverse your entire social graph in mere microseconds."&lt;/p&gt;

&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLLkLnN5NPPPoSxspLjlcZZJguwj-hh4rfPu7K95-vt-Ccu-IiXUjOm0-PcgxW0id1c9Bj0QzfzfXxknWTu-LKYRP17bPu2lzkeMaK2KjDrEN6A1pcmSDVulZxcmpYoVoAWDYAxwWr9UQCwJZf4D72hiQrEyTrajzBSjL2cMvMKwBkE2XL-aAcTkkcpN4/s1058/Inside%20Facebook's%20News%20Feed%20Architecture.png" rel="noopener noreferrer"&gt;&lt;img alt="Inside Facebook's News Feed Architecture - Webzone tech tips - Zidane" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblogger.googleusercontent.com%2Fimg%2Fb%2FR29vZ2xl%2FAVvXsEhLLkLnN5NPPPoSxspLjlcZZJguwj-hh4rfPu7K95-vt-Ccu-IiXUjOm0-PcgxW0id1c9Bj0QzfzfXxknWTu-LKYRP17bPu2lzkeMaK2KjDrEN6A1pcmSDVulZxcmpYoVoAWDYAxwWr9UQCwJZf4D72hiQrEyTrajzBSjL2cMvMKwBkE2XL-aAcTkkcpN4%2Fs1600%2FInside%2520Facebook%27s%2520News%2520Feed%2520Architecture.png" title="Inside Facebook's News Feed Architecture - Webzone tech tips - Zidane" width="737" height="1058"&gt;&lt;/a&gt;&lt;br&gt;
&lt;h3&gt;Chapter 3: The Fan-Out Dilemma &amp;amp; Hybrid Architecture&lt;/h3&gt;
&lt;p&gt;"Once you have the social graph, how do you deliver a new post to a user’s friends? This brings us to one of the most famous system design tradeoffs: &lt;b&gt;Fan-out on Write&lt;/b&gt; versus &lt;b&gt;Fan-out on Read&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;In a &lt;b&gt;Fan-out on Write&lt;/b&gt; model—also known as the Push Model—when you publish a post, the system immediately writes a reference of that post into the inbox memory cache of every single one of your friends. When your friends open the app, reading their feed is blazingly fast because their timeline cache is already pre-assembled. This works brilliantly for regular users who have a few hundred friends.&lt;/p&gt;
&lt;p&gt;However, this model completely breaks down when applied to high-profile accounts or celebrities. Imagine a global icon with one hundred million followers publishing a status update. Under a pure push model, a single button click would force the servers to write one hundred million database entries simultaneously. This causes catastrophic write amplification, CPU spikes, and severe network throttling—a scenario known as the Thundering Herd problem.&lt;/p&gt;
&lt;p&gt;To solve this, Facebook deployed a &lt;b&gt;Hybrid Fan-out System&lt;/b&gt;. For standard users with moderate friend counts, the system uses Fan-out on Write. But for celebrities, public figures, and viral pages, the system switches to Fan-out on Read. Their posts are stored in a dedicated hot cache. Only when you open your app does the backend pull that celebrity’s post on demand and merge it into your feed seamlessly."&lt;/p&gt;
&lt;h3&gt;Chapter 4: Multi-Tier Caching Infrastructure&lt;/h3&gt;
&lt;p&gt;"Latency is the ultimate enemy of user retention. Fetching feed items from persistent storage disks on every scroll is far too slow. To achieve sub-millisecond retrieval speeds, Facebook engineered one of the world's largest distributed &lt;b&gt;RAM caching infrastructures&lt;/b&gt;, heavily built around optimized &lt;b&gt;Memcached&lt;/b&gt; clusters.&lt;/p&gt;
&lt;p&gt;When you scroll your feed, almost nothing comes directly from a hard drive; your feed is served almost entirely out of RAM. Facebook created &lt;b&gt;Mcrouter&lt;/b&gt;, an open-source memcached protocol router, to manage traffic across millions of cache nodes globally.&lt;/p&gt;
&lt;p&gt;To prevent cache stampedes—where thousands of application threads request the exact same missing key simultaneously—the caching layer employs clever primitives like Leases. If a key is missing, the cache hands out a lease token to only ONE worker process to rebuild the data, while telling all other requests to wait or serve stale data gracefully. This architecture guarantees that database layers remain shielded even during massive global viral events."&lt;/p&gt;
&lt;h3&gt;Chapter 5: The 4-Stage AI Ranking Engine&lt;/h3&gt;
&lt;p&gt;"Having a list of candidate posts from your friends and pages is only half the battle. Out of ten thousand potential items, which twenty posts should appear at the top of your feed right now? This is where Facebook’s &lt;b&gt;Multi-Stage AI Ranking Pipeline&lt;/b&gt; takes over.&lt;/p&gt;
&lt;p&gt;The machine learning pipeline processes content through four distinct stages:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Stage One is Candidate Generation.&lt;/b&gt; The system pulls roughly ten thousand eligible posts from your friends, groups, followed pages, ads engines, and recommended topics.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Stage Two is Lightweight Scoring.&lt;/b&gt; Running complex deep learning models on ten thousand items in real time would crush server compute. So, a lightweight scoring model quickly evaluates basic metadata—filtering out old posts or low-relevance content—narrowing the pool down to about five hundred high-probability candidates.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Stage Three is Deep Neural Network Ranking.&lt;/b&gt; This is the core machine learning phase. Deep neural networks evaluate thousands of contextual features per post in real time: How often do you interact with this author? Is it a high-definition video or a text update? Are you on Wi-Fi or a weak 4G connection? The AI calculates specific predictive probabilities: The probability you will click, the probability you will leave a comment, the probability you will share, or the probability you will watch the video to completion. These probabilities are combined into a final weighted score.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Stage Four is Diversity and Policy Filtering.&lt;/b&gt; Before the top-ranked posts hit your screen, the system enforces business rules. It ensures variety so you don't see ten posts in a row from the same person, injects sponsored advertisements at fixed intervals, and strips out policy-violating misinformation or clickbait."&lt;/p&gt;
&lt;h3&gt;Chapter 6: Real-Time Event Streaming &amp;amp; Invalidation&lt;/h3&gt;
&lt;p&gt;"A news feed is not a static webpage; it is a living, breathing stream. When you like a post or post a comment, that action must instantly influence what you and your friends see next.&lt;/p&gt;
&lt;p&gt;To handle millions of concurrent user interactions per second, Facebook uses an &lt;b&gt;Asynchronous Event-Driven Architecture&lt;/b&gt;. Every click, reaction, comment, or scroll event is captured by edge proxies and published into distributed log streams like &lt;b&gt;Apache Kafka&lt;/b&gt; or Facebook's internal streaming engines.&lt;/p&gt;
&lt;p&gt;Stream processing engines consume these events in real time to update feature stores, recalculate user engagement signals, and invalidate stale cache entries. If a post goes viral with thousands of angry reactions, real-time analytics pipelines notify the ranking model to adjust its distribution score dynamically—all without blocking the main user application thread."&lt;/p&gt;
&lt;h3&gt;Chapter 7: Client-Side Optimization &amp;amp; GraphQL&lt;/h3&gt;
&lt;p&gt;"All this backend power would be useless if the mobile client took seconds to parse and render the response. This is why Facebook pioneered &lt;b&gt;GraphQL&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;Instead of traditional REST APIs that return fixed, bloated JSON payloads containing unnecessary data fields, GraphQL empowers the mobile app to request exact data fields—no more, no less. On a slow mobile network, the client can ask for just post titles, author avatars, and image URLs, drastically reducing network payload size.&lt;/p&gt;
&lt;p&gt;Furthermore, the mobile app utilizes &lt;b&gt;Pre-fetching&lt;/b&gt; and &lt;b&gt;Cursor-based Pagination&lt;/b&gt;. As you scroll near the bottom of your screen, an Intersection Observer triggers a subtle background request to pre-fetch the next batch of five posts. By the time your thumb swipes up, the content is already cached locally in device memory, creating the illusion of an infinite, zero-latency scroll."&lt;/p&gt;
&lt;h3&gt;Chapter 8: Conclusion &amp;amp; Key System Design Takeaways&lt;/h3&gt;
&lt;p&gt;"Building a system that serves personalized content to three billion people under three hundred milliseconds requires mastering system design trade-offs.&lt;/p&gt;
&lt;p&gt;Let's recap the core engineering principles behind Facebook’s News Feed:
First, leverage specialized databases like &lt;b&gt;TAO&lt;/b&gt; to traverse graph relationships in memory.
Second, adopt a &lt;b&gt;Hybrid Fan-out strategy&lt;/b&gt; to balance write amplification against read performance.
Third, rely on &lt;b&gt;multi-tier in-memory caching&lt;/b&gt; with Memcached to keep disk I/O at near zero.
Fourth, utilize a &lt;b&gt;multi-stage AI ranking pipeline&lt;/b&gt; to narrow down candidates efficiently.
And finally, streamline client communication with &lt;b&gt;GraphQL&lt;/b&gt; and smart pre-fetching.&lt;/p&gt;
&lt;p&gt;That is the hidden engineering marvel powering the world's largest social feed every single second. Thank you for tuning in!"&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>distributedsystems</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>How Uber Handles 50,000 Requests per Second Without Crashing: A System Design Deep Dive</title>
      <dc:creator>Zidane</dc:creator>
      <pubDate>Thu, 06 Aug 2026 14:44:37 +0000</pubDate>
      <link>https://dev.to/zidane1688/how-uber-handles-50000-requests-per-second-without-crashing-a-system-design-deep-dive-fcn</link>
      <guid>https://dev.to/zidane1688/how-uber-handles-50000-requests-per-second-without-crashing-a-system-design-deep-dive-fcn</guid>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;&lt;span&gt;How Uber Handles 50,000 Requests per Second Without Crashing: A System Design Deep Dive&lt;/span&gt;&lt;/h1&gt;
&lt;p&gt;It is 5:00 PM on a rainy Friday in Manhattan. Subways are delayed, rain is pouring down, and within a single second, over 50,000 users pull out their phones and tap &lt;b&gt;"Request Ride"&lt;/b&gt;.&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;At that exact moment, 20,000 drivers are navigating crowded city streets, their mobile devices sending precise GPS updates back to the cloud every 4 seconds.&lt;/p&gt;
&lt;p&gt;To a backend engineer, this scenario sounds like a recipe for catastrophe:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Hundreds of thousands of persistent TCP connections.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Massive, continuous database write streams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complex spatial proximity queries executing in real time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your database locks for just two seconds, users cancel their requests. If latency spikes past 500 milliseconds, the entire platform risks a cascading outage. Yet, behind Uber’s clean mobile interface, an intricate system matches passengers with nearby drivers in &lt;b&gt;under 100 milliseconds&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;How does Uber route this immense, highly stateful traffic without dropping a single packet? The answer lies in an architecture that decouples traditional web pipelines and leverages hexagonal spatial indexing.&lt;/p&gt;
&lt;h2&gt;The Illusion of Traditional Load Balancing&lt;/h2&gt;
&lt;p&gt;When developers study load balancing, they typically picture a traditional, stateless architecture:&lt;/p&gt;$$\text{Client} \xrightarrow{\quad \text{HTTP Request} \quad} \text{NGINX Balancer} \xrightarrow{\quad \text{Round-Robin} \quad} \text{Server A / Server B}$$&lt;p&gt;This stateless model works exceptionally well for e-commerce platforms or content portals. If Server A fails, NGINX silently redirects your request to Server B. It doesn't matter which server fetches your shopping cart from the database because state lives securely in a centralized storage layer (like PostgreSQL or Redis).&lt;/p&gt;
&lt;h3&gt;Why Stateless Round-Robin Fails for Ride-Hailing&lt;/h3&gt;
&lt;p&gt;Ride-hailing is fundamentally &lt;b&gt;stateful, highly dynamic, and bound to physical geography&lt;/b&gt;:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Database Write Bottleneck:&lt;/b&gt; Storing driver locations in a relational database forces your cluster to execute tens of thousands of spatial write operations per second (&lt;code&gt;UPDATE drivers SET location = ...&lt;/code&gt;). The resulting disk lock contention will paralyze even high-end database clusters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The &lt;span&gt;$N+1$&lt;/span&gt; Network Hop Problem:&lt;/b&gt; Suppose Passenger A in Times Square requests a ride. If Passenger A's request hits Server 1, but nearby Driver B's location data is stored in memory on Server 2, Server 1 must query every other node in the data center to locate surrounding drivers. Inter-node network latency explodes exponentially.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Uber realized early on that off-the-shelf load balancers could not solve this problem. They needed a multi-tiered pipeline that separates network protocol handling from spatial in-memory state.&lt;/p&gt;
&lt;h2&gt;The Three-Tier Architecture Overview&lt;/h2&gt;
&lt;p&gt;To solve throughput and spatial coordination simultaneously, Uber engineered a distinct three-tier load balancing network:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────┐
│ TIER 1: Edge Defense &amp;amp; L4 Transport Routing                 │
│ (IPVS / Hardware Switches — High Packets/Sec, No TLS Parse) │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│ TIER 2: L7 Application Gateways                             │
│ (Envoy Proxy — Path Routing, JWT, Circuit Breaking)         │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│ TIER 3: Stateful Application Ring                           │
│ (Ringpop + H3 Spatial Indexing — In-Memory Sharding)        │
└─────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Tier 1: High-Speed Perimeter Routing at Layer 4&lt;/h2&gt;
&lt;p&gt;At the outer perimeter of Uber’s infrastructure sit &lt;b&gt;Layer 4 (L4) load balancers&lt;/b&gt;, implemented using Linux IP Virtual Server (IPVS) and high-performance hardware switches.&lt;/p&gt;
&lt;h3&gt;Why Layer 4 First?&lt;/h3&gt;
&lt;p&gt;Layer 4 operates strictly at the transport layer (TCP/UDP). An L4 balancer evaluates only:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Source IP and Port&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Destination IP and Port&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It does &lt;b&gt;not&lt;/b&gt; decrypt TLS certificates, parse HTTP headers, or examine JSON payloads. By skipping CPU-intensive SSL termination and layer-7 packet inspection, a single L4 edge node can process &lt;b&gt;millions of packets per second with near-zero CPU overhead&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;Tier 1 acts as a massive traffic filter and distributor, absorbing raw internet connections, terminating TCP streams, and evenly fanning packets out to the Tier 2 proxy layer.&lt;/p&gt;
&lt;h2&gt;Tier 2: Intelligent Microservice Gateway with Envoy Proxy&lt;/h2&gt;
&lt;p&gt;Once traffic passes the L4 edge layer, it hits &lt;b&gt;Tier 2 Layer 7 (L7) load balancers&lt;/b&gt; powered by Envoy Proxy.&lt;/p&gt;
&lt;p&gt;At Layer 7, the proxy decrypts the HTTP payload and inspects request context:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Path-Based Routing:&lt;/b&gt; A request to &lt;code&gt;/api/v1/payments&lt;/code&gt; routes directly to the isolated Payment Service cluster, whereas &lt;code&gt;/api/v1/dispatch&lt;/code&gt; routes to the Dispatch Engine.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Authentication &amp;amp; Validation:&lt;/b&gt; Envoy parses JSON Web Tokens (JWTs) at the proxy level, rejecting unauthorized requests before they ever reach internal application code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Resiliency Patterns: Circuit Breaking &amp;amp; Shedding&lt;/h3&gt;
&lt;p&gt;When handling 50,000 requests per second, microservice dependencies will periodically slow down. Envoy enforces strict resilience patterns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Circuit Breaking:&lt;/b&gt; If the Payment Service experiences a spike in latency, Envoy trips a circuit breaker immediately, returning a fallback response rather than letting queued requests exhaust thread pools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Rate Limiting &amp;amp; Retries:&lt;/b&gt; Envoy tracks retry budgets with exponential backoff, preventing failed requests from creating a self-inflicted Thundering Herd attack on downstream databases.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Tier 3: Solving Spatial Routing with Uber H3&lt;/h2&gt;
&lt;p&gt;Layer 7 proxies solve microservice routing, but they cannot answer the fundamental question: How do you map a moving driver and passenger in physical space to the exact same server instance?&lt;/p&gt;
&lt;p&gt;Continuous GPS coordinates are represented by floating-point numbers (e.g., &lt;code&gt;40.7580° N, 73.9855° W&lt;/code&gt;). You cannot performantly shard floating-point numbers across a fixed server cluster using traditional hash functions.&lt;/p&gt;
&lt;h3&gt;The Invention of Uber H3&lt;/h3&gt;
&lt;p&gt;To translate continuous geographic coordinates into discrete, hashable units, Uber developed &lt;b&gt;H3&lt;/b&gt;—an open-source, hexagonal hierarchical spatial index.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;       / \     / \
     /     \ /     \
    | (8828) | (8829)|  &amp;lt;-- Hexagonal H3 Cells
     \     / \     /    (Identical distances to all 6 neighbors)
       \ /     \ /
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;H3 overlays a mathematical grid of hexagons across the entire surface of the Earth:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Why Hexagons over Squares?&lt;/b&gt; Square grid systems have a critical flaw: the distance from a square's center to its edge differs from the distance to its corner. Hexagons feature &lt;b&gt;equidistant centroids&lt;/b&gt; to all six neighboring cells. This geometric symmetry drastically simplifies radius calculations when locating nearby drivers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Resolution Levels:&lt;/b&gt; H3 supports 16 resolution tiers. At Resolution 8, a city is divided into hexagonal cells roughly 700 meters wide.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Every raw GPS coordinate transforms instantly into a unique &lt;b&gt;64-bit integer H3 cell ID&lt;/b&gt;.&lt;/p&gt;
&lt;h2&gt;Tier 3 (Continued): Ringpop and In-Memory Stateful Sharding&lt;/h2&gt;
&lt;p&gt;Now that physical location is represented by a 64-bit integer, how does Uber map those cell IDs to servers without hitting a central database?&lt;/p&gt;
&lt;p&gt;Uber built &lt;b&gt;Ringpop&lt;/b&gt;, an open-source decentralized application-level routing library embedded directly into worker nodes.&lt;/p&gt;
&lt;h3&gt;Consistent Hashing on the Ring&lt;/h3&gt;
&lt;p&gt;Ringpop organizes worker nodes into a unified, distributed hash ring using &lt;b&gt;consistent hashing&lt;/b&gt;:&lt;/p&gt;$$\text{Cell ID (e.g., 8828308281FFFFF)} \xrightarrow{\quad \text{Ringpop Hash} \quad} \text{Assigned Server Node}$$&lt;pre&gt;&lt;code&gt;                   Node A (Owner: Cell 8828)
                       /               \
                      /                 \
            Node D                       Node B
                      \                 /
                       \               /
                   Node C (Owner: Cell 8829)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When a driver sends a GPS update or a passenger requests a ride in Manhattan (Cell &lt;code&gt;8828&lt;/code&gt;):&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;Ringpop hashes the H3 Cell ID.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The hash ring resolves to &lt;b&gt;Node A&lt;/b&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both the driver update and the rider request route to &lt;b&gt;Node A's local RAM&lt;/b&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Spatial matching takes place directly in memory at microsecond speeds. There are &lt;b&gt;zero disk writes&lt;/b&gt; and &lt;b&gt;zero cross-datacenter fanout queries&lt;/b&gt;.&lt;/p&gt;
&lt;h2&gt;Decentralized Health Management: The SWIM Gossip Protocol&lt;/h2&gt;
&lt;p&gt;In a cluster scaling thousands of nodes, hardware failures are inevitable. Disk drives corrupt, network interfaces drop packets, and virtual machines terminate unexpected.&lt;/p&gt;
&lt;p&gt;Traditional systems rely on a centralized coordinator like Apache ZooKeeper to manage cluster topology. However, at extreme scale, a central coordinator becomes a massive bottleneck and single point of failure.&lt;/p&gt;
&lt;p&gt;Ringpop avoids central coordinators entirely by implementing the &lt;b&gt;SWIM Gossip Protocol&lt;/b&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[Node A] ──(1. Ping)──&amp;gt; [Node B] (No Ack)
   │
   ├──(2. Indirect Ping via Node C &amp;amp; D)──&amp;gt; [Node B] (No Ack)
   │
   └──(3. Declare Dead) ──&amp;gt; [Gossip Update to Cluster]
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Direct Ping:&lt;/b&gt; Node A periodically sends a lightweight ping to a random peer, Node B.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Indirect Ping:&lt;/b&gt; If Node B fails to respond, Node A does not immediately mark it dead. It requests two neutral peers (Node C and Node D) to ping Node B indirectly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Decentralized Consensus:&lt;/b&gt; If Nodes C and D also fail to reach Node B, Node B is declared dead.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Gossip Propagation:&lt;/b&gt; This health state whispers across the entire cluster within seconds. The distributed hash ring automatically rebalances, assigning dead H3 cell IDs to surviving nodes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Key System Design Lessons for Software Engineers&lt;/h2&gt;
&lt;p&gt;Uber’s load balancing evolution provides invaluable architecture lessons for building resilient, distributed software:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Layer Separation:&lt;/b&gt; Never mix low-level packet handling with high-level application business logic. Use Layer 4 for raw TCP throughput at the edge, and Layer 7 for protocol inspection and microservice orchestration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Data Model Optimization:&lt;/b&gt; Transforming unstructured, continuous GPS data into discrete 64-bit H3 integers turned a complex, un-indexable spatial problem into a straightforward distributed hashing mechanism.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Embrace In-Memory State for Ephemeral Workloads:&lt;/b&gt; High-velocity write streams (like 4-second GPS updates) do not belong on persistent disks. Handle ephemeral real-time state in RAM using consistent hash rings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Design for Decentralized Resilience:&lt;/b&gt; Eliminate single points of failure. Utilizing gossip protocols like SWIM allows large-scale application clusters to self-heal without centralized orchestrators.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By combining L4/L7 network decoupling with hexagonal spatial sharded memory, Uber transformed an impossibly complex real-time coordination problem into an elegant, scalable engineering system.&lt;br&gt;&lt;br&gt;#webzonetechtips&lt;/p&gt;
&lt;p&gt;#webzonezidane&lt;/p&gt;

</description>
      <category>ai</category>
      <category>loadbalancing</category>
      <category>systemdesign</category>
      <category>uber</category>
    </item>
    <item>
      <title>How Discord Stores 11 Billion Messages (Without Melting)</title>
      <dc:creator>Zidane</dc:creator>
      <pubDate>Wed, 05 Aug 2026 10:58:34 +0000</pubDate>
      <link>https://dev.to/zidane1688/how-discord-stores-11-billion-messages-without-melting-52bb</link>
      <guid>https://dev.to/zidane1688/how-discord-stores-11-billion-messages-without-melting-52bb</guid>
      <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h1&gt;How Discord Stores 11 Billion Messages (Without Melting)&lt;/h1&gt;
&lt;br&gt;
&lt;p&gt;Every day, hundreds of millions of gamers, developers, and online communities send billions of chat messages on Discord. Whether it’s a simple "gg," a massive meme flood during an esports tournament, or a code snippet shared in a programming community, every single keystroke must be stored permanently, indexed instantly, and delivered across the world in milliseconds.&lt;/p&gt;
&lt;p&gt;Back in 2017, Discord’s engineering team faced a terrifying milestone: their primary database was hitting a hard wall. They were storing over &lt;b&gt;11 billion messages&lt;/b&gt;, and the underlying database—Apache Cassandra—was starting to choke.&lt;/p&gt;
&lt;p&gt;Read latencies were spiking, garbage collection freezes were causing random site-wide lags, and adding new server nodes felt like trying to put out a fire with gasoline.&lt;/p&gt;
&lt;p&gt;This is the story of how Discord’s engineering team pulled off one of the most audacious database migrations in modern tech history: moving billions of live messages to a brand-new storage engine with &lt;b&gt;zero downtime&lt;/b&gt; and &lt;b&gt;zero dropped chats&lt;/b&gt;.&lt;/p&gt;
&lt;h2&gt;The Architectural Summary&lt;/h2&gt;
&lt;p&gt;If you are looking for the quick system design takeaway, here is how Discord solved their massive database bottleneck:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Original Architecture (MongoDB to Cassandra):&lt;/b&gt; Discord started on MongoDB, quickly outgrew it, and migrated to Apache Cassandra for its wide-column, distributed key-value model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Cassandra Bottleneck:&lt;/b&gt; Java’s Garbage Collection (GC) pauses and unpredictable compaction cycles led to massive read-latency spikes (&lt;span&gt;$100\text{ms}$&lt;/span&gt; to several seconds).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Solution (ScyllaDB):&lt;/b&gt; Discord migrated from Java-based Cassandra to &lt;b&gt;ScyllaDB&lt;/b&gt;, a C++ rewrite of Cassandra that eliminates JVM garbage collection entirely and leverages thread-per-core hardware architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Custom Data Layer (Data Services):&lt;/b&gt; Discord built a intermediate service layer written in Rust to coalesce duplicate database requests, shielding the database from traffic surges.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;1. The Early Days: MongoDB to Apache Cassandra&lt;/h2&gt;
&lt;p&gt;When Discord launched in 2015, the entire application ran on a single &lt;b&gt;MongoDB&lt;/b&gt; replica set. MongoDB was fast to build on, but as the platform exploded in popularity, the message table outgrew the server's available RAM.&lt;/p&gt;
&lt;p&gt;To survive, Discord needed a database that was:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Linearly Scalable:&lt;/b&gt; Easy to expand simply by adding more hardware nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;High Write Throughput:&lt;/b&gt; Capable of handling thousands of concurrent message writes per second.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Fault-Tolerant:&lt;/b&gt; Free of single points of failure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In 2016, Discord migrated to &lt;b&gt;Apache Cassandra&lt;/b&gt;. Cassandra is a distributed, wide-column NoSQL database designed at Facebook to handle massive write volumes across multiple server nodes.&lt;/p&gt;
&lt;h3&gt;How Discord Partitioned Data in Cassandra&lt;/h3&gt;
&lt;p&gt;To store billions of messages efficiently, Discord needed a clever database schema. They created a primary partition key based on the &lt;code&gt;channel_id&lt;/code&gt;. Because messages in a channel are always retrieved together in chronological order, grouping messages by channel made fetching chat history incredibly fast.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;+-------------------------------------------------------------------------+
|                       DISCORD CASSANDRA SCHEMA                          |
+-------------------------------------------------------------------------+
| Partition Key : channel_id (e.g., Channel #general)                    |
| Clustering Key: message_id (Snowflake ID: timestamp + worker + seq)     |
+-------------------------------------------------------------------------+
| Row 1         | Message ID: 1001 | User: Alice | Text: "Hello!"        |
| Row 2         | Message ID: 1002 | User: Bob   | Text: "Hey there!"    |
| Row 3         | Message ID: 1003 | User: Charlie| Text: "Ready to game?"|
+-------------------------------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To generate unique, chronologically sortable message IDs across distributed servers, Discord utilized &lt;b&gt;Snowflake IDs&lt;/b&gt; (a 64-bit integer encoding a millisecond timestamp, worker process ID, and sequence number).&lt;/p&gt;
&lt;p&gt;For years, Cassandra handled the load brilliantly. But by 2022, as the total message count skyrocketed past &lt;b&gt;100 billion&lt;/b&gt;, the system began to unravel.&lt;/p&gt;
&lt;h2&gt;2. The Nightmare: Java GC Pauses &amp;amp; Hot Partitions&lt;/h2&gt;
&lt;p&gt;Why did Apache Cassandra start struggling? The short answer comes down to &lt;b&gt;Java&lt;/b&gt; and &lt;b&gt;Disk I/O&lt;/b&gt;.&lt;/p&gt;
&lt;h3&gt;Problem A: The Java Virtual Machine (JVM) Garbage Collector&lt;/h3&gt;
&lt;p&gt;Apache Cassandra is written in Java. Java relies on an automatic &lt;b&gt;Garbage Collector (GC)&lt;/b&gt; to clear unused memory. As Discord's dataset ballooned into hundreds of terabytes, Cassandra’s JVM heaps were constantly filling up with temporary query objects.&lt;/p&gt;
&lt;p&gt;When Java’s Garbage Collector ran its deep cleaning cycle (Stop-the-World GC pauses), entire database nodes would freeze for several seconds. To the rest of the cluster, a frozen node looked like a crashed node, causing unnecessary cluster-wide panic and traffic rerouting.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Normal Operation: [ Query ] ──► [ DB Node Response (5ms) ]

During JVM GC Pause: [ Query ] ──► [ DB Node Frozen... ] ──► [ Timeout Spike (2000ms+) ]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Problem B: Tombstones and Compaction&lt;/h3&gt;
&lt;p&gt;In Cassandra, when a user deletes a message, the database doesn't instantly delete it from the disk. Instead, it writes a marker called a &lt;b&gt;Tombstone&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;When a user opened a channel with many deleted messages, Cassandra had to read through thousands of tombstones just to find the surviving messages. This caused massive read-latency spikes, pushing response times from a crisp &lt;span&gt;$5\text{ms}$&lt;/span&gt; up to several agonizing seconds.&lt;/p&gt;
&lt;h2&gt;3. The New Engine: Enter ScyllaDB&lt;/h2&gt;
&lt;p&gt;Faced with unacceptable latency spikes, Discord’s engineering team realized that tuning the Java Virtual Machine was no longer enough. They needed to replace the database engine itself.&lt;/p&gt;
&lt;p&gt;They chose &lt;b&gt;ScyllaDB&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;ScyllaDB is a ground-up rewrite of Apache Cassandra written in &lt;b&gt;C++&lt;/b&gt;. It is &lt;span&gt;$100\%$&lt;/span&gt; protocol-compatible with Cassandra (meaning Discord could use the exact same client drivers and query language), but its underlying performance architecture is fundamentally different.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;+------------------------------------+------------------------------------+
|  APACHE CASSANDRA (JAVA)           |  SCYLLADB (C++ REWRITE)            |
+------------------------------------+------------------------------------+
| - Managed Memory (JVM GC Pauses)   | - Manual C++ Memory Management     |
| - Thread Pool Model                | - Thread-Per-Core Architecture     |
| - High CPU Overhead                | - Direct Asynchronous I/O (io_uring)|
| - Susceptible to Latency Spikes    | - Ultra-consistent Low Latency     |
+------------------------------------+------------------------------------+
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;The Power of Thread-per-Core&lt;/h3&gt;
&lt;p&gt;In traditional Java applications, operating system threads are constantly context-switching between different CPU cores, causing lock contention and performance bottlenecks.&lt;/p&gt;
&lt;p&gt;ScyllaDB uses a &lt;b&gt;Thread-per-Core&lt;/b&gt; architecture. It pins a single execution thread to each individual CPU core. Memory and network queues are partitioned so that each core operates independently without waiting for locks from other cores.&lt;/p&gt;
&lt;p&gt;By eliminating the JVM Garbage Collector and embracing bare-metal C++ efficiency, ScyllaDB delivered predictable, sub-millisecond latencies even under brutal traffic loads.&lt;/p&gt;
&lt;h2&gt;4. The Shield: Building "Data Services" in Rust&lt;/h2&gt;
&lt;p&gt;Replacing the database engine was only half the battle. Discord’s engineers knew that even the fastest database on Earth can be knocked offline if thousands of clients query the exact same data at the same instant (a phenomenon known as the &lt;b&gt;Thundering Herd Problem&lt;/b&gt;).&lt;/p&gt;
&lt;p&gt;To protect ScyllaDB, Discord built an intermediate caching and request coalescing layer written in &lt;b&gt;Rust&lt;/b&gt;, called &lt;b&gt;Data Services&lt;/b&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ User Requests (10,000 Concurrent Users) ]
                    │
                    ▼
       [ RUST DATA SERVICES LAYER ]
   (Coalesces 10,000 identical queries)
                    │
                    ▼  (Only 1 query sent to DB!)
         [ SCYLLADB CLUSTER ]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;How Request Coalescing Works:&lt;/h3&gt;
&lt;p&gt;Imagine a popular streamer posts a message in a Discord channel with 100,000 active viewers. All 100,000 client apps will instantly send a read request for the exact same message ID at the exact same millisecond.&lt;/p&gt;
&lt;p&gt;Instead of sending 100,000 separate queries to ScyllaDB:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;The incoming requests hit the &lt;b&gt;Rust Data Services layer&lt;/b&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The service detects that 10,000 users are asking for the exact same &lt;code&gt;message_id&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It sends &lt;b&gt;only ONE single query&lt;/b&gt; to ScyllaDB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When ScyllaDB responds, the Data Services layer duplicates the response in memory and returns it to all 10,000 waiting users simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This caching mechanism reduced database read traffic by orders of magnitude, smoothing out traffic spikes during viral events.&lt;/p&gt;
&lt;h2&gt;5. Live Migration: Moving Billions of Rows Zero Downtime&lt;/h2&gt;
&lt;p&gt;Migrating hundreds of billions of records while millions of users are actively chatting is like replacing the engine of a commercial jet mid-flight. Discord could not afford a maintenance window.&lt;/p&gt;
&lt;p&gt;To pull off a seamless zero-downtime migration, they executed a &lt;b&gt;Dual-Writing Engineering Strategy&lt;/b&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ Incoming User Writes/Edits ]
             │
             ├───────────────┬───────────────┐
             ▼                               ▼
    [ CASSANDRA (Old DB) ]          [ SCYLLADB (New DB) ]
             │                               ▲
             │                               │
             └───► [ BACKGROUND MIGRATOR ] ──┘
                    (Copies Historical Data)
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Dual Writing:&lt;/b&gt; Discord updated their application code to write all &lt;b&gt;new&lt;/b&gt; messages, edits, and deletions to both Cassandra and ScyllaDB simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Historical Backfill:&lt;/b&gt; They built background worker tasks to read historical messages from Cassandra and copy them over to ScyllaDB in reverse chronological order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Consistency Verification:&lt;/b&gt; Automated validation scripts compared records between both databases to ensure &lt;span&gt;$100\%$&lt;/span&gt; data integrity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Cutover:&lt;/b&gt; Once the backfill was complete and data parity was confirmed, Discord flipped the read switch. All user traffic was instantly pointed to ScyllaDB, and the old Cassandra cluster was safely decommissioned.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Summary &amp;amp; Key Takeaways&lt;/h2&gt;
&lt;p&gt;Discord’s migration from Cassandra to ScyllaDB is a masterclass in modern infrastructure scaling:&lt;/p&gt;

&lt;h1&gt;How Discord Stores 11 Billion Messages (Without Melting)&lt;/h1&gt;
&lt;p&gt;Every day, hundreds of millions of gamers, developers, and online communities send billions of chat messages on Discord. Whether it’s a simple "gg," a massive meme flood during an esports tournament, or a code snippet shared in a programming community, every single keystroke must be stored permanently, indexed instantly, and delivered across the world in milliseconds.&lt;/p&gt;
&lt;p&gt;Back in 2017, Discord’s engineering team faced a terrifying milestone: their primary database was hitting a hard wall. They were storing over &lt;b&gt;11 billion messages&lt;/b&gt;, and the underlying database—Apache Cassandra—was starting to choke.&lt;/p&gt;
&lt;p&gt;Read latencies were spiking, garbage collection freezes were causing random site-wide lags, and adding new server nodes felt like trying to put out a fire with gasoline.&lt;/p&gt;
&lt;p&gt;This is the story of how Discord’s engineering team pulled off one of the most audacious database migrations in modern tech history: moving billions of live messages to a brand-new storage engine with &lt;b&gt;zero downtime&lt;/b&gt; and &lt;b&gt;zero dropped chats&lt;/b&gt;.&lt;/p&gt;
&lt;h2&gt;The TL;DR Architectural Summary&lt;/h2&gt;
&lt;p&gt;If you are looking for the quick system design takeaway, here is how Discord solved their massive database bottleneck:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Original Architecture (MongoDB to Cassandra):&lt;/b&gt; Discord started on MongoDB, quickly outgrew it, and migrated to Apache Cassandra for its wide-column, distributed key-value model.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Cassandra Bottleneck:&lt;/b&gt; Java’s Garbage Collection (GC) pauses and unpredictable compaction cycles led to massive read-latency spikes (&lt;span&gt;$100\text{ms}$&lt;/span&gt; to several seconds).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Solution (ScyllaDB):&lt;/b&gt; Discord migrated from Java-based Cassandra to &lt;b&gt;ScyllaDB&lt;/b&gt;, a C++ rewrite of Cassandra that eliminates JVM garbage collection entirely and leverages thread-per-core hardware architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Custom Data Layer (Data Services):&lt;/b&gt; Discord built a intermediate service layer written in Rust to coalesce duplicate database requests, shielding the database from traffic surges.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;1. The Early Days: MongoDB to Apache Cassandra&lt;/h2&gt;
&lt;p&gt;When Discord launched in 2015, the entire application ran on a single &lt;b&gt;MongoDB&lt;/b&gt; replica set. MongoDB was fast to build on, but as the platform exploded in popularity, the message table outgrew the server's available RAM.&lt;/p&gt;
&lt;p&gt;To survive, Discord needed a database that was:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Linearly Scalable:&lt;/b&gt; Easy to expand simply by adding more hardware nodes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;High Write Throughput:&lt;/b&gt; Capable of handling thousands of concurrent message writes per second.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Fault-Tolerant:&lt;/b&gt; Free of single points of failure.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In 2016, Discord migrated to &lt;b&gt;Apache Cassandra&lt;/b&gt;. Cassandra is a distributed, wide-column NoSQL database designed at Facebook to handle massive write volumes across multiple server nodes.&lt;/p&gt;
&lt;h3&gt;How Discord Partitioned Data in Cassandra&lt;/h3&gt;
&lt;p&gt;To store billions of messages efficiently, Discord needed a clever database schema. They created a primary partition key based on the &lt;code&gt;channel_id&lt;/code&gt;. Because messages in a channel are always retrieved together in chronological order, grouping messages by channel made fetching chat history incredibly fast.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;+-------------------------------------------------------------------------+
|                       DISCORD CASSANDRA SCHEMA                          |
+-------------------------------------------------------------------------+
| Partition Key : channel_id (e.g., Channel #general)                    |
| Clustering Key: message_id (Snowflake ID: timestamp + worker + seq)     |
+-------------------------------------------------------------------------+
| Row 1         | Message ID: 1001 | User: Alice | Text: "Hello!"        |
| Row 2         | Message ID: 1002 | User: Bob   | Text: "Hey there!"    |
| Row 3         | Message ID: 1003 | User: Charlie| Text: "Ready to game?"|
+-------------------------------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To generate unique, chronologically sortable message IDs across distributed servers, Discord utilized &lt;b&gt;Snowflake IDs&lt;/b&gt; (a 64-bit integer encoding a millisecond timestamp, worker process ID, and sequence number).&lt;/p&gt;
&lt;p&gt;For years, Cassandra handled the load brilliantly. But by 2022, as the total message count skyrocketed past &lt;b&gt;100 billion&lt;/b&gt;, the system began to unravel.&lt;/p&gt;
&lt;h2&gt;2. The Nightmare: Java GC Pauses &amp;amp; Hot Partitions&lt;/h2&gt;
&lt;p&gt;Why did Apache Cassandra start struggling? The short answer comes down to &lt;b&gt;Java&lt;/b&gt; and &lt;b&gt;Disk I/O&lt;/b&gt;.&lt;/p&gt;
&lt;h3&gt;Problem A: The Java Virtual Machine (JVM) Garbage Collector&lt;/h3&gt;
&lt;p&gt;Apache Cassandra is written in Java. Java relies on an automatic &lt;b&gt;Garbage Collector (GC)&lt;/b&gt; to clear unused memory. As Discord's dataset ballooned into hundreds of terabytes, Cassandra’s JVM heaps were constantly filling up with temporary query objects.&lt;/p&gt;
&lt;p&gt;When Java’s Garbage Collector ran its deep cleaning cycle (Stop-the-World GC pauses), entire database nodes would freeze for several seconds. To the rest of the cluster, a frozen node looked like a crashed node, causing unnecessary cluster-wide panic and traffic rerouting.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Normal Operation: [ Query ] ──► [ DB Node Response (5ms) ]

During JVM GC Pause: [ Query ] ──► [ DB Node Frozen... ] ──► [ Timeout Spike (2000ms+) ]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Problem B: Tombstones and Compaction&lt;/h3&gt;
&lt;p&gt;In Cassandra, when a user deletes a message, the database doesn't instantly delete it from the disk. Instead, it writes a marker called a &lt;b&gt;Tombstone&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;When a user opened a channel with many deleted messages, Cassandra had to read through thousands of tombstones just to find the surviving messages. This caused massive read-latency spikes, pushing response times from a crisp &lt;span&gt;$5\text{ms}$&lt;/span&gt; up to several agonizing seconds.&lt;/p&gt;
&lt;h2&gt;3. The New Engine: Enter ScyllaDB&lt;/h2&gt;
&lt;p&gt;Faced with unacceptable latency spikes, Discord’s engineering team realized that tuning the Java Virtual Machine was no longer enough. They needed to replace the database engine itself.&lt;/p&gt;
&lt;p&gt;They chose &lt;b&gt;ScyllaDB&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;ScyllaDB is a ground-up rewrite of Apache Cassandra written in &lt;b&gt;C++&lt;/b&gt;. It is &lt;span&gt;$100\%$&lt;/span&gt; protocol-compatible with Cassandra (meaning Discord could use the exact same client drivers and query language), but its underlying performance architecture is fundamentally different.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;+------------------------------------+------------------------------------+
|  APACHE CASSANDRA (JAVA)           |  SCYLLADB (C++ REWRITE)            |
+------------------------------------+------------------------------------+
| - Managed Memory (JVM GC Pauses)   | - Manual C++ Memory Management     |
| - Thread Pool Model                | - Thread-Per-Core Architecture     |
| - High CPU Overhead                | - Direct Asynchronous I/O (io_uring)|
| - Susceptible to Latency Spikes    | - Ultra-consistent Low Latency     |
+------------------------------------+------------------------------------+
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;The Power of Thread-per-Core&lt;/h3&gt;
&lt;p&gt;In traditional Java applications, operating system threads are constantly context-switching between different CPU cores, causing lock contention and performance bottlenecks.&lt;/p&gt;
&lt;p&gt;ScyllaDB uses a &lt;b&gt;Thread-per-Core&lt;/b&gt; architecture. It pins a single execution thread to each individual CPU core. Memory and network queues are partitioned so that each core operates independently without waiting for locks from other cores.&lt;/p&gt;
&lt;p&gt;By eliminating the JVM Garbage Collector and embracing bare-metal C++ efficiency, ScyllaDB delivered predictable, sub-millisecond latencies even under brutal traffic loads.&lt;/p&gt;
&lt;h2&gt;4. The Shield: Building "Data Services" in Rust&lt;/h2&gt;
&lt;p&gt;Replacing the database engine was only half the battle. Discord’s engineers knew that even the fastest database on Earth can be knocked offline if thousands of clients query the exact same data at the same instant (a phenomenon known as the &lt;b&gt;Thundering Herd Problem&lt;/b&gt;).&lt;/p&gt;
&lt;p&gt;To protect ScyllaDB, Discord built an intermediate caching and request coalescing layer written in &lt;b&gt;Rust&lt;/b&gt;, called &lt;b&gt;Data Services&lt;/b&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ User Requests (10,000 Concurrent Users) ]
                    │
                    ▼
       [ RUST DATA SERVICES LAYER ]
   (Coalesces 10,000 identical queries)
                    │
                    ▼  (Only 1 query sent to DB!)
         [ SCYLLADB CLUSTER ]
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;How Request Coalescing Works:&lt;/h3&gt;
&lt;p&gt;Imagine a popular streamer posts a message in a Discord channel with 100,000 active viewers. All 100,000 client apps will instantly send a read request for the exact same message ID at the exact same millisecond.&lt;/p&gt;
&lt;p&gt;Instead of sending 100,000 separate queries to ScyllaDB:&lt;/p&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;The incoming requests hit the &lt;b&gt;Rust Data Services layer&lt;/b&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The service detects that 10,000 users are asking for the exact same &lt;code&gt;message_id&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It sends &lt;b&gt;only ONE single query&lt;/b&gt; to ScyllaDB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When ScyllaDB responds, the Data Services layer duplicates the response in memory and returns it to all 10,000 waiting users simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This caching mechanism reduced database read traffic by orders of magnitude, smoothing out traffic spikes during viral events.&lt;/p&gt;
&lt;h2&gt;5. Live Migration: Moving Billions of Rows Zero Downtime&lt;/h2&gt;
&lt;p&gt;Migrating hundreds of billions of records while millions of users are actively chatting is like replacing the engine of a commercial jet mid-flight. Discord could not afford a maintenance window.&lt;/p&gt;
&lt;p&gt;To pull off a seamless zero-downtime migration, they executed a &lt;b&gt;Dual-Writing Engineering Strategy&lt;/b&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ Incoming User Writes/Edits ]
             │
             ├───────────────┬───────────────┐
             ▼                               ▼
    [ CASSANDRA (Old DB) ]          [ SCYLLADB (New DB) ]
             │                               ▲
             │                               │
             └───► [ BACKGROUND MIGRATOR ] ──┘
                    (Copies Historical Data)
&lt;/code&gt;&lt;/pre&gt;
&lt;ol start="1"&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Dual Writing:&lt;/b&gt; Discord updated their application code to write all &lt;b&gt;new&lt;/b&gt; messages, edits, and deletions to both Cassandra and ScyllaDB simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Historical Backfill:&lt;/b&gt; They built background worker tasks to read historical messages from Cassandra and copy them over to ScyllaDB in reverse chronological order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Consistency Verification:&lt;/b&gt; Automated validation scripts compared records between both databases to ensure &lt;span&gt;$100\%$&lt;/span&gt; data integrity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;The Cutover:&lt;/b&gt; Once the backfill was complete and data parity was confirmed, Discord flipped the read switch. All user traffic was instantly pointed to ScyllaDB, and the old Cassandra cluster was safely decommissioned.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Summary &amp;amp; Key Takeaways&lt;/h2&gt;

&lt;p&gt;Discord’s migration from Cassandra to ScyllaDB is a masterclass in modern infrastructure scaling:&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Architecture Era&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Database Used&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Primary Bottleneck&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Performance Result&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;2015 (Launch)&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;MongoDB&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Outgrew RAM limits on single replica set.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Unstable under rapid user growth.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;2016 - 2022&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Apache Cassandra&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;JVM Garbage Collection freezes &amp;amp; Tombstones.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Spikes up to &lt;span&gt;$2000\text{ms}+$&lt;/span&gt; read latency.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;2023 - Present&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;ScyllaDB + Rust Data Services&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Managed via C++ bare-metal efficiency &amp;amp; request coalescing.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;Sub-millisecond latencies (&lt;span&gt;$&amp;lt;5\text{ms}$&lt;/span&gt;)&lt;/b&gt; at &lt;span&gt;$100\text{B}+$&lt;/span&gt; messages.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;By replacing Java GC pauses with C++ hardware efficiency and shielding their database with a smart Rust middleware layer, Discord transformed a lagging infrastructure into a lightning-fast messaging platform capable of scaling effortlessly for years to come.&lt;/p&gt;




</description>
      <category>backend</category>
      <category>database</category>
      <category>scalability</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>The Hidden Traffic Cop Keeping the Internet From Melting</title>
      <dc:creator>Zidane</dc:creator>
      <pubDate>Sun, 02 Aug 2026 09:51:35 +0000</pubDate>
      <link>https://dev.to/zidane1688/the-hidden-traffic-cop-keeping-the-internet-from-melting-3cg1</link>
      <guid>https://dev.to/zidane1688/the-hidden-traffic-cop-keeping-the-internet-from-melting-3cg1</guid>
      <description>&lt;h2&gt;🚦 What is Load Balancing?&lt;/h2&gt;
&lt;p&gt;Think of a &lt;b&gt;Load Balancer&lt;/b&gt; as a digital traffic cop sitting in front of your servers. When thousands of users visit your website at the same time, the load balancer distributes incoming web traffic across multiple backend servers so that no single server gets overwhelmed, crashes, or slows down.&lt;/p&gt;
&lt;h3&gt;Core Benefits of Load Balancing&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Zero Downtime (High Availability):&lt;/b&gt; If Server A crashes, the load balancer automatically redirects traffic to Server B without the user noticing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Scalability:&lt;/b&gt; You can easily add 5 more servers during peak sales hours and remove them when traffic drops.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Faster Response Times:&lt;/b&gt; Traffic is routed to the healthiest, least busy, or geographically closest server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;🔄 The 5 Core Routing Algorithms Compared&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Algorithm&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;How it Works (Analogy)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Best Used For&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;1. Round Robin&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Takes turns in order: Server 1 &lt;span&gt;$\rightarrow$&lt;/span&gt; Server 2 &lt;span&gt;$\rightarrow$&lt;/span&gt; Server 3 &lt;span&gt;$\rightarrow$&lt;/span&gt; Server 1.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Servers with &lt;b&gt;identical hardware&lt;/b&gt; handling &lt;b&gt;short, equal requests&lt;/b&gt;.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;2. Least Connections&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Sends traffic to the server with the &lt;b&gt;fewest active connections&lt;/b&gt;.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;Long-lived connections&lt;/b&gt; (e.g., chat apps, streaming, gaming).&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;3. IP Hash&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Uses the user's IP address to map them to the &lt;b&gt;exact same server&lt;/b&gt; every time.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Applications requiring &lt;b&gt;persistent user sessions&lt;/b&gt; (e.g., shopping carts).&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;4. Least Response Time&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Sends traffic to the server with the &lt;b&gt;fastest response time&lt;/b&gt; and fewest connections.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Systems where server performance fluctuates or is latency-sensitive.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;span&gt;&lt;b&gt;5. Weighted (Bonus)&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Assigns a higher capacity ratio (e.g., 3:1) to stronger servers.&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span&gt;Mixed infrastructure where some servers have more RAM/CPU than others.&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;🛠️ Deep Dive: When, Where &amp;amp; Why to Use Each&lt;/h2&gt;
&lt;h3&gt;1. Round Robin&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;How it works:&lt;/b&gt; Imagine a dealer passing out cards around a table one by one in a circle. It cycles through servers sequentially regardless of how busy they are.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Benefits:&lt;/b&gt; Extremely simple to configure, virtually zero CPU overhead on the load balancer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;When to use:&lt;/b&gt; When all backend servers have &lt;b&gt;identical CPU/RAM specs&lt;/b&gt; and the incoming requests take roughly the same amount of time to process (e.g., serving static HTML/CSS files).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;When NOT to use:&lt;/b&gt; If some requests take 10 seconds (like rendering a PDF) and others take 10 milliseconds.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2. Least Connections&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;How it works:&lt;/b&gt; The load balancer keeps track of how many active open connections each server currently holds, and sends the next user to whoever has the shortest line.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Benefits:&lt;/b&gt; Prevents server overload when request processing times vary wildly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;When to use:&lt;/b&gt; Applications with &lt;b&gt;long-lived connections&lt;/b&gt; or variable task lengths—such as live chat apps (WebSockets), file uploads, video streaming, or heavy database query rendering.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;3. IP Hash&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;How it works:&lt;/b&gt; The load balancer takes the user’s IP address (e.g., &lt;code&gt;192.168.1.50&lt;/code&gt;), runs it through a hash function, and converts it into a number that permanently points to Server A.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Benefits:&lt;/b&gt; Guarantees "session stickiness" (the user always lands on the same server) without relying on browser cookies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;When to use:&lt;/b&gt; Legacy applications where &lt;b&gt;user session state is stored in server memory&lt;/b&gt; (like an active shopping cart or login session) instead of a shared database like Redis.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4. Least Response Time (or Least Latency)&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;How it works:&lt;/b&gt; The load balancer constantly monitors the health and TTFB (Time To First Byte) latency of each server. It combines the fewest active connections with the fastest ping time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;Benefits:&lt;/b&gt; Maximizes end-user speed and automatically routes around servers that are lagging or undergoing background tasks (like memory garbage collection).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;b&gt;When to use:&lt;/b&gt; Ultra low-latency systems like high-frequency trading platforms, real-time gaming backends, or globally distributed microservices where network delays vary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;🎯 Summary Quick-Decision Guide&lt;/h2&gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&amp;lt;!----&amp;gt;&lt;pre&gt;&lt;code&gt;                          Do your servers have equal specs?&lt;br&gt;
                                   │&lt;br&gt;
                 ┌─────────────────┴─────────────────┐&lt;br&gt;
                 YES                                 NO&lt;br&gt;
                 │                                   │&lt;br&gt;
      Are requests equal in length?            Use WEIGHTED &lt;br&gt;
         ┌───────┴───────┐                    ROUND ROBIN&lt;br&gt;
        YES              NO&lt;br&gt;
         │               │&lt;br&gt;
  ROUND ROBIN     LEAST CONNECTIONS&lt;br&gt;
                         │&lt;br&gt;
        Need persistent session per user?&lt;br&gt;
                 ┌───────┴───────┐&lt;br&gt;
                YES              NO&lt;br&gt;
                 │               │&lt;br&gt;
              IP HASH    LEAST RESPONSE TIME&lt;/code&gt;&lt;/pre&gt;


&lt;h1&gt;
  
  
  webzonetechtips
&lt;/h1&gt;

&lt;h1&gt;
  
  
  loadbalancing
&lt;/h1&gt;

</description>
      <category>loadbalancing</category>
      <category>roundrobin</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
