<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hazel Mahajan on Medium]]></title>
        <description><![CDATA[Stories by Hazel Mahajan on Medium]]></description>
        <link>https://medium.com/@hazelmahajan852?source=rss-4c6ee95c5e9b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tV2EITKdEmC_8nGKYK1oKw.jpeg</url>
            <title>Stories by Hazel Mahajan on Medium</title>
            <link>https://medium.com/@hazelmahajan852?source=rss-4c6ee95c5e9b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 06:04:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hazelmahajan852/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[⚙️ Scaling Backend Systems: Beyond Adding More Servers]]></title>
            <link>https://medium.com/@hazelmahajan852/%EF%B8%8F-scaling-backend-systems-beyond-adding-more-servers-79fcfbd8bec9?source=rss-4c6ee95c5e9b------2</link>
            <guid isPermaLink="false">https://medium.com/p/79fcfbd8bec9</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Hazel Mahajan]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 11:38:08 GMT</pubDate>
            <atom:updated>2025-06-28T22:44:06.648Z</atom:updated>
            <content:encoded><![CDATA[<p>As your user base grows from a few hundred to millions, your backend architecture can go from simple to chaotic — fast. Contrary to popular belief, scaling isn’t just about upgrading hardware or adding new instances. It’s about making strategic decisions around how data flows, how components interact, and what trade-offs you’re willing to make in the face of distributed complexity.</p><p>In this post, we’ll break down three key pillars of building scalable backend systems:</p><p>Vertical vs Horizontal Scaling</p><p>I/O Bottlenecks in Real Systems</p><p>The CAP Theorem and Trade-offs in Distribution</p><p>Let’s dive into how modern engineering teams navigate the shift from “just working” to truly scalable.</p><h3>🧱 Vertical vs Horizontal Scaling: Growth Isn’t One-Directional</h3><p><strong>Vertical scaling </strong>also called <em>scaling up </em>means upgrading the resources on a single machine. Think more memory, faster CPUs, or better SSDs. It’s quick to implement and ideal for early-stage products or monolithic systems.</p><p>But vertical scaling doesn’t scale forever.</p><h3>Limitations:</h3><p><strong>Hardware caps</strong>: There’s only so much you can upgrade.</p><p><strong>Expensive</strong>: Top-tier machines cost significantly more.</p><p><strong>Single point of failure</strong>: One server crash can halt everything.</p><p><strong>Horizontal scaling </strong>or <em>scaling out </em>spreads the workload across multiple servers or containers. This is the foundation of cloud-native and distributed architecture.</p><h3>Benefits:</h3><p><strong>Redundancy</strong>: One node fails, others carry on.</p><p><strong>Elasticity</strong>: Scale with demand.</p><p><strong>Parallelism</strong>: Handle more traffic simultaneously.</p><p>👀 But Be Aware:</p><p>Requires stateless service design.</p><p>Needs orchestration tools (like Docker, Kubernetes).</p><p>Demands automated deployments and observability.</p><blockquote><strong><em>Example</em></strong><em>: Migrating from a monolithic Rails app on one EC2 instance to a containerized service with replicas managed by Kubernetes behind a load balancer.</em></blockquote><h3>I/O Bottlenecks: The Silent System Killers</h3><p>When performance dips, it’s rarely just the CPU. Most backend slowdowns happen at the <strong>I/O level : </strong>the point where your code talks to storage, memory, or the network.</p><p>Let’s break it down:</p><h3>💾 1. Disk I/O (Storage-Level Latency)</h3><p>Reading from and writing to storage is fundamental : whether you’re saving logs, writing to a database, or serving large files.</p><p>Common Pitfalls:</p><p>Unindexed database queries</p><p>Synchronous writes in high-throughput apps</p><p>Uploads without streaming or chunking</p><h4>Smart Practices:</h4><p>Use SSDs over HDDs for faster access.</p><p>Index columns used in filters and joins.</p><p>Batch write operations where possible.</p><blockquote><strong><em>Real-world impact</em></strong><em>: A misconfigured ORM query without indexing leads to table scans and drives up latency for all users sharing that disk.</em></blockquote><h3>🧠 2. Memory I/O (RAM ↔ CPU Transfers)</h3><p>Memory access is lightning fast — often used for caching and temporary state. But it comes with caveats.</p><h4>Risks:</h4><p>Caching large/unbounded datasets</p><p>Memory leaks or unmonitored spikes</p><p>No persistence on failure</p><h4>Best Practices:</h4><p>Set TTLs on caches like Redis or Memcached.</p><p>Avoid storing user sessions or large blobs in RAM.</p><p>Monitor memory pressure and eviction rates.</p><blockquote><strong><em>Pro tip</em></strong><em>: Caching user profiles can reduce database reads by 80%, but without proper expiration, you risk serving outdated data.</em></blockquote><blockquote><strong>3. Network I/O (Inter-Service Communication)</strong></blockquote><p>As systems split into services, the network becomes the new bottleneck.</p><h4>Expensive Network Patterns:</h4><p>Making frequent, small API calls (chatty services)</p><p>Synchronous service chaining</p><p>Cross-region traffic without optimizations</p><h4>Smarter Communication:</h4><p>Use HTTP/2 or gRPC to reduce overhead.</p><p>Implement connection pooling and keep-alives.</p><p>Batch requests or use message queues for async flows.</p><blockquote><strong><em>Scenario</em></strong><em>: A dashboard that fires 10 separate API calls on page load — each creating a new TLS handshake — can triple response time unless optimized.</em></blockquote><h3>The CAP Theorem: You Can’t Have It All</h3><p>When designing distributed systems, you eventually face a decision: which guarantees matter most?</p><p>The <strong>CAP theorem</strong> states that in the presence of a network partition (which <em>will</em> happen), you can only guarantee <strong>two</strong> of the following:</p><p><strong>Consistency</strong>: Reads always return the most recent write.</p><p><strong>Availability</strong>: Every request gets a response, even during failures.</p><p><strong>Partition Tolerance</strong>: The system continues functioning when parts can’t communicate.</p><h3>You can’t pick all three….So how do you decide?</h3><h4>🔐 CP Systems (Consistency + Partition Tolerance)</h4><p>Prioritize correctness.<br> → Think: banking apps, inventory systems, ledgers.</p><h4>🌐 AP Systems (Availability + Partition Tolerance)</h4><p>Prefer uptime, even if data is briefly inconsistent.<br> → Think: social feeds, product reviews, content delivery.</p><h3>Design Implications:</h3><p>Be cautious about promising strong consistency across multiple regions.</p><p>Know your consistency model: eventual, strong, or causal.</p><p>Don’t treat CAP as a theoretical limit — it’s a practical design compass.</p><blockquote><strong><em>Example</em></strong><em>: A global microservice split between US and EU regions may serve stale data during a partition unless consistency is prioritized — at the cost of some requests failing or being delayed.</em></blockquote><h3>TL;DR: Smart Scaling Isn’t Just About Size</h3><p>True scalability isn’t about throwing more servers at the problem — it’s about knowing your bottlenecks, designing for failure, and making trade-offs intentionally.</p><h3>Key Takeaways:</h3><p><strong>Scale vertically first</strong> if you’re small, but architect with horizontal growth in mind.</p><p><strong>Watch for I/O limits : </strong>disk, memory, and network are frequent bottlenecks.</p><p><strong>Understand CAP: </strong>choose trade-offs based on your domain, not desire.</p><blockquote><em>Behind every scalable system is a set of tough engineering choices — and the wisdom to make them early.</em></blockquote><p>📬 <strong>Enjoyed this post?</strong><br> This is part of a weekly series on backend engineering, system design, and cloud-native patterns.</p><p>Follow me on <a href="https://medium.com/@hazelmahajan852">Medium</a> or connect on <a href="https://www.linkedin.com/in/hazel-mahajan/">LinkedIn</a> for more real-world deep dives into the backend.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79fcfbd8bec9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>