<?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 Dharin S on Medium]]></title>
        <description><![CDATA[Stories by Dharin S on Medium]]></description>
        <link>https://medium.com/@dharinshah1234?source=rss-86e6334711ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TFruBgUsGzPrjF2KN5hlwg.jpeg</url>
            <title>Stories by Dharin S on Medium</title>
            <link>https://medium.com/@dharinshah1234?source=rss-86e6334711ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:38:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharinshah1234/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[Elasticsearch Under the Hood: Navigating High Write Loads]]></title>
            <link>https://medium.com/@dharinshah1234/elasticsearch-under-the-hood-navigating-high-write-loads-2a2dc37c636a?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a2dc37c636a</guid>
            <category><![CDATA[opensearch]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Tue, 10 Oct 2023 20:50:53 GMT</pubDate>
            <atom:updated>2023-10-11T07:57:30.377Z</atom:updated>
            <content:encoded><![CDATA[<p>Elasticsearch, a distributed search and analytics engine, is revered for its real-time capabilities and scalability. However, high write activity can pose challenges, especially when it impacts read performance. In this blog, we’ll delve into Elasticsearch’s architecture, the intricacies of its indexing process, and the implications of high write loads.</p><h3>Elasticsearch Architecture and Indexing</h3><p>Elasticsearch stores data in structures called indices, which are further divided into shards. Each shard is a self-contained index, and they allow Elasticsearch to distribute data and parallelize operations across nodes.</p><p>Indexing Process:</p><ol><li>Document Ingestion: Data is ingested as documents. Each document is a collection of fields, representing your data.</li><li>Analysis: During indexing, the content of each field in a document is processed by an analyzer to convert text into tokens or terms, which are then added to the index.</li><li>Segment Creation: As documents are indexed, they’re first stored in an in-memory buffer. Once this buffer reaches a certain size, its contents are written to a new segment on disk. These segments are immutable.</li><li>Segment Merging: Over time, to optimize performance and storage, smaller segments are merged into larger ones, and the old ones are deleted.</li></ol><h3>System-Level Implications of High Write Activity</h3><p>Consider a news platform during a major global event. As real-time updates (articles, videos, comments) are indexed, millions of users are simultaneously searching for the latest news.</p><ul><li>Storage I/O: The influx of new content saturates the I/O. As users search for updates, their queries are delayed due to I/O contention.</li><li>Memory: The system’s memory fills with indexing buffers. Frequent garbage collection events, triggered by high memory utilization, further slow down user queries.</li><li>CPU: The CPU is swamped processing new content data, affecting its ability to handle search requests efficiently.</li><li>Cluster Architecture: Some shards, especially those containing the latest news, receive a disproportionate amount of traffic, creating hotspots.</li></ul><h3>Deep Dive: Off-Heap Memory and Indexing Buffers</h3><p>One of Elasticsearch’s strengths is its ability to handle large volumes of data efficiently. A significant part of this efficiency comes from its use of off-heap memory for indexing buffers.</p><p>When documents are ingested, they’re first stored in the indexing buffer, an off-heap memory structure. This allows Elasticsearch to handle high write loads without putting too much pressure on the JVM heap. Once the buffer reaches a certain threshold, its contents are flushed to disk as a new segment.</p><p>However, during periods of intense write activity, these buffers can fill up rapidly. If the system’s I/O can’t keep up, it can lead to increased memory usage and potential performance issues.</p><h3>Solutions and Analysis</h3><ol><li>Optimise Storage:</li></ol><ul><li>Provision More IOPS: On cloud platforms, provision more IOPS for your storage.</li><li>Use SSDs: They offer better IOPS and lower latencies.</li></ul><ol><li>Memory Management: Monitor both on-heap and off-heap memory usage. Consider increasing off-heap memory if indexing buffers are consistently full.</li><li>Scale Out: Distribute the load by adding more nodes or increasing replica shards.</li><li>Tune Indexing: Adjust settings like the refresh interval and bulk indexing strategies.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gn9J0XcDq33O4a2_mupVGw.jpeg" /></figure><ol><li>Metrics to Monitor:</li></ol><ul><li>Disk Queue Length: Indicates I/O operations waiting for disk access.</li><li>JVM Heap and Off-Heap Usage: Monitor to ensure they’re not consistently high.</li><li>CPU Utilization: Track for heavy processing indications.</li><li>Search and Indexing Latencies: Ensure they remain within acceptable bounds.</li></ul><h3>Conclusion</h3><p>Elasticsearch is a engineering marvel in the world of distributed systems, but it requires a deep understanding to harness its full potential. By grasping its architecture, indexing process, and the implications of high write loads, you can optimize your setup for peak performance.</p><p>PS — this is a very high level overview of how to understand performance implications due to IOPS, let me know if you would want to deep dive, so i can dive into the code</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a2dc37c636a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing Technical Debt: A Comprehensive Guide]]></title>
            <link>https://medium.com/@dharinshah1234/managing-technical-debt-a-comprehensive-guide-624706ccd946?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/624706ccd946</guid>
            <category><![CDATA[system-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technical-debt]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 20:44:39 GMT</pubDate>
            <atom:updated>2023-10-05T20:44:51.642Z</atom:updated>
            <content:encoded><![CDATA[<p>Technical debt, akin to financial debt, can accumulate over time and become a significant burden if not managed effectively. In software development, technical debt refers to the implied cost of additional rework caused by choosing a quicker yet less optimal solution now instead of a better approach that would take longer. This article offers a structured approach to understanding, categorizing, and addressing technical debt, emphasizing the collaboration between product managers and engineering teams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*STi9ejl1rSYnuUqA-ZyhXA.png" /></figure><h3>1. Understanding Technical Debt</h3><p>Technical debt can arise from various sources, including rushed development, changing requirements, or lack of knowledge. While some amount of technical debt is inevitable, it’s essential to recognize and address it to maintain a healthy codebase and product.</p><h3>2. Categorizing Technical Debt</h3><p>Breaking down technical debt into categories helps teams understand its sources and devise targeted strategies:</p><ul><li><strong>Design Debt:</strong> Arises when system design principles are compromised, making the system harder to maintain and extend.</li><li><strong>Usability Debt:</strong> Results from user interface and experience compromises, leading to a less intuitive or user-friendly product.</li><li><strong>Code Debt:</strong> Stems from suboptimal coding practices, such as not adhering to coding standards, resulting in hard-to-read and maintain code.</li><li><strong>Infrastructure Debt:</strong> Arises from outdated servers, tools, or platforms, leading to potential security and performance issues.</li></ul><h3>3. The Role of Testing in Managing Technical Debt</h3><p>A robust testing framework is a cornerstone of managing technical debt:</p><ul><li><strong>Immediate Feedback:</strong> Comprehensive tests, especially behavioral and integration tests, provide feedback on system health, catching bugs or broken functionalities.</li><li><strong>Safety Net for Refactoring:</strong> Tests allow developers to refactor confidently, ensuring that regressions are identified promptly.</li></ul><h3>4. Setting a Technical Debt Ceiling</h3><p>It’s unrealistic to aim for zero technical debt. Instead:</p><ul><li><strong>Define an Acceptable Level:</strong> Use metrics like known issues, time required to address the debt, or scores from code quality tools.</li><li><strong>Regular Audits:</strong> Conduct reviews to identify and quantify debt, ensuring it remains below the defined ceiling.</li></ul><h3>5. Strategies to Keep Technical Debt in Check</h3><ol><li><strong>Prioritise:</strong> Address high-impact debts first.</li><li><strong>Allocate Resources:</strong> Dedicate specific development time to manage technical debt.</li><li><strong>Documentation:</strong> Maintain a record of all known technical debts.</li><li><strong>Educate and Train:</strong> Equip the team with best practices to minimize debt accumulation.</li><li><strong>Feedback Loop:</strong> Foster a culture of open communication about potential debt issues.</li></ol><h3>6. The Role of Collaboration in Managing Technical Debt</h3><p>Effective management of technical debt requires collaboration between product managers and engineering teams:</p><ul><li><strong>Product Managers:</strong> They should understand the implications of technical debt on the product’s roadmap, user experience, and overall quality. By prioritising features and improvements, product managers can allocate time for the engineering team to address technical debt.</li><li><strong>Engineering Teams:</strong> Engineers should communicate the technical challenges and the potential accumulation of debt. By working closely with product managers, they can ensure that there’s a balance between feature development and debt management.</li></ul><h3>7. Conclusion</h3><p>Technical debt, if left unchecked, can become a significant challenge. However, with a structured approach and collaboration between product and engineering teams, it can be effectively managed. By understanding its sources, setting clear guidelines, and fostering open communication, organizations can ensure that technical debt remains a manageable aspect of software development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=624706ccd946" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Evolution of Coding: From SOLID Foundations to Agile Heights]]></title>
            <link>https://medium.com/@dharinshah1234/the-evolution-of-coding-from-solid-foundations-to-agile-heights-7d151ffd8cb3?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d151ffd8cb3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Tue, 19 Sep 2023 18:31:07 GMT</pubDate>
            <atom:updated>2023-09-19T18:38:22.364Z</atom:updated>
            <content:encoded><![CDATA[<p>In the ever-shifting sands of software development, change is the only constant. And just like in any good superhero story, with great power (read: rapid deployment tools) comes… you guessed it, great responsibility (and the occasional spaghetti code).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/0*9w3r0DiUIO6r9KtC.jpeg" /></figure><h3>A Trip Down Memory Lane: The SOLID Days</h3><blockquote><em>“Remember the days when software was as immovable as a stubborn cat on your keyboard?”</em></blockquote><p>Those were the days of SOLID and DRY principles. The days when every class had a single responsibility, and God forbid if two classes shared even a hint of functionality.</p><pre>interface DataProcessor {<br>    void process();<br>}<br><br>class DataCollector implements DataProcessor {<br>    public void process() {<br>        // Collecting data like a squirrel with acorns<br>    }<br>}</pre><p>This was the era of meticulous planning. Every piece of code was crafted with the precision of a watchmaker. Why? Because deploying updates was like trying to turn the Titanic — slow and fraught with danger.</p><h3>The Need for Speed (No, Not the Game)</h3><p>Fast forward to today, and it’s all about speed. With CI/CD tools, we’re deploying faster than you can say “Did I just break production?” And in this race, sometimes SOLID feels more like a heavy anchor than a guiding star.</p><pre>class RecommendationSystem {<br>    public void collectData() {<br>        // Gotta catch &#39;em all... data points!<br>    }<br>    public void analyzeData() {<br>        // Stirring the data cauldron<br>    }<br>    public void generateRecommendations() {<br>        // Magic 8-ball says...<br>    }<br>}</pre><blockquote><em>“This approach is like the Swiss Army knife of coding. Straightforward, multipurpose, and gets the job done.”</em></blockquote><h3>Is SOLID Going the Way of the Dinosaur?</h3><p>Now, I’m not saying SOLID is extinct. But in an agile world, where adaptability is the name of the game, being too rigid can feel like you’re coding with one hand tied behind your back.</p><h3>The Real Cost: Engineering Systems vs. Code</h3><p>While refactoring code is relatively cheap and straightforward, reengineering entire systems is not. It’s like comparing rearranging the furniture in your room to moving to a new house. The former can be done in an afternoon, while the latter… well, you get the idea.</p><p>In today’s fast-paced environment, it’s crucial to focus more on engineering robust, scalable systems. Code can be tweaked, improved, or even rewritten. But foundational systems? Those are the bedrock of your software, and changing them can be a Herculean task.</p><blockquote><em>“Invest in your systems, because while code is malleable, foundational systems are not.”</em></blockquote><h3>The Safety Net: Integration Testing</h3><p>Regardless of your coding style, there’s one thing we can all agree on: the sheer panic of breaking something in production. But fear not! Integration tests are here to save the day. They’re like the superhero sidekick that catches you when you fall (perhaps not when you accidentally delete the database :) ).</p><h3>Murphy’s Law of Refactoring</h3><p>In the realm of coding, Murphy’s Law translates to: “What can be refactored, will be refactored.” Recognizing this, we can prioritize delivering value now and making improvements later.</p><blockquote><em>“Refactoring is just like cleaning your room. You might not want to do it, but you’ll feel so much better once it’s done.”</em></blockquote><h3>Embracing the Future</h3><p>As we continue to navigate the ever-evolving landscape of software development, every tool, principle, and pattern has its place. Whether you’re a SOLID aficionado or a rapid deployment ninja, the key is to adapt, iterate, and always keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d151ffd8cb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitOps as evolution of Kubernetes]]></title>
            <link>https://medium.com/@dharinshah1234/gitops-as-evolution-of-kubernetes-d661b0ab7f2c?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/d661b0ab7f2c</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Sun, 25 Jun 2023 16:13:59 GMT</pubDate>
            <atom:updated>2023-06-25T16:19:25.656Z</atom:updated>
            <content:encoded><![CDATA[<p>In the rapidly evolving world of software development and deployment, the need for efficient infrastructure management and faster application delivery is paramount. GitOps, a modern software delivery methodology, brings a transformative approach to Kubernetes deployments by leveraging Git as the single source of truth for infrastructure and application configuration. In this article, we will explore how GitOps has revolutionized the way we approach Kubernetes deployments, leading to improved delivery speed, enhanced efficiency, and reduced operational costs.</p><h3>The Traditional Approach: Challenges and Limitations</h3><p>Before the advent of GitOps, managing Kubernetes deployments was often a manual and error-prone process. Configuration files and manifests were stored in various locations, making it challenging to track changes and ensure consistency across environments. Let’s take a closer look at some of the key challenges associated with the traditional approach:</p><ol><li>Manual Updates and Synchronization:</li></ol><p>In the traditional approach, making updates to Kubernetes configurations involved manual interventions. These updates had to be manually synchronized across different environments, leading to inconsistencies and configuration drift.</p><p>2. Lack of Version Control:</p><p>Without a centralized version control system, tracking changes and rolling back to a known working state was cumbersome. This made troubleshooting and debugging more challenging, leading to longer resolution times.</p><p>3. Limited Collaboration:</p><p>Collaboration between development and operations teams was often hindered due to fragmented and siloed processes. Lack of transparency and shared visibility resulted in delays and miscommunication during deployments.</p><p>4. Tedious and Error-Prone Deployments:</p><p>Manual deployments were time-consuming and prone to errors. The risk of misconfigurations or missed steps increased, affecting the overall stability and reliability of the applications.</p><h3>GitOps: Transforming Kubernetes Deployments</h3><p>GitOps addresses the limitations of the traditional approach by introducing a new paradigm in Kubernetes deployments. Let’s explore how GitOps revolutionises the process and brings several significant benefits:</p><ol><li>Enhanced Configuration Management:</li></ol><p>GitOps introduces the concept of Infrastructure as Code (IaC) by treating infrastructure configurations as code stored in a Git repository. This provides version control, making it easy to track changes, roll back to previous versions, and ensure consistency across different environments.</p><p>Example:</p><pre># Deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: my-app<br>  labels:<br>    app: my-app<br>spec:<br>  replicas: 3<br>  template:<br>    metadata:<br>      labels:<br>        app: my-app<br>    spec:<br>      containers:<br>        - name: my-app-container<br>          image: my-app:latest<br>          ports:<br>            - containerPort: 8080</pre><p>With GitOps:</p><pre># deployment.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: my-app<br>  labels:<br>    app: my-app<br>spec:<br>  replicas: 3<br>  template:<br>    metadata:<br>      labels:<br>        app: my-app<br>    spec:<br>      containers:<br>        - name: my-app-container<br>          image: my-app:1.0.1<br>          ports:<br>            - containerPort: 8080</pre><p>In the GitOps approach, the desired state of the infrastructure is stored in the Git repository. Changes made to the code, such as updating the image version, are committed and tracked in Git.</p><p>2. Consistent Environments:</p><p>With GitOps, maintaining consistency across environments becomes effortless. The desired state stored in the Git repository is automatically applied to the target Kubernetes clusters, ensuring that all environments are synchronized and consistent.</p><p>Example: Before GitOps:</p><p>Manually applying changes to multiple Kubernetes clusters, ensuring consistent configurations, and tracking changes across environments was a challenging task.</p><p>With GitOps:</p><p>The desired state defined in the Git repository is automatically synchronized across clusters. Deployments become consistent and reproducible.</p><p>3. Accelerated Delivery Speed:</p><p>GitOps enables organizations to achieve faster application delivery by automating the deployment process. Continuous Integration/Continuous Delivery (CI/CD) pipelines integrated with the GitOps workflow automate testing, building, and deploying applications, reducing manual intervention and enabling rapid iterations.</p><p>Example: Before GitOps:</p><p>The deployment process involved manual steps, including building container images, updating configurations, and manually triggering deployments.</p><p>With GitOps:</p><p>CI/CD pipelines integrated with GitOps automate the entire deployment process. Developers can push changes to the Git repository, triggering automated builds and deployments, resulting in faster iterations and reduced time-to-market.</p><p>4. Cost Reduction and Operational Efficiency:</p><p>GitOps brings operational efficiency by automating deployments, reducing manual errors, and minimizing the time spent on repetitive tasks. By ensuring consistent configurations and reducing configuration drift, GitOps improves the overall stability and reliability of applications, resulting in cost savings and reduced operational overhead.</p><p>Example: Before GitOps:</p><p>Manual deployments often resulted in misconfigurations or inconsistent environments, leading to increased operational costs due to the time and effort required to troubleshoot and rectify issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*m8xhKt3Nj_tFw8SeY3BEKQ.png" /></figure><p>With GitOps:</p><p>Automated deployments and consistent configurations minimize the risk of errors and reduce operational costs associated with troubleshooting and managing infrastructure.</p><h3>Conclusion:</h3><p>GitOps has emerged as a transformative methodology, revolutionizing Kubernetes deployments by leveraging Git as the single source of truth and embracing Infrastructure as Code. By automating deployments, ensuring consistency, and fostering collaboration, GitOps enables organizations to achieve faster delivery speed, enhanced operational efficiency, and reduced costs. With its focus on automation, version control, and reproducibility, GitOps paves the way for a new era of infrastructure management, empowering teams to meet the demands of modern software development and deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d661b0ab7f2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of Tests: How Writing Tests Actually Makes You Faster]]></title>
            <link>https://medium.com/@dharinshah1234/the-power-of-tests-how-writing-tests-actually-makes-you-faster-6249221b3dd9?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/6249221b3dd9</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[speed]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Sun, 25 Jun 2023 15:52:18 GMT</pubDate>
            <atom:updated>2023-06-25T16:19:09.073Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of software development, time is of the essence. Delivering high-quality code quickly is a constant challenge for developers. Surprisingly, one of the most effective ways to speed up your development process is by writing tests. Testing may seem like an additional burden, but in reality, it can significantly enhance your productivity. In this article, we will explore the reasons why writing tests can make you faster and more efficient in your software development journey. Additionally, we will delve into the drawbacks of extreme testing approaches, such as TDD (Test-Driven Development), and discuss how to strike a balance between speed and thoroughness.</p><p><strong>1. Refactor with Confidence:</strong><br>Writing good tests provides a safety net when refactoring code. As your project evolves, you’ll likely encounter the need to improve and optimize your code. Without tests, refactoring becomes a daunting task, as you can’t be sure if your changes will introduce new bugs. However, with a comprehensive test suite in place, you can confidently make changes, knowing that the tests will detect any regressions. This freedom allows you to iterate faster and focus on improving your code’s design and performance.</p><p><strong>2. Identify Bugs Early:</strong><br>One of the most significant advantages of having a solid testing strategy is the ability to catch bugs early in the development cycle. Writing tests forces you to think about the different scenarios your code should handle. By covering various edge cases and input combinations, you increase the likelihood of catching potential issues before they reach production. This proactive approach saves you valuable time that would otherwise be spent tracking down and fixing bugs later on.</p><p><strong>3. Streamline Code Reviews:</strong><br>Code reviews are an essential part of the software development process. However, reviewing code can be time-consuming, especially if the code lacks clarity or has poor naming conventions. By writing good tests, you can alleviate some of the reviewer’s burden. Tests serve as a form of documentation, making it easier for reviewers to understand the code’s intent and behavior. With tests in place, reviewers can focus on higher-level design decisions and logic, leading to faster and more effective code reviews.</p><p><strong>4. Maintain Focus on What’s Important:</strong><br>When you write tests, you naturally shift your focus towards the core functionality and requirements of your code. Tests force you to think about the expected outcomes and desired behavior, helping you prioritize your development efforts. By focusing on what’s important, you can avoid unnecessary complexity and feature creep, resulting in cleaner and more maintainable code. This streamlined approach ultimately saves time and makes you more productive in the long run.</p><p><strong>5. Leveraging AI Tools for Efficient Testing:</strong><br>In recent years, the development landscape has witnessed the emergence of powerful AI tools, such as ChatGPT, that can assist developers in writing tests. AI tools can generate test cases based on code analysis and patterns, accelerating the test writing process. While these AI-generated tests still require validation, they allow developers to quickly cover potential code paths and scenarios without panicking about introducing bugs into the production environment. Leveraging AI tools for testing empowers developers to be more productive and efficient in their test-driven development workflows.</p><p><strong>The Drawbacks of Extreme Testing Approaches:</strong></p><p><strong>1. Time Investment:</strong><br>One of the potential downsides of Test-Driven Development (TDD) is the time investment required upfront. Writing tests before implementing the actual code can slow down the initial development process. While TDD promotes better design and test coverage, it may not always be the best approach when speed of delivery is crucial.</p><p><strong>2. Over-Engineering:</strong><br>In extreme testing approaches, such as TDD, there is a risk of over-engineering the code to fulfill all test cases. The focus on passing tests may lead to complex and unnecessary code structures, making the system harder to understand</p><p>and maintain. This can result in slower development as developers spend additional time managing intricate test scenarios.</p><p><strong>3. Limited Flexibility:</strong><br>Extreme testing approaches can limit the flexibility to adapt quickly to changing requirements. Writing tests before fully understanding the desired outcome may result in rework or the need to discard previously written tests. This can introduce delays and hinder the delivery speed, especially when requirements evolve rapidly.</p><p><strong>Finding the Right Balance:</strong><br>To strike a balance between speed of delivery and thoroughness in testing, it’s crucial to adopt a pragmatic approach. Consider the context, project complexity, and time constraints when deciding on the testing strategy. While thorough testing is essential for critical systems, less critical or time-sensitive projects may require a more lightweight testing approach. By tailoring your testing efforts to the specific needs of each project, you can optimize speed without compromising quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*wsBL0_YdV8IJl149qZXfWA.jpeg" /></figure><p><strong>Conclusion:</strong><br>Contrary to popular belief, writing tests can actually make you faster as a software developer. By investing time in creating a robust test suite, you gain the ability to refactor code with confidence, catch bugs early, expedite code reviews, stay focused on what truly matters, and leverage AI tools to enhance your testing process. However, extreme testing approaches like TDD may introduce challenges related to initial time investment, over-engineering, and limited flexibility. Striking a balance between speed and thoroughness in testing is crucial to optimize the delivery speed while maintaining code quality. Embrace the power of testing while being mindful of the appropriate testing approach for each project, and you’ll find yourself becoming a more efficient and productive developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6249221b3dd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Hidden Complexity of Kafka Streams DSL: Solving Scaling Issues]]></title>
            <link>https://medium.com/@dharinshah1234/the-hidden-complexity-of-kafka-streams-dsl-solving-scaling-issues-8620fd344a6d?source=rss-86e6334711ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/8620fd344a6d</guid>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <category><![CDATA[data-processing]]></category>
            <dc:creator><![CDATA[Dharin S]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 15:48:23 GMT</pubDate>
            <atom:updated>2023-06-11T17:54:39.218Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong><br>Kafka Streams DSL is a powerful tool for building real-time data processing applications. Its simplicity and convenience make it an attractive choice for many developers. However, there are scenarios where the DSL’s ease of use can obscure the underlying complexity of data processing, leading to scaling issues. In this blog post, we will explore a specific problem encountered while using Kafka Streams DSL and discuss a solution that helped optimize the streams and resolve the scaling issues.</p><p><strong>Problem Statement:</strong><br>Let’s consider a data model with two topics: activity data and location data. The activity data contains information about various activities, <br>including a list of associated locations.</p><pre>{<br>....<br>&lt;other activity data&gt;,<br>&quot;locationIds&quot;: [1,2,3]<br>}</pre><p>The objective is to extract all the locations corresponding to each activity and produce an output keyed by the {activityId, locationId}</p><p><strong>Initial Implementation:</strong><br>Using the Kafka Streams DSL, the initial code to achieve this functionality was relatively straightforward. It involved a flatMap operation on the activity data, mapping each location to the corresponding activity. The resulting data was then stored in a table for further processing.</p><pre><br>var flatMappedActivityLocation = activityData<br> .toStream()<br> .flatMap((activityId, activityData) -&gt; {<br>     if (isNull(activityData.getLocations()) || isNull(activityOption.getLocations().getAll())) {<br>     return singletonList(<br>     KeyValue.pair(new ActivityLocationKey(activityId, null), null)<br>   );<br> }<br> return activityOption.getLocations()<br> .getAll()<br> .stream()<br> .map(location -&gt; ActivityLocationMapper.map(activityOption, location))<br> .map(value -&gt; KeyValue.pair(<br>     new ActivityLocationKey(value.getActivityId(), value.getLocationId()),<br>     value<br>   ))<br>   .collect(Collectors.toList());<br>   })<br> .toTable(Materialized.&lt;ActivityLocationKey, ActivityLocation, KeyValueStore&lt;Bytes, byte[]&gt;&gt;as(<br>   “flatmapped-locations”)<br> .withKeySerde(new JsonSerdes&lt;&gt;(ActivityLocationKey.class))<br> .withValueSerde(new JsonSerdes&lt;&gt;(ActivityLocation.class))<br> .withLoggingEnabled(materializedConf)<br> .withCachingEnabled()<br> );</pre><p><strong>Issue with the Initial Implementation:</strong><br>The problem arose when the activity data was not updated with the “locationIds” key every time it changed. However, due to the flatMap operation, updates were triggered for all locations of all activities downstream, even when there were no actual changes. This led to unnecessary processing and subsequent scaling issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V4MYlUigpGgLIRmICnLbdA.png" /></figure><p><strong>Solution: Adding a Custom Processor with the Processor API:</strong><br>To address the scaling issues caused by the unnecessary updates, a custom processor using the Processor API was introduced. The DeltaProcessor class acted as a throttling mechanism, filtering out unchanged records and only forwarding those that had undergone actual changes.</p><p>The DeltaProcessor class checked the previous and current values of a record and only forwarded the record if there was a difference. This prevented cascading updates downstream and optimized the streams’ processing.</p><pre><br>public class DeltaProcessor&lt;K, V&gt; implements Processor&lt;K, V, K, V&gt; {<br>   private final String mainStateStoreName;<br>   private KeyValueStore&lt;K, V&gt; mainStateStore;<br>   private ProcessorContext&lt;K, V&gt; context;<br><br>  public DeltaProcessor(String stateStoreName) {<br>   this.mainStateStoreName = stateStoreName;<br> }<br><br>@Override<br> public void init(ProcessorContext&lt;K, V&gt; context) {<br> this.context = context;<br> this.mainStateStore = context.getStateStore(this.mainStateStoreName);<br> }<br>@Override<br> public void process(Record&lt;K, V&gt; record) {<br>    var previousVal = Optional.ofNullable(mainStateStore.get(record.key()));<br>    var currentVal = Optional.ofNullable(record.value());<br>    try {<br>     if (!Objects.equals(previousVal, currentVal)) {<br>       context.forward(record);<br>     }<br>   } catch (Exception e) {<br>       log.error(&quot;Exception with key &quot; + record.key() + &quot; - &quot; + e.getMessage());<br>       context.forward(record);<br>   } finally {<br>       mainStateStore.put(record.key(), record.value());<br>       if (record.value() == null) {<br>         mainStateStore.delete(record.key());<br>       }<br>     }<br>   }<br><br> @Override<br> public void close() {}<br>}</pre><pre>var flatMappedActivityLocation = activityData<br> .toStream()<br> .flatMap((activityId, activityOption) -&gt; {<br>     if (isNull(activityOption.getLocations()) || isNull(activityOption.getLocations().getAll())) {<br>     return singletonList(<br>     KeyValue.pair(new ActivityLocationKey(activityId, null), null)<br>   );<br> }<br> return activityOption.getLocations()<br> .getAll()<br> .stream()<br> .map(location -&gt; ActivityLocationMapper.map(activityOption, location))<br> .map(value -&gt; KeyValue.pair(<br>     new ActivityLocationKey(value.getActivityId(), value.getLocationId()),<br>     value<br>   ))<br>   .collect(Collectors.toList());<br>   })<br>// add the processor<br>  .process(() -&gt; new DeltaProcessor&lt;&gt;(LOCATION_STATE_STORE_NAME),<br>                    LOCATION_STATE_STORE_NAME)<br> .toTable(Materialized.&lt;ActivityLocationKey, ActivityLocation, KeyValueStore&lt;Bytes, byte[]&gt;&gt;as(<br>   “flatmapped-locations”)<br> .withKeySerde(new JsonSerdes&lt;&gt;(ActivityLocationKey.class))<br> .withValueSerde(new JsonSerdes&lt;&gt;(ActivityLocation.class))<br> .withLoggingEnabled(materializedConf)<br> .withCachingEnabled()<br> );<br>Outcome (Lag issues went from ~5–10M to couple 1000s)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APhXJ-tTHSfuqEfTxV2UaQ.png" /></figure><p><strong>Outcome:</strong></p><p>Reduction of lag from 5–10M usually to 1000s now :). Reduced load on kafka cluster, and I/O reduction due to managed kafka means reduced cost :) (eventually)</p><p><strong>Conclusion:</strong><br>While the Kafka Streams DSL offers simplicity and ease of use, it is essential to be aware of the underlying complexity of data processing. In some cases, the DSL may abstract away important details that can impact scalability and performance.</p><p>By understanding the intricacies of the data model and incorporating custom processors when necessary, developers can overcome scaling issues and optimize their Kafka Streams applications. This example highlights the importance of diving deeper into the underlying mechanics of data processing to build efficient and robust streaming pipelines.</p><p>By being aware of the challenges and solutions discussed in this blog post, you can leverage Kafka Streams DSL effectively while mitigating potential scaling issues and ensuring smooth and efficient real-time data processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8620fd344a6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>