<?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 Amitesh Bharti on Medium]]></title>
        <description><![CDATA[Stories by Amitesh Bharti on Medium]]></description>
        <link>https://medium.com/@amiteshbharti?source=rss-5f4a8ef36e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9x1XztmZxbuzyxwxDenAwg.png</url>
            <title>Stories by Amitesh Bharti on Medium</title>
            <link>https://medium.com/@amiteshbharti?source=rss-5f4a8ef36e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 04:28:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amiteshbharti/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[Coding AI Model Selection Strategy for Engineering Teams (2026)]]></title>
            <link>https://medium.com/@amiteshbharti/coding-ai-model-selection-strategy-for-engineering-teams-2026-09e478cf2ccd?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/09e478cf2ccd</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Tue, 19 May 2026 14:11:22 GMT</pubDate>
            <atom:updated>2026-05-19T14:11:22.505Z</atom:updated>
            <content:encoded><![CDATA[<h4>A common question these days: How to Maximize Developer Productivity While Minimizing AI Costs?</h4><p>AI-assisted development has rapidly evolved from “nice to have” into a core engineering productivity multiplier. Tools like <a href="https://www.cursor.com/?utm_source=chatgpt.com">Cursor AI</a> are now deeply integrated into daily development workflows across startups, mid-size product companies, and large enterprises.</p><p>However, many teams are unknowingly burning massive AI budgets by using premium reasoning models for routine engineering tasks.</p><p>The smarter approach is not:</p><blockquote><em>“Use the best model everywhere.”</em></blockquote><p>The smarter approach is:</p><blockquote><em>“Use the right model for the right engineering problem.”</em></blockquote><p>This article outlines a practical, engineering-first strategy for selecting Cursor AI models cost-efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Btow5CWuDVvozPBf1jJBlw.png" /><figcaption>There is no single best model for every task</figcaption></figure><h3>The Core Engineering Principle</h3><p>Not every coding task requires elite reasoning.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ClR9tR7D9W4iKkl6TjFtAA.png" /></figure><p>Using a premium reasoning model for DTO generation is equivalent to:</p><ul><li>running Kubernetes for a cron job</li><li>using GPUs for string formatting</li><li>provisioning Redis for static data</li></ul><p>It works — but it is economically inefficient.</p><p>The goal should always be:</p><blockquote><em>Maximize output quality per token spent.</em></blockquote><h3>AI Model Matrix (2026)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYhrXo6butJLkxBUYVNY4Q.png" /></figure><h3>Best Model by Engineering Use Case</h3><h3>1. Daily Backend Development → GPT-4.1 Mini</h3><p>For most backend teams working with:</p><ul><li>Java</li><li>Spring Boot</li><li>Node.js</li><li>Python</li><li>REST APIs</li><li>SQL</li></ul><p>GPT-4.1 Mini delivers the best balance of:</p><ul><li>speed</li><li>quality</li><li>token efficiency</li></ul><h3>Ideal Tasks</h3><ul><li>controller creation</li><li>repository generation</li><li>SQL queries</li><li>unit tests</li><li>API wiring</li><li>integration logic</li><li>documentation</li></ul><h3>Why It Wins</h3><p>Most engineering tasks are not “hard AI reasoning problems.”</p><p>Teams often overpay by using premium models for:</p><ul><li>getters/setters</li><li>simple bug fixes</li><li>small code edits</li><li>repetitive implementation work</li></ul><p>GPT-4.1 Mini handles these extremely efficiently.</p><h3>Recommended Usage</h3><blockquote><em>70–80% of overall engineering usage.</em></blockquote><h3>2. Large Refactoring &amp; Migration → Claude Sonnet</h3><p>Claude Sonnet has become extremely popular for:</p><ul><li>large-scale refactoring</li><li>multi-file modifications</li><li>legacy modernization</li><li>migration workflows</li></ul><p>Especially useful for:</p><ul><li>PHP → Java migration</li><li>monolith cleanup</li><li>architectural restructuring</li></ul><h3>Why Sonnet Performs Well</h3><p>It maintains:</p><ul><li>long-context consistency</li><li>cleaner code organization</li><li>better structural awareness across files</li></ul><h3>Ideal Tasks</h3><ul><li>PR review</li><li>service restructuring</li><li>package cleanup</li><li>migration assistance</li><li>architecture alignment</li></ul><h3>Important Note</h3><blockquote>Sonnet is excellent for engineering quality, but can become expensive if used for routine coding. Use it strategically.</blockquote><h3>3. Production Debugging [GPT-4.1]</h3><p>Production debugging requires:</p><ul><li>stronger reasoning</li><li>higher consistency</li><li>better infra understanding</li></ul><p>GPT-4.1 performs particularly well for:</p><ul><li>Kafka consumer issues</li><li>concurrency bugs</li><li>Kubernetes troubleshooting</li><li>performance bottlenecks</li><li>distributed tracing</li></ul><h3>Recommended Usage Pattern</h3><p>Use GPT-4.1 only when:</p><ul><li>blocked for &gt;15 minutes</li><li>The issue is production-critical</li><li>debugging complexity increases</li></ul><p>This prevents unnecessary token burn.</p><h3>4. Repository Understanding [Gemini 2.5 Pro]</h3><p>One of Gemini’s biggest strengths is:</p><blockquote><em>very large context handling.</em></blockquote><p>This makes it highly effective for:</p><ul><li>unknown repositories</li><li>dependency analysis</li><li>onboarding into large codebases</li><li>impact analysis</li><li>documentation generation</li></ul><h3>Best Use Cases</h3><ul><li>“Explain this architecture.”</li><li>“Find all services dependent on X.”</li><li>“Analyze module coupling.”</li><li>“Summarize this repository.”</li></ul><h3>Not Ideal For</h3><p>Small transactional coding tasks.</p><h3>5. Premium Architecture Reasoning → Claude Opus</h3><p>Claude Opus is powerful, but expensive.</p><p>This model is best reserved for:</p><ul><li>senior engineers</li><li>staff engineers</li><li>architects</li><li>critical production investigations</li></ul><h3>Ideal Use Cases</h3><ul><li>migration strategy</li><li>event consistency design</li><li>distributed systems tradeoffs</li><li>scalability reviews</li><li>failure analysis</li></ul><h3>Important Reality</h3><p>Using Opus for routine coding typically yields poor ROI.</p><p>Treat it like:</p><blockquote><em>premium consulting compute.</em></blockquote><h3>6. Budget Optimization → DeepSeek</h3><p>DeepSeek gained popularity because it delivers:</p><ul><li>surprisingly strong reasoning</li><li>very low operational cost</li></ul><h3>Best Use Cases</h3><ul><li>quick prototypes</li><li>alternate implementation ideas</li><li>algorithmic work</li><li>budget-sensitive engineering teams</li></ul><h3>Caution</h3><p>Do not rely on it blindly for:</p><ul><li>production-critical architectural decisions</li><li>security-sensitive logic</li></ul><p>Use engineering review.</p><h3>Recommended Enterprise Cursor Setup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*om0O9VNcFAQc_gpsKEjEXg.png" /></figure><h3>Most Common AI Cost Mistakes</h3><h3>1. Using Premium Models for Everything</h3><p>This is the biggest operational mistake.</p><p>Premium models should be:</p><ul><li>Escalated usage</li><li>Not default usage</li></ul><h3>2. Sending Entire Repositories Unnecessarily</h3><p>Large context windows dramatically increase cost.</p><p>Only provide:</p><ul><li>Relevant files</li><li>Relevant modules</li><li>Focused context</li></ul><h3>3. Repeated Prompting</h3><p>Create:</p><ul><li>reusable prompts</li><li>Cursor rules</li><li>project memory</li><li>coding templates</li></ul><p>This reduces:</p><ul><li>prompt repetition</li><li>token waste</li><li>inconsistent output</li></ul><h3>4. Using AI for Deterministic IDE Work</h3><p>Avoid wasting AI tokens on:</p><ul><li>imports</li><li>formatting</li><li>simple renames</li><li>package movement</li></ul><p>Use IDE tooling instead.</p><h3>Practical Engineering Recommendation</h3><p>For most backend engineering teams, the highest ROI setup today is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tk_bTaxlDjqbYb3IUrxVFQ.png" /></figure><p>This model-routing strategy gives:</p><ul><li>Better engineering velocity</li><li>Lower operational AI cost</li><li>Controlled token consumption</li><li>Scalable enterprise adoption</li></ul><p>without sacrificing engineering quality.</p><h3>Final Thought</h3><p>The future of AI-assisted development is not about finding:</p><blockquote><em>“the single best model.” </em>It is about building: <em>“the most economically efficient engineering workflow.”</em></blockquote><p>The teams that master:</p><ul><li>model routing</li><li>token optimization</li><li>escalation-based usage</li><li>context discipline</li></ul><p>will gain the biggest long-term productivity advantage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=09e478cf2ccd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Engineering with AI: The Cursor Agent Working Agreement Every Team Should Follow]]></title>
            <link>https://medium.com/@amiteshbharti/engineering-with-ai-the-cursor-agent-working-agreement-every-team-should-follow-be186641d9d5?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/be186641d9d5</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cursor-ai-workflow]]></category>
            <category><![CDATA[cursor-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cursor-ai-engineering]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Thu, 05 Mar 2026 13:23:24 GMT</pubDate>
            <atom:updated>2026-03-05T13:23:24.664Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cursor Agent Working Agreement</h3><p><em>A practical, disciplined approach to using Cursor in your engineering team</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bc3XvgCdtCWOZ6bK0-ngsA.png" /></figure><h3>1. Philosophy</h3><p>Do not treat Cursor as a magic AI.</p><p>Treat it like a <strong>junior-to-senior engineer that needs a clear scope, constraints, and review</strong>.</p><p>goals:</p><ul><li>Ship faster without compromising quality</li><li>Control token usage and cost</li><li>Keep diffs predictable</li><li>Preserve architectural integrity</li></ul><p>AI is an accelerator - not a replacement for engineering judgment.</p><h3>2. Model Selection Standards</h3><p>Intentionally choose the model based on task complexity.</p><h4>Default Rules</h4><p><strong>Routine work (CRUD, endpoints, localized fixes)</strong><br>Use low-agency, fast codegen models (e.g., Composer 1)</p><p><strong>Refactors, architecture, and ambiguous problems</strong><br>Use reasoning models (e.g., Claude Sonnet/Opus, GPT-5.x)</p><p>Off-the-shelf reasoning models from:</p><ul><li>Anthropic</li><li>OpenAI</li></ul><p>They are powerful - but must be used deliberately.</p><h4>Anti-Pattern</h4><p>Using the most powerful model for every task<br>Letting high-agency models refactor beyond scope</p><p>Bigger model ≠ better outcome.</p><h3>3. Plan Mode Is Mandatory for Non-Trivial Work (two-phase workflow)</h3><p>For:</p><ul><li>Multi-file changes</li><li>Cross-cutting logic</li><li>User-visible features</li><li>Schema or contract changes</li></ul><p>Follow a strict <strong>two-phase workflow.</strong></p><h4>Phase 1 - Plan (Reasoning Model)</h4><ul><li>Provide a high-level goal</li><li>Use precise @ file tagging</li><li>Let the model explore and ask clarifying questions</li><li>Review the generated plan</li></ul><p>No execution until the plan is reviewed.</p><h4>Phase 2 - Execute (Low-Agency Model)</h4><ul><li>Switch to Composer (or similar)</li><li>Execute strictly against the approved plan</li><li>Avoid re-designing during execution</li></ul><p>Measure twice, cut once.</p><h3>4. Prompting Standards (Non-Negotiable)</h3><h4>Every Prompt Must Include:</h4><ul><li>Clear objective</li><li>Expected behavior</li><li>Constraints (performance, backward compatibility, contracts)</li><li>Explicit @ file tags</li></ul><p>Example structure:</p><blockquote><em>In @UserController.ts and @UserService.ts, add CSV export.<br>Reuse filters from @UserFilter.ts.<br>Do not modify existing DTO contracts.<br>Add tests in @UserController.test.ts.</em></blockquote><h4>Disallowed Prompt Patterns</h4><p>“Find the bug.”<br> “Refactor this repo.”<br> Vague intent with no file references<br> Letting the model scan the entire repository unnecessarily</p><p>Surgical context produces surgical changes.</p><h3>5. Agent Session Discipline</h3><p>Each Agent session = one ticket.</p><p>Rules:</p><ul><li>Open new Agent sessions frequently</li><li>Do not mix multiple features in one thread</li><li>Keep context windows narrow</li><li>Avoid dragging historical noise forward</li></ul><p>Smaller context = better precision + lower cost.</p><h3>6. Cost &amp; Token Awareness</h3><p>Regularly review Cursor usage logs.</p><p>Monitor:</p><ul><li>Model used</li><li>Token consumption</li><li>Runtime</li><li>Dollar cost</li></ul><p>Large token spikes usually indicate:</p><ul><li>Vague prompts</li><li>Missing file tags</li><li>Wrong model selection</li><li>Overuse of reasoning models</li></ul><p>Cost discipline is part of engineering excellence.</p><h3>7. Continuous Model Evaluation</h3><p>When new models arrive:</p><ul><li>Run controlled experiments</li><li>Compare outputs side-by-side</li><li>Evaluate quality vs cost vs speed</li><li>Update internal guidance</li></ul><p>The model landscape evolves.<br>Our practices must evolve, too.</p><h3>8. Code Ownership &amp; Review</h3><p>AI-generated code is:</p><ul><li>Reviewed like any other PR</li><li>Subject to the same architectural standards</li><li>Required to pass tests and lint rules</li></ul><p>Cursor assists.<br>Engineers remain accountable.</p><h3>9. Definition of Responsible Cursor Usage</h3><p>A disciplined engineer:</p><ul><li>Chooses the right model intentionally</li><li>Writes scoped, precise prompts</li><li>Uses @ tagging aggressively</li><li>Uses Plan Mode for complex changes</li><li>Reviews cost logs periodically</li><li>Treats execution like a controlled change, not exploration</li></ul><h3>10. Team Commitment</h3><p>Commit to:</p><ul><li>Not overusing high-agency models</li><li>Not generating unnecessary markdown or docs</li><li>Not letting AI modify unrelated files</li><li>Maintaining architectural clarity</li><li>Optimizing for speed <strong>and</strong> cost</li></ul><p>Do not “use AI casually.”</p><p>Integrate Cursor into your engineering system - with discipline, clarity, and measurable efficiency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be186641d9d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reverse Proxy: Enhancing Web Security and Performance]]></title>
            <link>https://medium.com/@amiteshbharti/reverse-proxy-enhancing-web-security-and-performance-18ca42fd29dc?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/18ca42fd29dc</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Sun, 10 Nov 2024 15:25:05 GMT</pubDate>
            <atom:updated>2024-11-10T15:25:05.895Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn what a reverse proxy is, its benefits for web security and performance, and examples like Cloudflare.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*AoxYQwnOHxYLYXmJoZElrQ.png" /><figcaption>An unsung hero that tirelessly protects our boarders</figcaption></figure><p>Imagine you run a popular e-commerce website. You know how crucial it is to provide customers with a seamless and secure shopping experience. But as your site gains more traction, it attracts not only eager shoppers but also cyber threats and overwhelming traffic. Here’s where a reverse proxy comes to the rescue, playing the role of an unsung hero behind the scenes.</p><h4>Understanding HTTP/HTTPS Traffic Management:</h4><p>Think of a reverse proxy as your website’s front gatekeeper. Every time a visitor comes to your site, the reverse proxy is the first point of contact. It receives their HTTP/HTTPS requests, checks them for any red flags, and then smoothly forwards them to the appropriate back-end servers to fetch data. This means your backend servers can focus on doing what they do best — handling business logic and content delivery — without worrying about managing a flood of incoming traffic.</p><p>For example, let’s say a sudden spike in shoppers hits your site during a holiday sale. Instead of your backend servers being directly overwhelmed, the reverse proxy takes the brunt of the load, distributing requests smartly so that no server is overworked. Customers experience a fast, smooth browsing session without realizing that an intelligent intermediary is making it all happen.</p><h4>The SSL/TLS Shield: Securing Customer Data:</h4><p>Now, security is non-negotiable. Picture this: a shopper trusts your site enough to make a purchase, sharing sensitive information like credit card details. Your reverse proxy is more than just a middleman — it’s also a vigilant guardian. When a shopper submits their payment over HTTPS, the reverse proxy manages the SSL/TLS encryption, ensuring that data is encrypted as it travels from their browser to your servers.</p><p>This is called <strong>SSL termination</strong>, where the reverse proxy decrypts the secure traffic before passing it to the backend servers. Why? Because decrypting SSL/TLS at each server can be resource-intensive. By offloading this task to the proxy, your servers save energy and run more efficiently. And don’t worry, the reverse proxy re-encrypts data when sending it back to the shopper, keeping the entire transaction safe and secure.</p><h4><strong>Unified SSL Management: Simplifying Your Life:</strong></h4><p>Let’s say you need to update your SSL certificates, which can be a nightmare if your infrastructure spans multiple backend servers. With a reverse proxy, you only need to handle SSL certificates in one place. It’s like having one master key instead of multiple keys for every door in your house. This not only simplifies management but also reduces the chances of an expired certificate going unnoticed and compromising your site’s security.</p><h4>A Layer of Defense Against Cyber Attacks:</h4><p>In the real world, a security guard at the front gate doesn’t just welcome guests; they also keep an eye out for troublemakers. Your reverse proxy does the same. It inspects traffic, detects unusual behavior, and blocks potential threats, such as DDoS attacks, before they hit your main servers. This proactive approach means that even during a malicious traffic surge, your legitimate users won’t experience disruptions. The proxy absorbs the attack, sparing your backend infrastructure from being overwhelmed.</p><p><strong>Cloudflare</strong>, for instance, is known for this dual role of gatekeeping and protecting. When users visit a site protected by Cloudflare, their requests pass through the service, which evaluates them, caches resources for faster delivery, and ensures they don’t carry any malicious payloads. The best part? Shoppers experience nothing out of the ordinary; they simply enjoy a fast and secure connection.</p><h4>Humanizing the Role of a Reverse Proxy:</h4><p>Imagine yourself at a busy airport. Security checkpoints ensure that only those with valid tickets pass through, luggage is scanned for safety, and travelers are directed to the correct gates. A reverse proxy is like that checkpoint for your website, scanning, securing, and directing requests smoothly to ensure everyone reaches their destination efficiently. And just like an experienced security officer can spot trouble and act fast, a reverse proxy can identify and block potential threats in real time.</p><h4>The Bottom Line:</h4><p>A reverse proxy may not be visible to users or celebrated in the tech world as often as it deserves, but it’s the backbone that keeps digital interactions safe and efficient. From managing traffic spikes and optimizing server loads to safeguarding sensitive data and repelling cyber threats, a reverse proxy makes modern online experiences possible. And just like a trusted gatekeeper, it ensures your visitors have a seamless, secure, and enjoyable experience every time they knock on your digital door.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18ca42fd29dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Key concepts of Circuit Breaker pattern focusing on Resilience4J’s]]></title>
            <link>https://medium.com/@amiteshbharti/key-concepts-of-circuit-breaker-pattern-focusing-on-resilience4js-1a30c41dc347?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a30c41dc347</guid>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[circuit-breaker]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 09:18:12 GMT</pubDate>
            <atom:updated>2024-10-29T09:33:20.142Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn the key concepts of the Circuit Breaker pattern with a focus on Resilience4J, covering how to implement and configure fault-tolerant, resilient microservices.</p><h4>What is a Circuit Breaker?</h4><p>A Circuit Breaker pattern is used to prevent a system from making requests to an external service if that service is likely to fail, thus avoiding cascading failures. It can have three main states:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*2IgCvQCa4yFhIy2y0qNxIA.png" /><figcaption>Circuit Breaker States</figcaption></figure><p>- <strong>Closed</strong>: The service is functioning normally; requests are allowed.<br>- <strong>Open</strong>: The service is down or too many failures have occurred; requests are blocked.<br>- <strong>Half-Open</strong>: The circuit breaker is checking if the service is recovering; a few requests are allowed.</p><h4><strong>Key Resilience4J Circuit Breaker Concepts</strong></h4><p><strong>a. Failure Threshold:</strong><br>- The Circuit Breaker remains C<strong>losed</strong> until a certain failure threshold is reached. After this, it transitions to the <strong>Open</strong> state.<br>- Example: If 50% of requests fail, the breaker will trip.</p><p><strong>b. Wait Duration:</strong><br>- After moving to the <strong>Open</strong> state, the circuit breaker will stay open for a specified period (e.g., 60 seconds).<br>- After this, it transitions to the <strong>Half-Open</strong> state, where a few test requests are sent to check if the external service has recovered.</p><p><strong>c.</strong> <strong>Success Threshold (Half-Open)</strong>:<br>- In the <strong>Half-Open</strong> state, the circuit breaker allows a limited number of requests to see if the service has recovered. If the requests are successful, the circuit breaker moves back to the <strong>Closed</strong> state.</p><h3><strong>Resilience4J in Spring Boot</strong></h3><p>Resilience4J integrates seamlessly with Spring Boot and allows you to annotate your methods to use the circuit breaker.</p><p><strong>Basic Steps:</strong><br>1. Add the Dependency** (use Gradle in your case):</p><pre>implementation &#39;io.github.resilience4j:resilience4j-spring-boot2:1.7.0&#39;</pre><p>2. <strong>Enable Circuit Breaker</strong>:<br> You can enable Circuit Breaker in your Spring Boot application with the `<a href="http://twitter.com/CircuitBreaker">@CircuitBreaker</a>` annotation.</p><pre> @RestController<br> public class DemoController {<br> <br> @CircuitBreaker(name = &quot;myService&quot;, fallbackMethod = &quot;fallback&quot;)<br> @GetMapping(&quot;/test&quot;)<br> public String test() {<br> // Call external service<br> return externalService.call();<br> }<br> <br> public String fallback(Exception e) {<br> return &quot;Service is unavailable. Please try again later.&quot;;<br> }<br> }</pre><p>3. <strong>Configuration</strong>:<br> Configure the behavior of the circuit breaker (failure rate, wait duration, etc.) in the `application.yml` or `application.properties`.<br> <br> Example (in `application.yml`):</p><pre>resilience4j:<br>  circuitbreaker:<br>    instances:<br>      hvodCircuitBreaker:<br>        registerHealthIndicator: true<br>        eventConsumerBufferSize: 100<br>        failureRateThreshold: 50 # percentage of failed calls before opening the circuit<br>        minimumNumberOfCalls: 10 # minimum number of calls before the circuit breaker considers the failure rate<br>        automaticTransitionFromOpenToHalfOpenEnabled: true<br>        waitDurationInOpenState: 30s # duration the circuit breaker stays open before transitioning to half-open state<br>        permittedNumberOfCallsInHalfOpenState: 5 # number of calls permitted in half-open state to check if the circuit can close<br>        slidingWindowSize: 10 # the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.<br>        slidingWindowType: COUNT_BASED # the last slidingWindowSize calls are recorded and aggregated.</pre><p>4. <strong>Sliding Window</strong>:<br>- Resilience4J uses a <strong>sliding window</strong> to determine when to trip the circuit breaker. You can choose between a <strong>count-based</strong> or <strong>time-based </strong>sliding window.<br> — <strong>Count-based: </strong>Tracks the last N requests.<br> —<strong> Time-based:</strong> Tracks all requests within a specified time window.</p><p><strong>5. Fallback Mechanism</strong>:<br>- The <strong>fallbackMethod</strong> provides an alternative response when the circuit breaker is in the <strong>Open</strong> state, allowing the system to degrade gracefully rather than failing completely.</p><p><strong>6. Key Metrics:</strong><br>- <strong>Failure Rate</strong>: Percentage of failed calls in the sliding window.<br>- <strong>Slow Call Rate</strong>: Percentage of slow calls (based on a defined threshold) in the sliding window.<br>- <strong>Number of calls in Half-Open State</strong>: How many test calls are allowed before deciding whether to switch back to <strong>Closed</strong> or remain <strong>Open</strong>.</p><h4>Summary:</h4><p>These are the core concepts that will give you a good understanding of how the Circuit Breaker pattern works with Resilience4J in Spring Boot:<br>1. Circuit Breaker states: Closed, Open, Half-Open.<br>2. Failure threshold and wait duration.<br>3. The sliding window (count-based or time-based).<br>4. Fallback method for graceful degradation.<br>5. Key configuration settings in <strong>application.yml</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a30c41dc347" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Workflows for Efficient Collaboration in Software Development]]></title>
            <link>https://medium.com/@amiteshbharti/git-workflows-for-efficient-collaboration-in-software-development-8d6fb9a2fa50?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d6fb9a2fa50</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Wed, 09 Oct 2024 14:25:44 GMT</pubDate>
            <atom:updated>2024-10-09T14:25:44.702Z</atom:updated>
            <content:encoded><![CDATA[<p>Git workflows are structured approaches that define how teams collaborate on code within a Git repository. They outline the process of branching, committing, and merging code to ensure smooth collaboration and version control. By adopting a well-defined workflow, teams can work simultaneously without stepping on each other’s toes, avoid duplication, and maintain the integrity of the codebase.</p><h4><strong>Importance of Choosing the Right Git Workflow</strong></h4><p>Selecting the right Git workflow is critical to maintaining project stability and efficiency. A suitable workflow allows developers to work concurrently, manage releases effectively, and ensures the project can adapt to changes. A poor workflow, on the other hand, can lead to confusion, merge conflicts, and delays in delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6r0AMdT4WaMKb1D8pDR7w.png" /></figure><p><strong>[1]. Centralized Workflow</strong><br> A simple workflow for small teams or projects where all developers commit to a single branch. This workflow resembles SVN-style version control, where all developers work from a single, central branch (usually main or master).<br><strong>How it works:</strong><br>a) Developers clone the central repository.<br>b) Work is done directly on the <strong>master</strong> branch.<br>c) Use `git pull` to fetch the latest changes, then `git push` to upload your work.<br> <strong>Pros</strong>:<br> — Simple and easy for teams used to centralized systems.<br> — No need for feature branches, making it straightforward for small teams.<br><strong> Cons:</strong><br> — Limited collaboration; code review is harder as everyone works directly on the same branch.<br> — Higher risk of conflicts and bugs if multiple developers push changes simultaneously.<br> — Example Use: Small teams or projects without complex feature requirements.<br> — Companies: Typically used by small startups or teams transitioning from SVN/CVS.</p><p><strong>[2]. Feature Branch Workflow </strong><br> Developers create separate branches for each feature they are working on, and then merge the branch into the <strong>master</strong> branch when the feature is complete, ensuring the <strong>master</strong> branch remains stable.<br><strong>How it works:</strong><br>Developers create a new branch (`git checkout -b feature-x`) for every feature or bug fix.<br>Once the feature is complete, it is merged into the <strong>master</strong> branch (often via a pull request).<br><strong>Pros:</strong><br> — Isolated feature development.<br> — Clear code history; easier for collaboration and code review.<br> — Allows testing features independently before merging into the main branch.<br><strong>Cons:<br></strong> — Requires more Git knowledge (e.g., branching and merging).<br> — Longer-lived branches can result in merge conflicts if multiple developers are working on the same parts of the codebase.<br><strong> Example Use: </strong>Most open-source projects and companies.<br><strong>Companies</strong>: Commonly used by companies like Microsoft, GitLab, and many open-source communities (like Kubernetes).</p><p><strong>[3]. Gitflow Workflow </strong><br> A more structured approach, using two main branches (<strong>master</strong> and `develop`) and additional feature, release, and hotfix branches. it becomes bit more complex workflow with dedicated branches for features, releases, and bug fixes.<br><strong>How it works:</strong><br> — Developers branch off `develop` for feature work.<br> — After a feature is complete, it’s merged back into `develop` and then into <strong>master</strong> upon release.<br> — Special branches like `release/` and `hotfix/` are used for final-stage preparation and urgent bug fixes.<br><strong>Pros:</strong><br> — Clear structure for different types of work (features, releases, and hotfixes).<br> — Works well for projects with scheduled releases.<br><strong>Cons:</strong><br> — More complex; requires good Git skills to manage multiple branches.<br> — Overhead in managing and keeping track of multiple long-lived branches.<br> <strong>Example Use: </strong>Teams working on large projects with regular release cycles.<br><strong>Companies:</strong> Used by large organizations like Spotify, Dell, and companies managing big projects with defined release schedules.</p><p><strong>[4]. Forking Workflow</strong><br><strong>Description: </strong><br> This is popular in open-source projects where contributors fork the repository, make changes in their fork, and submit a pull request to merge their changes into the upstream repository.<br><strong> How it works:</strong><br> — A developer forks the central repository to create their copy.<br> — Changes are made in the fork and a pull request is created to merge them back into the central repository.<br><strong>Pros:</strong><br> — Complete isolation for each developer.<br> — Perfect for open-source collaboration with external contributors.<br> — Maintainers have full control over what gets merged into the main repository.<br><strong>Cons:</strong><br> — Harder for teams to collaborate closely on the same feature.<br> — More Git knowledge required to manage forks and pull requests.<br><strong>Example Use:</strong> Open-source projects like Linux Kernel, Kubernetes, and Apache.<br><strong>Companies:</strong> GitHub-based open-source projects like Homebrew, React, and Kubernetes.</p><p><strong>[5]. Trunk-Based Development (TBD) </strong><br> All developers work on a single branch (the <strong>master</strong> branch or trunk) and commit small, frequent changes directly to it.<br><strong> How it works:</strong><br> — Developers push small changes to the <strong>master</strong> branch frequently.<br> — Code is always in a deployable state.<br> — Continuous integration (CI) and continuous delivery (CD) tools automatically build and test the codebase.<br><strong>Pros</strong>:<br> — Simple, fast, and easy to deploy changes.<br> — Encourages frequent, small commits, reducing the risk of large merge conflicts.<br> — Works well with CI/CD pipelines.<br><strong>Cons</strong>:<br> — Harder to manage larger features that require more development time.<br> — Requires a highly disciplined team and well-built test automation.<br><strong>Example Use</strong>: Continuous delivery-focused teams and companies with frequent deployments.<br><strong>Companies</strong>: Commonly used by companies like Google, Netflix, and Facebook.</p><p><strong>Which Workflow to Start With:</strong><br>As a beginner, I’d recommend starting with <strong>Feature Branch Workflow.</strong> These workflows are widely used and offer a good balance of simplicity and collaboration, making them perfect for most team environments and personal projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d6fb9a2fa50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Bother with Design Principles in System Design?]]></title>
            <link>https://medium.com/@amiteshbharti/why-bother-with-design-principles-in-system-design-07b5f819d0d4?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/07b5f819d0d4</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Sat, 28 Sep 2024 17:46:58 GMT</pubDate>
            <atom:updated>2024-09-28T17:46:58.775Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Bother with Design Principles in System Design? Uncover the Secret Sauce to Scalable and Resilient Architectures!</h3><p>Design Principles in System Design are more than just guidelines — they’re the foundation for building robust, scalable, and maintainable systems. But <strong>why are these principles so critical in creating effective software solutions?</strong></p><p>To understand it further, let’s get into the explanations for the “why” and “how” behind each design principle, along with specific examples for better understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oE_mrVM-Je6LRIpH--B1Zw.png" /></figure><p><strong>[1].</strong> 𝗦𝗲𝗽𝗮𝗿𝗮𝘁𝗶𝗼𝗻 𝗼𝗳 𝗖𝗼𝗻𝗰𝗲𝗿𝗻𝘀[<br>𝗪𝗵𝘆: This principle helps manage complexity by dividing a system into distinct sections, each addressing a separate concern.<br>𝗛𝗼𝘄: Break down the application into self-contained modules. For instance, in a typical e-commerce application, separate concerns such as user authentication, product catalog, and payment processing.<br>𝗘𝘅𝗮𝗺𝗽𝗹𝗲: In a microservices architecture, different services like ‘User Service’, ‘Order Service’, and ‘Payment Service’ are responsible for their specific domains, making the system easier to maintain and scale.</p><p><strong>[2]. </strong>𝗘𝗻𝗰𝗮𝗽𝘀𝘂𝗹𝗮𝘁𝗶𝗼𝗻 𝗮𝗻𝗱 𝗔𝗯𝘀𝘁𝗿𝗮𝗰𝘁𝗶𝗼𝗻<br> 𝗪𝗵𝘆: Encapsulation hides the internal workings of a system and protects it from outside interference. Abstraction simplifies complex systems by modeling classes appropriate to the problem.<br>𝗛𝗼𝘄: Use private fields and public methods to expose only the necessary information. Utilize abstract classes or interfaces to define common behaviors.<br>𝗘𝘅𝗮𝗺𝗽𝗹𝗲: A `Payment` class encapsulates the process of making a payment by hiding details like API calls to payment gateways. Abstracting it through an interface allows multiple implementations like `CreditCardPayment` or `PayPalPayment`.</p><p>[3]. 𝗦𝗰𝗮𝗹𝗮𝗯𝗶𝗹𝗶𝘁𝘆 𝗮𝗻𝗱 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲<br> 𝗪𝗵𝘆: Ensuring the system can handle increased load without compromising performance is crucial for user experience and business growth.<br>𝗛𝗼𝘄: Implement horizontal scaling, use caching, and optimize database queries. Consider load balancing and distributed databases for better performance.<br>𝗘𝘅𝗮𝗺𝗽𝗹𝗲: In a high-traffic web application, a caching layer like Redis can be used to store frequently accessed data, reducing database load and improving response times.</p><p><strong>[4]. 𝗥</strong>𝗲𝘀𝗶𝗹𝗶𝗲𝗻𝗰𝗲 𝗮𝗻𝗱 𝗙𝗮𝘂𝗹𝘁 𝗧𝗼𝗹𝗲𝗿𝗮𝗻𝗰𝗲<br> 𝗪𝗵𝘆: Systems should be resilient to failures to ensure high availability and reliability. This prevents a single point of failure from bringing down the entire system.<br>𝗛𝗼𝘄: Use circuit breakers, retries, and failover strategies. Implement health checks and fallback mechanisms to recover from failures.<br>𝗘𝘅𝗮𝗺𝗽𝗹𝗲: Netflix uses the Hystrix library to implement circuit breakers, ensuring that if a microservice fails, the failure is contained and does not cascade to other services.</p><p><strong>[5]. </strong>𝗟𝗼𝗼𝘀𝗲 𝗖𝗼𝘂𝗽𝗹𝗶𝗻𝗴 𝗮𝗻𝗱 𝗛𝗶𝗴𝗵 𝗖𝗼𝗵𝗲𝘀𝗶𝗼𝗻<br> 𝗪𝗵𝘆: Loose coupling reduces dependencies between components, making them easier to change or replace. High cohesion means that a module or class has a single responsibility.<br>𝗛𝗼𝘄: Use dependency injection, design systems around interfaces, and maintain single responsibility in classes.<br>𝗘𝘅𝗮𝗺𝗽𝗹𝗲: In a software library, classes for file operations (e.g., reading, writing, copying files) should be cohesive, and the library itself should be loosely coupled to the application using it through interfaces.</p><p>Design principles aren’t just theoretical concepts; they are practical tools that can transform how we build and maintain software systems. By adhering to these principles, we lay a solid foundation for creating systems that are not only efficient and scalable but also adaptable to changing needs and resilient in the face of unforeseen challenges.</p><p>Explore the world of design principles and take your system architecture to the next level. Whether you’re a seasoned architect or a developer just starting out, the right principles can be your blueprint for success. Happy designing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07b5f819d0d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Separation of Concerns (SoC) is indeed a game-changer in software development because it addresses…]]></title>
            <link>https://medium.com/@amiteshbharti/separation-of-concerns-soc-is-indeed-a-game-changer-in-software-development-because-it-addresses-bde5b4d507b6?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde5b4d507b6</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[design-thinking]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Sat, 28 Sep 2024 15:41:25 GMT</pubDate>
            <atom:updated>2024-09-28T15:41:25.945Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Separation of Concerns (SoC): The Key Design Principle for Clean Code</h3><p><strong>Separation of Concerns (SoC)</strong> is indeed a game-changer in software development because it addresses some of the fundamental challenges that arise during the design, implementation, and maintenance of software systems.</p><h4><strong>Definition:</strong></h4><p>SoC is a principle that promotes the division of a software system into distinct sections, each addressing a separate concern or responsibility. This separation minimises the overlap between different parts of the system, leading to a clearer structure.</p><h4><strong>Benefits:</strong><br>Here’s how SoC transforms software development:</h4><p><strong>1. Enhanced Maintainability</strong></p><blockquote><strong>Isolation of Changes: </strong>When each module or component addresses a single concern, changes in one part of the system have minimal impact on others. This isolation<em> reduces the risk of unintended side </em>effects and makes the codebase easier to maintain.<br><strong>Simplified Debugging</strong>: Bugs can be more easily traced and fixed because the code related to a specific functionality is confined to a particular module, <em>making the system more predictable</em>.</blockquote><p><strong>2. Improved Readability and Understandability</strong></p><blockquote><strong>Clear Code Structure:</strong> SoC organizes code in a way that mirrors the business logic, making it easier for developers to understand what each part of the system does without being overwhelmed by complexity.<br><strong>Self-Documenting Code</strong>: <em>When concerns are well-separated</em>, <em>code often becomes more self-explanatory</em>, reducing the need for extensive documentation.</blockquote><p><strong>3. Facilitated Parallel Development</strong></p><blockquote><strong>Concurrent Development: </strong>Multiple teams or developers can work on different modules independently, without stepping on each other’s toes. This parallelism accelerates development and reduces bottlenecks.<br><strong>Modular Delivery: </strong>Teams can deliver their modules independently, enabling a more agile and iterative development process.</blockquote><p><strong>4. Increased Reusability</strong></p><blockquote><strong>Reusable Components</strong>: By focusing each module on a specific concern, those modules are more likely to be reusable in other projects or parts of the system. This reduces duplication of effort and accelerates the development of new features.<br><strong>Standardized Interfaces</strong>: SoC encourages the use of well-defined interfaces for interacting with different parts of the system, making it easier to plug and play components as needed.</blockquote><p><strong>5. Better Testability</strong></p><blockquote><strong>Unit Testing: </strong>With clear boundaries between different concerns, it’s easier to write unit tests for individual modules. Each module can be tested in isolation, improving test coverage and reliability.<br><strong>Mocking and Stubbing:</strong> Testing isolated concerns allows for the use of mocks and stubs, making it easier to simulate and test interactions without relying on the full system.</blockquote><p><strong>6. Reduced Complexity and Enhanced Modularity</strong></p><blockquote><strong>Simplified Codebase:</strong> By breaking down the system into smaller, focused parts, developers can tackle one piece of the puzzle at a time. This leads to a system that’s easier to reason about and manage.<br><strong>Encapsulation of Logic:</strong> SoC encourages encapsulation of logic within modules, reducing the interdependence between different parts of the system. This modularity makes the code more adaptable to change.</blockquote><p><strong>7. Scalability and Flexibility</strong></p><blockquote><strong>Independent Scaling:</strong> Different concerns can be scaled independently based on demand. For example, in a microservices architecture, different services can be scaled separately according to their specific requirements.<br><strong>Ease of Extension:</strong> Adding new features or extending existing ones becomes more straightforward as new modules can be introduced without modifying or disrupting existing ones.</blockquote><p><strong>8. Supports Multiple Architectural Styles</strong></p><blockquote><strong>Layered Architecture</strong>: SoC enables the division of software into layers (e.g., Presentation, Business Logic, Data Access), where each layer has a distinct responsibility, facilitating easier updates and changes.<br><strong>Microservices</strong>: SoC is a foundational principle of microservices architecture, where each service is responsible for a specific business capability, promoting modularity and independent deployment.<br><strong>Domain-Driven Design (DDD): </strong>SoC complements DDD by allowing developers to focus on specific business domains and encapsulate the logic related to those domains in separate modules or services.</blockquote><p><strong>9. Improved Collaboration with Non-Technical Stakeholders</strong></p><blockquote><strong>Business Logic Isolation</strong>: With SoC, business rules and logic are often encapsulated in dedicated modules. This separation makes it easier for non-technical stakeholders to understand and review the business logic, leading to better alignment between business requirements and implementation.</blockquote><p><strong>10. Foundation for Modern Software Development Practices</strong></p><blockquote><strong>Continuous Integration/Continuous Deployment (CI/CD): </strong>Clear separation of concerns allows for better modular testing and deployment pipelines, making CI/CD processes more efficient.<br><strong>DevOps and Cloud-Native Architectures:</strong> SoC is key in creating loosely-coupled, cloud-native architectures where services can be independently deployed, monitored, and managed.</blockquote><h4>How Implementation of Modularity and SoC</h4><p><strong>Layered Architecture:</strong></p><ul><li>Divides the application into layers such as Presentation, Business Logic, and Data Access.</li><li>Each layer has a distinct responsibility and interacts only with its adjacent layers.</li></ul><p><strong>Microservices Architecture:</strong></p><ul><li>Breaks down the system into independently deployable services, each handling a specific business capability.</li><li>Services communicate through well-defined APIs, making them easy to develop, deploy, and scale independently.</li></ul><p><strong>MVC (Model-View-Controller) Pattern:</strong></p><ul><li>Separates the application into Model (data and business logic), View (UI), and Controller (user input processing).</li><li>Promotes separation of concerns within a single application or module.</li></ul><p><strong>Plugins and Extension Points:</strong></p><ul><li>Use plugins or extension mechanisms to add new functionality without modifying the core system.</li><li>Encourages modular design by allowing new features to be plugged in as needed.</li></ul><p><strong>Use of Interfaces and Abstract Classes:</strong></p><ul><li>Define clear contracts for modules, promoting loose coupling and easier module swapping or mocking during testing.</li></ul><p><strong>Service-Oriented Architecture (SOA):</strong></p><ul><li>Organizes the system into services, each representing a specific business capability, with defined protocols and message formats for communication.</li></ul><p>In essence, SoC is a transformative principle because it lays the foundation for building software systems that are easier to develop, extend, and maintain. It allows developers to manage complexity by breaking it down into manageable parts, promotes collaboration, and enhances the quality and agility of software development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde5b4d507b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Bitmap Operators Are Essential in Programming and Systems Design ]]></title>
            <link>https://medium.com/@amiteshbharti/why-bitmap-operators-are-essential-in-programming-and-systems-design-570ca6acc6ad?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/570ca6acc6ad</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Sat, 14 Sep 2024 15:52:00 GMT</pubDate>
            <atom:updated>2024-09-14T15:56:44.175Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to programming, particularly in areas where performance and memory efficiency are critical, <strong>bitmap operators</strong> (also known as <strong>bitwise operators</strong> play a key role. These operators allow us to manipulate data at the binary level, enabling low-level control over the bits that make up integers. This makes them highly valuable when writing optimized code, especially for system-level programming, data compression, cryptography, and algorithms that require fast, efficient computations.</p><p><strong>What are Bitwise Operators</strong>?<br>At their core, bitmap operators allow you to perform operations on binary numbers (1s and 0s). Since computers store data in binary, these operators interact directly with the underlying hardware, making them incredibly fast and efficient. Some common bitwise operators are:<br>- <strong>AND (`&amp;`)</strong>: Sets each bit to 1 if both corresponding bits are 1.<br>- <strong>OR (`|`)</strong>: Sets each bit to 1 if at least one corresponding bit is 1.<br>- <strong>XOR (`^`)</strong>: Sets each bit to 1 if only one of the corresponding bits is 1.<br>- <strong>NOT (`~`)</strong>: Inverts all the bits.<br>- <strong>Bit</strong> <strong>shifts (`&lt;&lt;`, `&gt;&gt;`)</strong>: Moves the bits to the left or right, effectively multiplying or dividing by powers of two.</p><p>While these operators may seem obscure if we’re used to higher-level programming constructs, they are extremely powerful for optimizing specific types of computations. Let’s break it down with an example.</p><h4>Practical Example: Counting Set Bits (1s) in a Number 🔢</h4><p>One common use case is counting how many bits are set to `1` in a number’s binary representation. This has practical applications in fields like <strong>error detection, compression algorithms</strong>, and <strong>data analytics,</strong> where you need to quickly analyze the binary state of large datasets.</p><p>Here’s a Java example that counts the number of `1`s in a binary number using bitwise operations:</p><pre>public static int countSetBits(int num) {<br>  int count = 0;<br>    while (num &gt; 0) {<br>      count += num &amp; 1; // Check if the least significant bit is 1<br>      num &gt;&gt;= 1; // Right shift to examine the next bit<br>    }<br>  return count;<br>}</pre><p><strong>Let’s walk through an example: </strong><br>If the input is `15` (which is `1111` in binary), this function will count 4 set bits. Why? The bitwise AND (`&amp;`) operation checks the last bit each time, and the right shift (`&gt;&gt;=`) moves to the next bit after each iteration, until there are no more bits left to examine. This provides a fast way to count set bits, which can be much more efficient than conventional methods.</p><h4>Advantages of Bitmap Operators 🚀</h4><p>1. <strong>Incredible Speed</strong>: Bitwise operations are <strong>extremely fast</strong> because they operate at the hardware level. Unlike loops or recursive functions that have time complexity based on the number of elements or iterations, bitwise operations execute in constant time, \( O(1) \). This makes them ideal for use in performance-critical applications such as <strong>encryption</strong>, <strong>checksum calculations</strong>, and <strong>graphics rendering</strong>.</p><p>2. <strong>Memory Efficiency</strong>: With bitwise operations, you can pack a lot of data into a small space. For example, imagine you need to store multiple boolean flags (true/false values). Instead of using multiple variables, you can use the bits of a single integer. A 32-bit integer can store 32 independent flags — this is how permissions and configurations are often handled in <strong>file systems</strong> and <strong>operating systems</strong>. The <strong>memory savings</strong> are particularly useful in constrained environments like embedded systems or mobile applications.</p><p>3. <strong>Versatility</strong>: Bitwise operators are not just limited to low-level programming. They are frequently used in fields such as <strong>cryptography</strong>, where encryption algorithms rely heavily on manipulating individual bits to secure data. They also play a role in <strong>compression algorithms</strong> like JPEG or PNG, helping to reduce file sizes by compacting data in an efficient manner.</p><p>4. <strong>Algorithm Optimization</strong>: Many advanced algorithms in data science, machine learning, and network security use bitwise operations to optimize tasks like checking for duplicates, creating hash functions, and finding the intersection or union of sets. For example, **Bloom filters**, a space-efficient probabilistic data structure, use bitwise operations to quickly check whether an element is present in a set, without requiring the storage of the entire dataset.</p><h4>Caution: Readability and Complexity ⚠️</h4><p>Despite their power, bitwise operators should be used with caution. Here are a few reasons why:<br>- <strong>Code Readability</strong>: Bitwise operations, while efficient, can make your code harder to understand for someone who isn’t familiar with them. Unlike simple arithmetic or logical operators, bitwise operators deal with binary representations, which are not always intuitive at first glance. This can make debugging more difficult. A clear comment explaining the purpose of each operation is essential.<br> <br>- <strong>Potential for Errors</strong>: Bitwise operations involve working with the raw bits of numbers, which means you need to be aware of integer overflow and boundary conditions. For instance, if you’re shifting bits too far left or right, you can end up with unexpected results due to overflow, especially if you’re working with fixed-width data types (e.g., 32-bit or 64-bit integers).</p><p>- <strong>Portability</strong>: In some cases, the behavior of bitwise shifts may vary between platforms due to differences in how they handle signed and unsigned integers. Always check how your programming language or platform implements bitwise operations.</p><h4>Conclusion: Efficient and Powerful but Use Wisely 💻✨</h4><p>Bitmap operators are a powerful tool in any programmer’s arsenal, providing both <strong>speed</strong> and <strong>memory efficiency</strong> in critical operations. Whether you’re working on encryption algorithms, optimizing performance, or reducing memory usage in large-scale applications, these operators can make a significant impact.</p><p>However, always remember to balance efficiency with code clarity. If not used properly, bitwise operators can lead to hard-to-understand and error-prone code, especially for those unfamiliar with binary logic. When in doubt, use comments to explain your logic, and ensure that any use of bitwise shifts or operations is well-tested for edge cases.</p><p><strong>How have bitmap operators helped you in your programming journey? Share your experience in the comments below!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=570ca6acc6ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PACELC Theorem Explained: A Comprehensive Guide to Distributed System Trade-offs]]></title>
            <link>https://medium.com/@amiteshbharti/pacelc-theorem-explained-a-comprehensive-guide-to-distributed-system-trade-offs-0f2a0748f3ba?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f2a0748f3ba</guid>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Tue, 10 Sep 2024 17:57:55 GMT</pubDate>
            <atom:updated>2024-09-10T17:57:55.995Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of distributed systems, reliability, speed, and consistency are vital concerns that need to be balanced. One of the widely discussed concepts in this space is the CAP theorem, which states that a distributed system can only achieve two of the three properties: <strong>Consistency</strong>, <strong>Availability</strong>, and <strong>Partition Tolerance</strong>. However, while CAP theorem captures the challenges during network partitions, it doesn’t fully address the system behavior in normal conditions when no partition exists.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*Tc66g_g41DS_2VTx.png" /><figcaption>CAP Theorem</figcaption></figure><p>This is where the <strong>PACELC theorem</strong> comes in, which extends the CAP theorem to consider latency vs. consistency trade-offs, even in the absence of partitions.</p><h3>What is PACELC?</h3><p><strong>PACELC</strong> stands for:<br>- <strong>P</strong>: Partition<br>- <strong>A</strong>: Availability<br>- <strong>C</strong>: Consistency<br>- <strong>E</strong>: Else<br>- <strong>L</strong>: Latency<br>- <strong>C</strong>: Consistency</p><p>The PACELC theorem builds on the CAP theorem, stating that i<strong>f a partition occurs (P)</strong>, the system must choose between a<strong>vailability (A)</strong> and <strong>consistency(C)</strong>(as per the CAP theorem). But <strong>else (E)</strong>, when no partition exists, the system still faces a trade-off between <strong>latency (L)</strong> and <strong>consistency(C)</strong>.</p><h3>Breaking Down PACELC</h3><ol><li><strong>Partition (P)</strong>:<br>A partition refers to a breakdown in communication between nodes in a distributed system. This could happen due to network failures, where different parts of the system can no longer communicate.<br>→During a partition, the system needs to make a choice:<br> — &gt;<strong>Consistency</strong>: Ensuring that every read returns the latest write.<br> —&gt;<strong>Availability</strong>: Ensuring that every request (read/write) gets a response, even if it’s not the most recent data.</li></ol><p>According to PACELC, if a partition occurs, the system needs to choose between availability and consistency (as per CAP). Most systems prioritize availability, but this comes at the cost of consistency.</p><p>2. <strong>Availability (A)</strong>:<br> — Availability means that every request to the system receives a response. However, the response may not necessarily be the most recent or accurate due to network delays or failures.<br> — This prioritizes a quick response over guaranteeing that the most up-to-date data is being served.</p><p>3. <strong>Consistency(C)</strong>:<br> — Consistency ensures that every request receives the most recent data or throws an error when that’s not possible. A system emphasizing consistency ensures that no stale or outdated data is read, but this may slow down responses.</p><p>4. <strong>Else (E)</strong>:<br> — The “else” part of PACELC addresses situations where there is <strong>no partition</strong>. Even without a network failure, systems still have to make a trade-off between two key factors:<br> — <strong>Latency</strong>: How quickly the system can respond to a request.<br> — <strong>Consistency</strong>: Ensuring that the response is the most recent and correct.</p><p>In this scenario, the system must balance consistency with latency. Systems that prioritize <strong>latency</strong> return faster responses but may not guarantee the most recent write, while systems that prioritize <strong>consistency</strong> ensure accuracy but at the expense of slower response times.</p><p>5. <strong>Latency (L)</strong>:<br> — Latency refers to the time taken for a system to respond to a request. In distributed systems, this can be a crucial factor in maintaining a smooth user experience.</p><p>6. <strong>Consistency(C)</strong>:<br> — Once again, consistency in this context means ensuring that every read reflects the most recent write. Systems prioritizing consistency may introduce higher latency because they must ensure data synchronization across all nodes.</p><h3>Understanding the Trade-offs</h3><p>Here’s how the PACELC theorem helps frame trade-offs:</p><p>- <strong>If there’s a partition (P)</strong>:<br> — You must choose between <strong>Availability (A)</strong> and **<strong>Consistency(C)</strong>.<br> <br>- <strong>Else (E)</strong>, if no partition exists:<br> — You must choose between <strong>Latency (L)</strong> and <strong>Consistency(C)</strong>.</p><p>Systems must choose whether to prioritise user experience with low latency or prioritise the correctness of the data with consistency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YlHh1uDJu1qGCF3N.png" /><figcaption>PACELE vs CAP theorem</figcaption></figure><h3>Real-World Applications of the PACELC Theorem</h3><p>1. <strong>AP systems (Availability over Consistency in Partitions)</strong>:<br> — Databases like <strong>Cassandra, </strong>or <strong>DynamoDB</strong> prioritise availability, ensuring that data is always available even if it’s not the most recent.<br> <br>2. <strong>PC systems (Consistency over Availability in Partitions)</strong>:<br> — Systems like <strong>HBase</strong> prioritize consistency, ensuring that clients only receive the latest and correct data, even if it means that some requests may fail or be delayed during partitions.</p><p>3. <strong>EL systems (Latency over Consistency when no partition)</strong>:<br> →These systems ensure low latency for fast read/write operations, but the data might not be the latest. For example, certain configurations of <strong>MongoDB</strong> allow for faster responses at the expense of consistency.</p><p>4. <strong>EC systems (Consistency over Latency when no partition)</strong>:<br> →Systems like <strong>Google’s Spanner</strong> prioritise consistency, ensuring all clients see the same data but may have slower response times due to global synchronisation.</p><h3><strong>Conclusion</strong></h3><p>The PACELC theorem extends the CAP theorem by introducing the latency-consistency trade-off even when the system is functioning normally. This model provides a more comprehensive view of the challenges involved in distributed systems. The key takeaway is that distributed systems, regardless of partitioning, are always balancing between different trade-offs: availability vs. consistency and latency vs. consistency. Understanding these trade-offs is crucial when designing systems that need to meet high demands for both speed and accuracy.</p><p>By leveraging the PACELC framework, system architects can make more informed decisions about how to configure their systems based on specific application needs, use cases, and network environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f2a0748f3ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proven Strategies for Kafka MSK Cost Optimization]]></title>
            <link>https://medium.com/@amiteshbharti/tips-to-reduce-the-aws-msk-costs-af03d1fa8add?source=rss-5f4a8ef36e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/af03d1fa8add</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[aws-msk]]></category>
            <dc:creator><![CDATA[Amitesh Bharti]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 16:08:42 GMT</pubDate>
            <atom:updated>2024-09-07T16:15:32.683Z</atom:updated>
            <content:encoded><![CDATA[<p>𝗜𝗻 𝘁𝗼𝗱𝗮𝘆’𝘀 𝗱𝗮𝘁𝗮-𝗱𝗿𝗶𝘃𝗲𝗻 𝘄𝗼𝗿𝗹𝗱, 𝗿𝗲𝗮𝗹-𝘁𝗶𝗺𝗲 𝗽𝗿𝗼𝗰𝗲𝘀𝘀𝗶𝗻𝗴 𝗶𝘀 𝗸𝗶𝗻𝗴.</p><p>𝗔𝗣𝗔𝗖𝗛𝗘 𝗞𝗔𝗙𝗞𝗔 — the powerhouse that makes real-time streaming at scale possible. However, to fully harness Kafka’s potential, it’s essential to follow the best practices to ensure optimal performance, reliability, and scalability.</p><p>𝗔𝗺𝗮𝘇𝗼𝗻 𝗠𝗦𝗞 (𝗠𝗮𝗻𝗮𝗴𝗲𝗱 𝗦𝘁𝗿𝗲𝗮𝗺𝗶𝗻𝗴 𝗳𝗼𝗿 𝗔𝗽𝗮𝗰𝗵𝗲 𝗞𝗮𝗳𝗸𝗮) — a fully managed service that makes it easier to build and run applications that use Apache Kafka.</p><p>let’s outline some cost optimization practices to follow when using Amazon MSK without compromising on performance or reliability.</p><p><strong>1. Right-Size Your Brokers</strong><br> Choose the appropriate broker instance types and sizes based on your workload. Avoid over-provisioning by selecting the smallest instance that meets your performance needs.</p><p><strong>2. Leverage Auto-Scaling</strong><br> Use MSK’s auto-scaling features to adjust the number of partitions or brokers based on demand, avoiding unnecessary costs during periods of low traffic c.</p><p><strong>3. Optimize Topic Partitioning</strong><br> Carefully plan the number of partitions per topic. Too many partitions can increase costs due to higher resource consumption, while too few can impact performance.</p><p><strong>4. Use Spot Instances for Testing</strong><br> Use EC2 Spot Instances for non-production environments like development and testing. Spot instances offer significant cost savings over On-Demand instances.</p><p><strong>5. Choose the Right Storage</strong><br> AWS MSK allows you to set the storage capacity for each broker. Optimize your storage based on actual data retention needs to avoid paying for unused capacity.</p><p><strong>6. Adjust Data Retention Policies</strong><br> Configure your Kafka topics to retain data only as long as necessary. Shorter retention periods reduce storage costs without impacting data availability.</p><p><strong>7. Monitor and Tune Performance</strong><br> Use CloudWatch to monitor resource usage and Kafka performance metrics. Identify bottlenecks and adjust configurations to improve efficiency and reduce resource consumption.</p><p><strong>8. Use Compression</strong><br> Enable data compression (e.g., Snappy, GZIP) for messages to reduce data size, leading to lower storage and data transfer costs.</p><p><strong>9. Consolidate Workloads</strong><br> Reduce the number of Kafka clusters by consolidating workloads wherever possible. Running multiple clusters may increase costs due to additional brokers and resources.</p><p><strong>10. Set Up Lifecycle Policies for Snapshots</strong><br> Create lifecycle policies for Kafka data snapshots to automatically delete old snapshots that are no longer needed, saving on long-term storage costs.</p><p><strong>11. Optimize Data Transfer</strong><br> Keep your Kafka clients within the same AWS region as your MSK cluster to minimize cross-region data transfer fees. For multi-region use, configure VPC peering or Transit Gateway to optimize costs.</p><p><strong>12. Enable Broker Log Segmentation</strong><br> Configure log segment sizes to prevent Kafka brokers from managing large log files, reducing resource consumption and avoiding potential cost increases.</p><p><strong>13. Use Reserved Instances</strong><br> If you have predictable long-term workloads, use Reserved Instances for brokers to benefit from significant cost savings over On-Demand pricing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af03d1fa8add" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>