<?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 Vignesh Anweri on Medium]]></title>
        <description><![CDATA[Stories by Vignesh Anweri on Medium]]></description>
        <link>https://medium.com/@vigneshanweri?source=rss-171d48f3af33------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WdoMKzUMNpN2K-qjKg2qtg.jpeg</url>
            <title>Stories by Vignesh Anweri on Medium</title>
            <link>https://medium.com/@vigneshanweri?source=rss-171d48f3af33------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:39:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vigneshanweri/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[Understanding Consistency Guarantees in Distributed Systems: Part-1]]></title>
            <link>https://medium.com/@vigneshanweri/linearizability-serializability-in-distributed-systems-understanding-consistency-aef6a548c568?source=rss-171d48f3af33------2</link>
            <guid isPermaLink="false">https://medium.com/p/aef6a548c568</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Vignesh Anweri]]></dc:creator>
            <pubDate>Sat, 29 Jul 2023 07:16:55 GMT</pubDate>
            <atom:updated>2023-07-29T07:23:51.748Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of distributed systems, ensuring data consistency across replicas is paramount for maintaining reliability and correctness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gfLVsvEvtfoKiLCv" /><figcaption>Photo by <a href="https://unsplash.com/@cookiethepom?utm_source=medium&amp;utm_medium=referral">Cookie the Pom</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Two fundamental consistency models, linearizability and serializability, play critical roles in achieving this goal.</p><p>In this article, we will delve into the technical aspects of these two models, exploring their characteristics, challenges, and practical implementations.</p><h3>Linearizability: Atomic Consistency</h3><p>Linearizability, also known as atomic consistency or strong consistency, is a powerful and widely used consistency model in distributed systems. It guarantees that all operations on a single object (which stores a single value) appear to occur instantaneously at a single point in time, providing a real-time ordering of operations. In simpler terms, linearizability ensures that clients see the effect of a write operation either immediately or not at all. This property is crucial for maintaining a consistent and predictable experience for users and applications.</p><h4>Key Characteristics of Linearizability:</h4><ol><li><strong>Real-Time Ordering</strong>: In a linearizable system, all operations are treated as if they occurred in a continuous and sequential order, irrespective of their actual concurrent execution. This means that even though multiple clients may submit read and write requests concurrently, the system guarantees that all clients observe the effects of these operations in the same order.</li><li><strong>Single Point of Truth</strong>: Linearizability ensures that there is a single, consistent state across all replicas. After a write operation is acknowledged, the new value immediately takes effect across the entire system. This property ensures that clients always read the most up-to-date value, maintaining a coherent view of the data.</li><li><strong>Total Order of Operations</strong>: In a linearizable system, all operations are inherently totally ordered. This means that every operation receives a unique timestamp that determines its position in the global execution order. This global ordering is critical for resolving any conflicts that may arise due to concurrent operations.</li></ol><h4>Challenges in Implementing Linearizability</h4><p>Achieving linearizability in distributed systems can be challenging, especially in highly concurrent and geographically distributed environments. Synchronizing the global order of operations across multiple replicas while maintaining low-latency access for clients requires careful design and coordination.</p><ol><li><strong>Coordination Overhead</strong>: To enforce real-time ordering, linearizable systems may introduce coordination overhead, leading to potential performance bottlenecks.</li><li><strong>Scalability</strong>: As the system scales, maintaining linearizability becomes more complex, and careful consideration is needed to strike a balance between consistency and scalability.</li><li><strong>Availability vs. Linearizability</strong>: Ensuring linearizability often requires all replicas to agree on the order of operations, which can impact system availability if some replicas are unreachable.</li><li><strong>Network Latency</strong>: The presence of network delays and asynchrony can challenge the real-time guarantees of linearizability, especially in geographically distributed systems.</li></ol><p>Despite these challenges, linearizability remains a critical consistency model for applications that require real-time ordering and immediate visibility of write operations.</p><h4>My personal experience with linearizability</h4><p>My team developed a dynamic variable replacer service that efficiently replaces placeholders in a template as part of a wider use case. The values for the variables/placeholders came from a single mongoDB document. So if the template had a variable “name”, we accessed the “name” attribute’s value of the mongo document.</p><p>The flexibility of our service allows other teams to leverage it for their custom use cases.</p><p>Recently, another team integrated our service into their workflow to replace template variables. What they did was that they updated the mongo document with the key value they wanted to replace in the template and immediately called our service.</p><p>However, they encountered an unexpected issue where some replacements resulted in empty strings. After thorough investigation, we discovered that the problem was caused by our service fetching data from a secondary MongoDB replica(we used a DAO), which sometimes provided stale documents lacking the most recent updates and this broke the linearizability assumptions.</p><p>A simple approach where the caller passes the updated document in the function call fixed the issue and made our system linearizable and consistent with our assumptions.</p><p>In <strong>Part-2</strong> of this article, we will delve into another important consistency model — <strong>serializability</strong>. We will also discuss a practical implementation of both <strong>linearizability</strong> and <strong>serializability</strong> by taking <strong>Google’s</strong> <strong>Spanner</strong> as an example.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aef6a548c568" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are distributed ACID transactions uncool?]]></title>
            <link>https://medium.com/@vigneshanweri/are-distributed-acid-transactions-uncool-8ba708a7c5bb?source=rss-171d48f3af33------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ba708a7c5bb</guid>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <dc:creator><![CDATA[Vignesh Anweri]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 15:36:21 GMT</pubDate>
            <atom:updated>2023-06-13T15:36:21.848Z</atom:updated>
            <content:encoded><![CDATA[<h4>A high level overview of distributed ACID transactions.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*tHX3BrMjMMx5L2PS1Nj2VQ.png" /><figcaption>source: Zanopia</figcaption></figure><p>Many of us are familiar with the conventional explanations of ACID transactions and the acronym’s meaning. Traditional ACID properties can impose limitations on system scalability and responsiveness because most of these were created to cater to a single instance of a database, back in the 1980s.</p><p>While the traditional definition of ACID transactions is fundamental, it doesn’t fully capture the intricacies of distributed systems. In distributed environments, data is distributed across partitions/shards on multiple nodes. This makes it difficult to adhere to all the constraints of ACID due to factors like network partitions, latency, and geographic distribution of data.</p><p>Understanding of such challenges will help us make better decisions regarding datastores while building scalable applications for our use cases.</p><p>Let’s get a better picture of A, C, I &amp; D within the context of distributed transactions :-</p><h4>1) Atomicity</h4><p>Atomicity means that a transaction is treated as a complete and unbreakable unit of work.</p><p>In a distributed setting, ensuring atomicity across multiple nodes becomes more intricate due to potential failures and network partitions. Distributed atomicity involves coordinating multiple sub-transactions across different nodes to ensure that either all the changes made by the transaction are committed, or none of them are. Techniques like two-phase commit protocols that use distributed consensus algorithms are commonly employed to achieve distributed atomicity.</p><h4>2) Consistency</h4><p>In the realm of ACID transactions, consistency plays a vital role by ensuring that a transaction effectively transitions the system from a valid state to another, while upholding all the constraints imposed by the database, such as integrity constraints.</p><p>In a distributed environment, maintaining consistency across multiple participating nodes becomes challenging. Network partitions and concurrent updates to different nodes can lead to conflicts and inconsistencies. To address this, various consistency models have been introduced, such as strong consistency, eventual consistency, and causal consistency. These models provide different trade-offs between availability, performance, and data integrity, allowing developers to choose the most suitable consistency level based on their application requirements.</p><h4>3) Isolation</h4><p>Isolation guarantees that concurrent transactions appear to be executed in isolation, without interfering with each other.</p><p>In distributed systems, achieving isolation becomes complex due to the need for coordination across multiple nodes. Different isolation levels, such as read committed, repeatable read, and serializable, define the degree of isolation and trade-offs between concurrency and consistency. Distributed databases employ mechanisms like multi-version concurrency control (MVCC) and distributed locking to provide isolation guarantees while allowing concurrent execution of transactions.</p><p><strong><em>Side note</em></strong><em>: I often wondered if isolation and consistency properties performed similar kinds of data integrity checks. While isolation mechanisms contribute to maintaining data integrity by preventing conflicts for concurrent transactions, they do not directly handle the validation of data integrity(business logic/domain). The responsibility for ensuring data integrity primarily lies with consistency checks, which are performed separately and independently of the isolation mechanisms. Consistency is something more closer to the database(business logic/domain) rather than the database system itself. The database system only enforces the constraints imposed by the database.</em></p><h4>4) Durability</h4><p>Durability ensures that once a transaction is committed, its effects remain intact despite any potential failures.</p><p>In distributed systems, ensuring durability across multiple nodes and potential failures requires reliable replication and synchronization mechanisms. Replicating data across multiple nodes or data centers, employing write-ahead logs, and using distributed storage systems contribute to achieving durability in distributed transactions.</p><p>While the traditional ACID properties still hold their significance, the landscape of data management has evolved with the advent of distributed systems. New approaches, such as BASE (Basically Available, Soft state, Eventually consistent), have emerged to address the limitations of ACID in highly scalable and distributed environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*oGFw8yLZwV75tHtqzJOLPA.png" /><figcaption>source: Praxilabs</figcaption></figure><p>BASE properties provide looser consistency guarantees and prioritize availability and responsiveness over strict consistency. This approach acknowledges that achieving strong consistency in distributed systems can come at the cost of reduced performance and availability. By relaxing the consistency requirements, BASE allows for higher scalability, fault tolerance, and improved system performance.</p><p>BASE is not a specific data management model or protocol but rather a set of principles guiding the design and trade-offs of distributed systems. The specific implementation and mechanisms for achieving availability, soft state, and eventual consistency can vary depending on the chosen architecture and technology stack.</p><p>It’s important to carefully consider the trade-offs and application requirements before adopting BASE principles, as there might be use cases where strong consistency and ACID properties are necessary, such as financial systems or critical data integrity scenarios.</p><p>Understanding the nuances of ACID and BASE properties is crucial when designing distributed systems. It enables architects and developers to make informed decisions about the choice of datastores and transaction models based on the specific requirements of their applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ba708a7c5bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System design 777: Debunking Load Balancers]]></title>
            <link>https://medium.com/@vigneshanweri/system-design-777-debunking-load-balancers-10fc4fbbb7ad?source=rss-171d48f3af33------2</link>
            <guid isPermaLink="false">https://medium.com/p/10fc4fbbb7ad</guid>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[big-tech]]></category>
            <dc:creator><![CDATA[Vignesh Anweri]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 15:37:25 GMT</pubDate>
            <atom:updated>2023-06-01T15:37:25.810Z</atom:updated>
            <content:encoded><![CDATA[<h4>Addressing misconceptions and myths surrounding load balancers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LogiA-jGeoQiwu0yX2z9yQ.png" /><figcaption>Source: analyticsvidhya</figcaption></figure><p>Load balancers are a critical component in designing scalable systems. They help in scaling systems by distributing incoming requests across multiple servers or backend instances to ensure efficient resource utilization and prevent any single server from being overwhelmed.</p><p>I often see load balancers as a more loosely thrown around term while trying to design systems for scale.</p><p>Load balancers are no magical, mystical components. Keep in mind that load balancers are systems in themselves, they have their own limitations.</p><p>I’m no expert in load balancers. We mostly use already available tools in the market, by tweaking the configurations to fit our use cases.</p><p>Let’s explore some prevalent misconceptions and myths surrounding load balancers without diving too deeply into technical intricacies. This approach will help us develop a clearer comprehension of load balancers.</p><h4>Myth 1: Load balancers are very robust and rarely fail.</h4><p>No component in a system is 100% robust and reliable. Components will fail due to reasons beyond imagination. To avoid this Single Point of Failure, the most straightforward solution is to add a redundant load balancer on standby which can take over(fail-over) in case a “primary” load balancer fails. This is good to handle smaller traffic, but won’t scale when traffic increases exponentially.</p><p>Rather than relying on a single load balancer at a time, a cluster of load balancers can be created. This approach involves distributing the workload across multiple load balancers, each capable of handling a portion of the traffic, using virtual IP addresses, session information sharing etc. Usually large production systems have layered deployments for load balancers where each layer performs a specific task and operate on a specific layer(eg. TCP/UDP or application layer). I will discuss this approach in more detail, in a separate article.</p><h4>Myth 2: Only large scale systems need load balancers.</h4><p>A common misconception is that load balancers are only useful for large-scale systems and not necessary for smaller applications. However, this is far from the truth. Load balancers bring benefits to systems of all sizes, including modest applications. Even small-scale applications can encounter unexpected surges in traffic or encounter resource limitations. Load balancers play a crucial role in distributing the workload, enabling the application to handle increased traffic without compromising performance or risking downtime. Furthermore, load balancers provide a solid foundation for future growth and scalability as the application expands its user base.</p><h4>Myth 3: Load balancers can also perform reverse proxy functions, so they are one and the same.</h4><p>As the names suggest, load balancer and reverse proxy are distinct components with specific functionalities. Load balancer’s primary purpose is to distribute traffic across servers, whereas reverse proxies intermediate between clients and backend servers.</p><p>Load balancers and reverse proxies are often clubbed together because they serve complementary roles(eg. Nginx).</p><p>Load balancers use reverse proxy functionalities such as SSL termination, caching, request routing, security and filtering etc. in managing and optimizing web traffic.</p><p>They are closely related and can be combined to enhance the overall performance, security, and scalability of a system.</p><h4>Myth 4: Load Balancers are Unnecessary Overhead.</h4><p>Sure, load balancers are overhead. But they are necessary overheads. The pros largely outweigh the cons. If you want to build systems that are scalable, reliable and resilient, you need to include load balancers in your design. Without them, it’s almost like building a sports car without wheels.</p><p><strong>Disclaimer:</strong> We have focussed on traditional load balancers instead of discussing client-side load balancing, as they play a vital role in the design of most three-tier applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10fc4fbbb7ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>