<?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 Saksham on Medium]]></title>
        <description><![CDATA[Stories by Saksham on Medium]]></description>
        <link>https://medium.com/@mani.saksham12?source=rss-6892c257514c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*JA1BcHDKOIbyGczI.jpg</url>
            <title>Stories by Saksham on Medium</title>
            <link>https://medium.com/@mani.saksham12?source=rss-6892c257514c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:18:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mani.saksham12/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[The Model Is Not the Moat.. The Orchestration Is]]></title>
            <link>https://medium.com/@mani.saksham12/the-model-is-not-the-moat-the-orchestration-is-a225717dc55a?source=rss-6892c257514c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a225717dc55a</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[large-language-models]]></category>
            <dc:creator><![CDATA[Saksham]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 09:47:24 GMT</pubDate>
            <atom:updated>2026-11-15T09:47:24.950Z</atom:updated>
            <content:encoded><![CDATA[<h4>149 multi-agent evals on Meta Muse Ember, Llama 4, GPT-6 Luna, Claude Haiku 5.5 and leading open-weight models across three orchestration architectures, including a new parallel ensemble model I built.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KRssN6EC87ne2fgVlyQYnA.png" /><figcaption>Same weights, three architectures. Results from 149 live multi-agent runs and 109 judge evaluations.</figcaption></figure><p>Meta’s Muse Ember is one of the strongest new models of late 2026. On real Amazon earnings filings, it scored a perfect 100% under every architecture I tested. Then I gave it a simple three-step tool task inside AutoGen. On first turn it replied with text instead of a tool call, and it scored 25 out of 100.</p><p>I didn’t change the model, and I didn’t touch the prompt. I ran it inside the parallel ensemble I built, where five copies of the model propose each action and vote before anything executes. Muse Ember picked every tool and every argument correctly, and its score jumped to <strong>89.8</strong>.</p><p>It wasn’t the only one. DeepSeek V4.1 Flash went from 24.6 to <strong>92.7</strong>. On the Amazon filings, the ensemble also filtered out two guidance revisions that Llama 4 Maverick had reported but that never happened, which lifted its change detection from 33% to <strong>100%</strong>.</p><p>In 2026, almost every team has access to the same models. What separates a demo from a dependable product is the system’s orchestration, harness and the evals around the model.</p><h4>The 60-second version</h4><ul><li><strong>Meta Muse Ember</strong> scored 100% on real filings under all three architectures. On tool use, the ensemble took it from 25 to 89.8.</li><li><strong>Llama 4 Maverick</strong> extracted every number from the filings, and the ensemble removed its two false revisions, taking change detection from 33% to 100%.</li><li><strong>Open-weight models are production-grade.</strong> gpt-oss-120b scored 100% on real filings under all three architectures. Gemma 4 26B posted the single best extraction score (99.9). Kimi K2.6 (97.1) and Qwen 3.8 Flash (96.2) were the best single-agent tool callers.</li><li><strong>Frontier models still need the right orchestration.</strong> GPT-6 Luna was perfect everywhere. Claude Haiku 5.5 scored 99.3 on LangGraph and 12.6 under AutoGen, where its output was truncated.</li><li><strong>The ensemble was 19% to 47% faster on open-ended synthesis</strong> than a sequential graph, and the 2026 judges rated it as high or higher.</li><li><strong>Evals need better judges.</strong> A legacy LLM judge gave 92/100 to an output that was missing its required JSON.</li></ul><blockquote>My earlier open-source project, Ember Swarm, was built on Muse Ember. Every model in this study ran through the same harness, prompts and graders.</blockquote><h3>What I built, and how I tested it</h3><p>When an AI team picks a model, the ritual is familiar: check a leaderboard, compare the price per million tokens, and choose. But a production model rarely runs as a single prompt. It runs inside an <strong>orchestration</strong>: a graph that breaks the task into steps, a review loop where one agent checks another, or a team of agents working in parallel.</p><p>The economics of orchestration have changed. Capable 2026 models cost between $0.04 and $0.15 per million input tokens, which makes a multi-agent system almost free to run. In my earlier <a href="https://github.com/sakshamaggarwal/ember-swarm"><em>Ember Swarm</em></a><em> </em>project, 100 parallel agents, one synthesizer and ten judges (111 calls in all) produced a seven-pillar crisis plan in <strong>24.3 seconds for $0.0187</strong>.</p><p>Question with Cheap calls : Does a parallel ensemble actually beat a well-built graph or a review loop, or does it only repeat the same mistakes at higher volume? To answer it, I needed a fair harness.</p><h4>The harness</h4><p>I built on SmartWrapperOSS, an excellent open-source eval framework. It compares AutoGen and LangGraph with confidence intervals and deterministic graders. I extended it with a third architecture, the <strong>parallel ensemble</strong>, and with new benchmarks on real financial filings, multi-step tool use and cross-lab judging.</p><p>Every runner follows the same contract. It takes a model ID and a task, routes every call through the same OpenRouter telemetry, and returns a structured result with per-call token counts, wall-clock latency and error traces. The model, the prompt and the graders stay fixed. Only the orchestration changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEsjvVVBUwNJnBPHWzhMiw.png" /><figcaption>Two widely used baselines and the parallel ensemble introduced in this study. Critical path means the number of sequential model calls a user waits on.</figcaption></figure><h3>Three Architectures</h3><ol><li><strong>Conversational critique (AutoGen).</strong> An analyst agent reads everything and drafts the answer, and a reviewer agent checks it against the source. It uses the fewest tokens, and both agents must handle the full context and the full output.</li><li><strong>Baseline: Stateful graph (LangGraph).</strong> Each node reads one document, a comparison node computes the changes between periods, and plain Python merges the results with no model call. Each step stays small and clean, and the steps run one after another.</li><li><strong>New parallel ensemble.</strong> Five role-specialized agents work at the same time, and a synthesizer reconciles their drafts. For tool calls, the synthesizer becomes a voter that approves each action before it runs. The ensemble delivers the redundancy of a committee with only two sequential steps, so it runs at roughly the latency of a single review loop.</li></ol><h4>Fourteen models</h4><ul><li><strong>Meta:</strong> Muse Ember and Llama 4 Maverick.</li><li><strong>Latest frontier models:</strong> OpenAI’s GPT-6 Luna and Anthropic’s Claude Haiku 5.5.</li><li><strong>Popular open-weight models:</strong> OpenAI’s gpt-oss-120b, Google’s Gemma 4 (26B and 31B), Alibaba’s Qwen 3.8 Flash, DeepSeek V4.1 Flash, Moonshot’s Kimi K2.6 and Z.ai’s GLM-5.3 Flash.</li><li><strong>Supporting roles:</strong> Google’s Gemini 2.5 Flash, NVIDIA’s Nemotron 3 Ultra and Mistral Large 4, plus gpt-4o-mini as a legacy judge.</li></ul><h3>Four benchmarks</h3><ol><li><strong>Synthetic financial extraction (Northwind, 2.3 KB, 52 runs).</strong> The task was to extract 13 guidance ranges and 7 revisions from two short synthetic earnings excerpts containing 7 deliberate traps.</li><li><strong>Real-world extraction (Amazon, 37.1 KB, 36 runs).</strong> The same job on Amazon’s Q2 and Q3 2026 earnings releases, with real traps such as quarterly net sales ($200.6B and $201.9B), AWS run rates ($169B and $184B) and a Prime Day timing shift.</li><li><strong>Multi-step tool use (35 runs).</strong> A dependent chain (check the weather, read the calendar, move an event), with destructive decoy tools such as “delete event” on offer.</li><li><strong>Open-ended synthesis (26 runs, 109 judge calls).</strong> A seven-pillar global crisis plan with a machine-checkable budget and headcount, scored 55% by deterministic checks and 30% by a six-model judge panel.</li></ol><blockquote>First three benchmarks are scored entirely by deterministic graders, with no LLM judge in the loop.</blockquote><h3>Finding 1 : Real documents separate the field</h3><p>On the 2.3 KB synthetic test, almost every model looked excellent. Z.ai’s GLM-5.3 Flash came first (99.8 at $0.0002 per run), followed by gpt-oss-120b (99.2), Muse Ember (99.1) and Claude Haiku 5.5 (98.7).</p><p>Then I switched to Amazon’s real earnings releases, where the forward guidance sits beneath roughly 35,000 characters of segment tables, cash-flow reconciliations and operating highlights. The field separated into three clear tiers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SYQIxQEYlKvFCZDy6sKNA.png" /><figcaption>Left column: best score on the 2.3 KB synthetic test. Right three columns: scores on the 37.1 KB Amazon releases by architecture. “T” marks a truncated output.</figcaption></figure><p><strong>Three models were perfect under every architecture.</strong> Muse Ember, GPT-6 Luna and gpt-oss-120b scored 100% on every mechanical dimension under AutoGen, LangGraph and ensemble. gpt-oss-120b matched Muse Ember’s 99.7 on LangGraph in 3.6 seconds and was the top open-weight model in the ensemble (97.9). For teams that need to self-host, that is great news: an open-weight model delivered frontier-level reliability on real filings.</p><p><strong>The ensemble removed false alarms.</strong> Llama 4 Maverick extracted every guidance number correctly on LangGraph and AutoGen, but it reported two revisions that never happened. That is the classic roll-forward trap, where last quarter’s guidance becomes this quarter’s actual results. In the ensemble, the specialists did not support those claims, the synthesizer dropped them, and Maverick’s change detection rose from 33% to 100%.</p><p><strong>The synthesizer model matters.</strong> Gemma 4 26B, a mixture-of-experts model with about 4 billion active parameters, posted the best single score of the study on LangGraph (99.9 at $0.0014), where Python does the merging. As the ensemble’s synthesizer, it scored 33% on change detection. The dense Gemma 4 31B, on the same filings and the same task, scored 100% on both LangGraph (98.9) and the ensemble (96.7). <strong>When an LLM does the merging, choose the merger deliberately.</strong></p><blockquote>Among the frontier models, Claude Haiku 5.5 scored 99.3 on LangGraph and 97.6 in the ensemble, but its output was truncated under AutoGen (12.6). GLM-5.3 Flash and Qwen 3.8 Flash extracted every figure and avoided every trap, but missed “new guidance initiated” change between quarters. Exactly the kind of detail a 2 KB test never exercises, and why evals need to run on real documents.</blockquote><h3>Finding 2: Ensemble voting makes tool calls reliable</h3><p>In document extraction, a bad call produces a flawed report. In agentic tool use, a bad call changes real state. It can move the wrong meeting, trigger a destructive API, or stall a workflow when model replies in prose instead of calling a tool.</p><p>So ensemble votes <em>before</em> anything runs. At each step, five workers independently read the history and propose the next tool call. If at least three agree on same tool and same arguments, the call executes immediately. If they disagree, an arbitrator reviews proposals and selects safest valid call before any external API is touched.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7LeiCL7Oxb-_SQ4k3SbbA.png" /><figcaption>Pre-execution voting. No tool runs until a majority, or the arbitrator, signs off.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnrnJOZUab4M2WyojXbldQ.png" /><figcaption>Tool-use composite score by architecture. Arrows show the gain from ensemble voting for models whose single-agent runs failed.</figcaption></figure><p><strong>Ensemble voting rescued five models:</strong></p><ul><li><strong>Meta Muse Ember:</strong> a first-turn formatting failure on AutoGen (0% tool selection) and drifting date arguments on LangGraph (75%) were both fixed, reaching 100% tools and arguments (25.0 to 89.8).</li><li><strong>Llama 4 Maverick:</strong> a first-turn stall on LangGraph (0%) became 67% tool selection and 100% argument accuracy.</li><li><strong>DeepSeek V4.1 Flash:</strong> from 0% on AutoGen and 33% on LangGraph to 100% (24.6 to 92.7).</li><li><strong>gpt-oss-120b:</strong> from 0% tool selection in both single-agent setups to 100%.</li><li><strong>Gemma 4 31B:</strong> an AutoGen argument error (75%) corrected to 100%.</li></ul><p><strong>Open-weight models also led single-agent tool calling.</strong> With internal reasoning switched off, Moonshot’s Kimi K2.6 scored 97.1, the best result of any model, and finished the chain in four calls. Qwen 3.8 Flash scored 96.2 in 5.5 seconds for $0.0004. GLM-5.3 Flash and both Gemma 4 models hit 100% on tool choice, arguments and completion. For these already-excellent single agents, the ensemble scored lower (Kimi 89.3, Qwen 74.8) because the extra calls added latency and, for Qwen, argument errors.</p><blockquote>Learning: use ensemble voting where a wrong action is expensive or model’s tool formatting varies, and single agent where one is already near perfect.</blockquote><h3>Finding 3: Ensemble synthesis is faster, and evals need a better judge</h3><p>Teams rely on LLM-as-a-judge evals, so tested both architectures &amp; judges. Each first-contact plan was scored blind by a six-model panel: two legacy judges (gpt-4o-mini and Gemini 2.5 Flash) and four 2026 peer judges (Muse Ember, GPT-6 Luna, Claude Haiku 5.5 and Gemma 4 26B). The generating model also scored its own work.</p><h4>The ensemble was faster for every model family</h4><p>Because the ensemble runs its five specialists at the same time, it finished faster than LangGraph’s three sequential steps for every model family I tested, by between 19% and 47%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7tGYMQEzrAMA5OvC0u0IA.png" /><figcaption>Wall-clock time for the same synthesis task, ensemble versus LangGraph.</figcaption></figure><blockquote>2026 peer judges also rated ensemble higher than LangGraph for Muse Ember (71.4 vs 70.9), GPT-6 Luna (72.3 vs 70.3) &amp; Gemma 4 26B (54.8 vs 49.3).</blockquote><p>One eval detail is worth sharing. On Muse Ember, the ensemble had the highest pure task quality (97.5 out of 100) but ranked third on the composite score. That’s because the harness scores cost relative to the cheapest and most expensive runs in the same table. The ensemble cost $0.0036 and AutoGen cost $0.0015. That gap of two-tenths of a cent gave the ensemble a cost score of zero and cost it 7.5 composite points. <strong>When you read composite eval scores, check the absolute numbers too.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mFgCuX-bexA28BSgLuhQlQ.png" /><figcaption>Each line is one output. Legacy judges (left) scored everything between 86 and 92, including the two broken outputs. The 2026 peer panel (right) spread the same outputs from 51 to 79.</figcaption></figure><p>The legacy panel gave <strong>92</strong> to a plan that omitted the required JSON block entirely, and <strong>86</strong> to one that was cut off mid-JSON. Its scores barely moved, whatever the quality.</p><p>The 2026 peer panel separated good work from broken work. It also changed how the models’ self-assessment looked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mymud50ZaatNKm8aoHT5BA.png" /><figcaption>Self-bias: the model’s score for its own output minus the judge panel’s score. Gray is measured against the legacy judges; color is measured against the 2026 peer judges.</figcaption></figure><p>Muse Ember, GPT-6 Luna and Claude Haiku 5.5 graded their own work within about five points of their peers. Gemma 4 26B rated its own output 35 to 38 points higher than its peers did, and Gemini 2.5 Flash rated its own 22 to 33 points higher. The legacy judge’s flat scoring had hidden that gap completely.</p><p><em>The eval rule I follow: </em><strong><em>use a multi-lab panel of reasoning-capable judges, never let the generating model grade alone, and put most of the weight on deterministic </em>checks.</strong></p><h3>Finding 4: Production lessons for parallel orchestration</h3><p>Running 149 multi-agent workflows on OpenRouter taught me three practical lessons.</p><p><strong>1. Control reasoning tokens explicitly.</strong> My first call to Muse Ember, with a 200-token limit, returned a successful response with no content. The model had spent 210 reasoning tokens before writing anything visible. NVIDIA’s Nemotron 3 Ultra used its entire 3,900-token budget the same way. In 2026, models accept one of two control settings:</p><pre># Effort control: Muse Ember, GPT-6 Luna, gpt-oss-120b, Claude Haiku 5.5, Mistral Large 4<br>&quot;reasoning&quot;: {&quot;effort&quot;: &quot;low&quot;}<br><br># On/off switch: Kimi K2.6, Qwen 3.8 Flash<br>&quot;reasoning&quot;: {&quot;enabled&quot;: false}</pre><p><em>Low effort on Muse Ember cut cost by 3.7 times and eliminated the empty responses. Turning reasoning off on Kimi K2.6 cut a single call from 23.9 seconds to 0.9 seconds, 26 t</em>imes faster, and made it the top tool caller.</p><p><strong>2. Set token limits for parallel calls.</strong> If you don’t set a limit, OpenRouter reserves each request’s full 65,536-token output window, about $0.033, against your credit. A five-agent ensemble reserves five of those at once ($0.16), which can trigger “insufficient credit” errors on a run that actually costs $0.0036. A 1,300-token limit cut the reservation by about 50 times.</p><p><strong>3. Add retries to parallel workers.</strong> A six-step voting loop makes 30 model calls per run, five at a time, and occasionally hit transient gateway errors. Per-worker retries with exponential backoff brought tool-use completion in the ensemble to 100%.</p><h3>When to use the ensemble</h3><ul><li><strong>High-stakes tool calls:</strong> yes. Voting rescued Muse Ember, Llama 4 Maverick, DeepSeek V4.1 Flash, gpt-oss-120b and Gemma 4 31B.</li><li><strong>Open-ended synthesis:</strong> yes. It was 19% to 47% faster than LangGraph and rated as high or higher by the 2026 judges.</li><li><strong>Filtering hallucinated changes:</strong> yes. It lifted Llama 4 Maverick’s change detection from 33% to 100% on real filings.</li><li><strong>Long-document extraction:</strong> use LangGraph’s Python merge, or a dense model such as Gemma 4 31B as the ensemble’s synthesizer.</li><li><strong>Models that are already near-perfect single agents</strong> (Kimi K2.6, Qwen 3.8 Flash): a single agent is faster and scored higher.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qui3yZenZT2MFRjqOblIBw.png" /><figcaption>Choose the orchestration by failure mode, then the model.</figcaption></figure><ul><li><strong>Long, multi-document extraction:</strong> <strong>stateful graph</strong>. Muse Ember (99.7), Claude Haiku 5.5 (99.3), Gemma 4 26B (99.9) or gpt-oss-120b (99.7).</li><li><strong>Extraction under any architecture:</strong> Muse Ember, GPT-6 Luna or gpt-oss-120b, which were perfect in all three. For a Gemma 4 ensemble, use the dense 31B.</li><li><strong>High-stakes, multi-step tool execution:</strong> <strong>ensemble voting</strong>. GLM-5.3 Flash (94.3), Gemma 4 31B (93.5), DeepSeek V4.1 Flash (92.7) or Muse Ember (89.8).</li><li><strong>Fast single-agent tool loops:</strong> <strong>graph or review loop</strong>, with reasoning off. Kimi K2.6 (97.1) or Qwen 3.8 Flash (96.2).</li><li><strong>Open-ended, multi-domain synthesis:</strong> <strong>parallel ensemble</strong>, with Muse Ember or GPT-6 Luna.</li><li><strong>LLM-as-a-judge evals:</strong> a <strong>multi-lab panel of reasoning models</strong>, plus deterministic checks carrying at least half the weight.</li></ul><h3>Open source: reproduce it, extend it, build on it</h3><p>Everything in this study is open source including the four benchmarks, ensemble runners, harness changes and raw per-run logs. I will create merge request contributing the parallel ensemble to SmartWrapperOSS, so it can become a standard architecture in framework for everyone. My fork’s branch (linked below) has everything you need to reproduce these results today. These results cover three architectures and four enterprise-style workflows. Fastest way to find out what holds for your domain is to run the harness on your own documents, and comment your findings.</p><p>A big thank you to <a href="https://medium.com/u/9cb527e4e850">Aditi Jain</a> for creating SmartWrapperOSS. A clean, deterministic eval harness is what made a controlled comparison like this possible, and it’s a great example of how open-source tooling moves the whole field forward.</p><ul><li>Harness, ensemble runners, benchmarks and logs: <a href="https://github.com/sakshamaggarwal/SmartWrapperOSS/tree/exp/muse-ensemble-langgraph">github.com/sakshamaggarwal/SmartWrapperOSS</a></li><li>Ember Swarm: <a href="https://github.com/sakshamaggarwal/ember-swarm">github.com/sakshamaggarwal/ember-swarm</a></li></ul><blockquote>Add your architecture -&gt; Add your benchmark -&gt; Add your model -&gt; Share your results</blockquote><blockquote>Models will keep getting better, and they will keep getting cheaper and more widely available. The durable advantage is in what you build around them</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a225717dc55a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OCPI and OCPP Protocols: Driving the Future of Electric Vehicle Charging]]></title>
            <link>https://medium.com/@mani.saksham12/ocpi-and-ocpp-protocols-driving-the-future-of-electric-vehicle-charging-b02f0cfab19d?source=rss-6892c257514c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b02f0cfab19d</guid>
            <category><![CDATA[ev-charging]]></category>
            <category><![CDATA[electric-vehicles]]></category>
            <category><![CDATA[ocpp]]></category>
            <category><![CDATA[ev-charger]]></category>
            <category><![CDATA[electric-car]]></category>
            <dc:creator><![CDATA[Saksham]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 21:35:51 GMT</pubDate>
            <atom:updated>2024-12-02T21:35:51.680Z</atom:updated>
            <content:encoded><![CDATA[<p>The rapid adoption of electric vehicles (EVs) has led to an increased demand for robust and standardized charging infrastructure. Two key components that play pivotal roles in the EV charging ecosystem are OCPI (Open Charge Point Interface) and OCPP (Open Charge Point Protocol). These protocols serve distinct yet complementary functions, working together to create a seamless and efficient charging experience for EV users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*fcfoTrzrtoCZh0DIXNHIqg.jpeg" /></figure><h4>OCPI: Facilitating Interoperability &amp; Enabling Seamless Roaming</h4><p>OCPI, or Open Charge Point Interface, is a protocol designed to foster interoperability among various EV charging networks and service providers. Its primary objective is to enable EV drivers to use charging stations from different networks using a single account or payment method. This is often referred to as “roaming.”</p><p>Roaming Simplified: Imagine driving an electric vehicle from one city to another, crossing multiple regions and jurisdictions. OCPI facilitates this journey by providing a standardized language for communication between different charging networks. It allows EV drivers to seamlessly locate, access, and pay for charging services regardless of the network operator.</p><p><em>Key Features of OCPI:</em></p><blockquote>1. Location and Availability Information: OCPI provides real-time data about the location and availability of charging stations, allowing EV users to make informed decisions about where to charge.</blockquote><blockquote>2. Pricing Transparency: It ensures transparency in pricing, enabling users to understand the cost of charging before initiating a session.</blockquote><blockquote>3. Authentication and Authorization: OCPI establishes secure methods for user authentication and authorization, ensuring that only authorized individuals can access charging services.</blockquote><p><em>Key Components of OCPI:</em></p><ol><li>JSON-RPC Communication:</li></ol><p>OCPI relies on JSON-RPC (Remote Procedure Call) as its communication protocol. This enables the exchange of messages between different charging networks, allowing operations like querying available charging stations and initiating charging sessions. JSON-RPC provides a lightweight and efficient method for information exchange.</p><ul><li>Request and Response: JSON-RPC operates on a request-response model. A component, such as a charging station, can send a JSON-formatted request to another component, like a central management system (CMS).</li><li>Standardized Messages: These messages contain information about operations to be performed, like querying the status of a charging station or initiating a charging session.</li><li>Efficient Data Transfer: JSON (JavaScript Object Notation) is a lightweight data-interchange format. It’s human-readable and easy to parse, making it an efficient choice for data transfer in OCPI.</li></ul><pre>{<br>  &quot;jsonrpc&quot;: &quot;2.0&quot;,<br>  &quot;id&quot;: 1,<br>  &quot;method&quot;: &quot;GET&quot;,<br>  &quot;url&quot;: &quot;locations&quot;,<br>  &quot;params&quot;: {<br>    &quot;date_from&quot;: &quot;2023-01-01T00:00:00Z&quot;,<br>    &quot;date_to&quot;: &quot;2023-01-02T23:59:59Z&quot;<br>  }<br>}</pre><p>In this example, a JSON-RPC message is constructed to request information about charging locations for a specific date range.</p><p>2. OAuth 2.0 for Secure Access:</p><p>OCPI employs OAuth 2.0, a widely adopted industry-standard protocol, for secure authorization. This ensures that only authorized parties can access the charging services. By obtaining an access token, the system verifies the authenticity of users, enhancing security.</p><p>It’s a widely adopted protocol used to grant limited access to resources without exposing credentials.</p><ul><li>Authorization and Token: When a user or system wants to access OCPI services, they initiate an OAuth 2.0 flow. This involves obtaining an access token from the authorization server.</li><li>The user or system initiates the OAuth 2.0 flow by sending a request to the authorization server.</li><li>This request includes information like client credentials (client ID and client secret), the desired scope of access, and a redirect URI.</li><li>The server validates this request and responds with an authorization code.</li></ul><pre>import requests<br><br>authorization_url = &#39;https://ocpi-authorization-server.com/authorize&#39;<br><br>response_type = &#39;code&#39;<br>client_id = &#39;your_client_id&#39;<br>redirect_uri = &#39;https://your_redirect_uri.com&#39;<br>scope = &#39;desired_scope&#39;<br><br>authorization_url += f&#39;?response_type={response_type}&amp;client_id={client_id}&amp;redirect_uri={redirect_uri}&amp;scope={scope}&#39;<br><br>response = requests.get(authorization_url)</pre><ul><li>Access Token Usage: The requester then exchanges the authorization code for an access token by sending a POST request to the token endpoint of the authorization server.</li><li>The server validates the code and, if valid, responds with an access token.</li></ul><pre>token_url = &#39;https://ocpi-authorization-server.com/token&#39;<br><br>code = &#39;authorization_code_received_from_previous_step&#39;<br><br>payload = {<br>    &#39;grant_type&#39;: &#39;authorization_code&#39;,<br>    &#39;code&#39;: code,<br>    &#39;redirect_uri&#39;: &#39;https://your_redirect_uri.com&#39;,<br>    &#39;client_id&#39;: &#39;your_client_id&#39;,<br>    &#39;client_secret&#39;: &#39;your_client_secret&#39;<br>}<br><br>response = requests.post(token_url, data=payload)<br>access_token = response.json()[&#39;access_token&#39;]</pre><p>3. RESTful API Architecture:</p><p>OCPI follows a RESTful architectural style, defining clear and standardized endpoints for various functionalities. For example, the /locations endpoint retrieves a list of available charging locations. This adherence to RESTful principles ensures simplicity, scalability, and ease of integration.</p><h4>OCPP: Streamlining Charging Infrastructure Management</h4><p>While OCPI focuses on the interaction between EV drivers and charging networks, OCPP, or Open Charge Point Protocol, serves a different purpose. It is the language spoken between the charging stations (charge points) and the central management system (CMS) or back-office system.</p><p>Remote Monitoring and Control</p><p>OCPP enables the remote monitoring and control of charging stations, allowing operators to efficiently manage their charging infrastructure. With OCPP, operators can start and stop charging sessions, collect data on energy consumption, monitor station health, and even perform firmware updates on the charging equipment.</p><p><em>Key Features of OCPP:</em></p><blockquote>1. Real-time Status Updates: OCPP provides real-time information about the status of charging stations, allowing operators to monitor usage and address any issues promptly.</blockquote><blockquote>2. Load Management: It enables operators to manage the load on the grid by dynamically adjusting charging rates and schedules based on demand.</blockquote><blockquote>3. Firmware Updates: OCPP supports the remote installation of firmware updates, ensuring that charging stations remain up-to-date with the latest software enhancements.</blockquote><p><em>Key Components of OCPP:</em></p><ol><li>WebSocket Communication:</li></ol><p>OCPP predominantly employs WebSocket as its transport protocol. This facilitates full-duplex communication between the charging station and the central system, allowing for real-time updates and control. WebSockets offer low-latency and high-performance communication, crucial for managing dynamic charging environments.</p><pre>// Example JavaScript code for establishing a WebSocket connection in a charging station<br><br>const WebSocket = require(&#39;ws&#39;);<br><br>const chargingStationUrl = &#39;wss://ocpp-central-system.com/ocpp&#39;;<br>const chargePointId = &#39;CP001&#39;;<br><br>const ws = new WebSocket(chargingStationUrl);<br><br>ws.on(&#39;open&#39;, () =&gt; {<br>  console.log(`Connected to central system at ${chargingStationUrl}`);<br>  <br>  // Register the charge point with the central system<br>  ws.send(JSON.stringify({<br>    type: &#39;BootNotification&#39;,<br>    chargePoint: chargePointId,<br>  }));<br>});<br><br>ws.on(&#39;message&#39;, (message) =&gt; {<br>  const parsedMessage = JSON.parse(message);<br>  <br>  // Handle incoming messages from the central system<br>  if (parsedMessage.type === &#39;BootNotificationResponse&#39;) {<br>    console.log(`Charge point ${chargePointId} registered successfully.`);<br>  } else {<br>    // Handle other types of messages<br>  }<br>});</pre><blockquote>The code starts by importing the WebSocket library (require(&#39;ws&#39;)), assuming this is JavaScript code running in a Node.js environment.</blockquote><blockquote>The chargingStationUrl variable is set to the WebSocket URL of the central system.</blockquote><blockquote>The chargePointId variable identifies the specific charge point (in this case, it&#39;s set to &#39;CP001&#39;).</blockquote><blockquote>A new WebSocket connection (ws) is created using the WebSocket class and pointed to the chargingStationUrl.</blockquote><blockquote>The ws.on(&#39;open&#39;, ...) event handler triggers when the WebSocket connection is successfully established. It logs a message indicating the successful connection.</blockquote><blockquote>Inside the open event handler, a message of type &#39;BootNotification&#39; is sent to the central system. This is a standard OCPP message for registering the charge point.</blockquote><blockquote>The ws.on(&#39;message&#39;, ...) event handler listens for incoming messages from the central system.</blockquote><blockquote>When a message is received, it’s parsed into a JavaScript object (parsedMessage).</blockquote><blockquote>The code checks if the message type is &#39;BootNotificationResponse&#39; (indicating a successful registration of the charge point) and logs a corresponding message.</blockquote><p>2. Central System Commands:</p><p>OCPP defines a comprehensive set of commands that can be sent from the central system to the charge point. For instance, the StartTransaction command initiates a new charging session. This two-way communication ensures seamless coordination between the central system and the charge points.</p><pre>// Example JavaScript code for handling a StartTransaction command in a charge point<br><br>ws.on(&#39;message&#39;, (message) =&gt; {<br>  const parsedMessage = JSON.parse(message);<br>  <br>  if (parsedMessage.type === &#39;StartTransaction&#39;) {<br>    const { connectorId, idTag, meterStart } = parsedMessage;<br>    <br>    // Perform actions to start a new charging session<br>    const transactionId = 123; // Replace with actual transaction ID<br>    <br>    // Send a response back to the central system<br>    ws.send(JSON.stringify({<br>      type: &#39;StartTransactionResponse&#39;,<br>      transactionId,<br>      status: &#39;Accepted&#39;,<br>    }));<br>  } else {<br>    // Handle other types of messages<br>  }<br>});</pre><blockquote>Inside the ws.on(&#39;message&#39;, ...) event handler, the received message is parsed into a JavaScript object (parsedMessage).</blockquote><blockquote>The code checks if the message type is &#39;StartTransaction&#39;, which is a standard OCPP command for initiating a new charging session.</blockquote><blockquote>If the message type is &#39;StartTransaction&#39;, the code extracts relevant information like connectorId, idTag, and meterStart.</blockquote><blockquote>The charge point then performs the necessary actions to start a new charging session. For simplicity, it assigns a fictional transactionId (123) and assumes that the transaction is accepted.</blockquote><blockquote>Finally, a response message of type &#39;StartTransactionResponse&#39; is sent back to the central system, indicating the accepted status of the transaction.</blockquote><p>3. Structured Data Transfer:</p><p>OCPP uses XML-based messages for data exchange between the charge point and the central system. This structured approach allows for organized and standardized communication. It includes vital information like charge point identity, current status, and transaction details.</p><pre>// Example XML message for reporting a meter value during a charging session<br><br>const xmlMessage = `<br>  &lt;meterValues xmlns=&quot;urn://Ocpp/Cs/2015/10/&quot; transactionId=&quot;123&quot;&gt;<br>    &lt;connectorId&gt;1&lt;/connectorId&gt;<br>    &lt;meterValue&gt;<br>      &lt;timestamp&gt;2023-10-25T14:30:00Z&lt;/timestamp&gt;<br>      &lt;value&gt;123.45&lt;/value&gt;<br>      &lt;unit&gt;kWh&lt;/unit&gt;<br>    &lt;/meterValue&gt;<br>  &lt;/meterValues&gt;<br>`;<br><br>// Send the XML message to the central system using WebSocket<br>ws.send(xmlMessage);</pre><blockquote>The xmlMessage variable contains an XML-formatted message representing meter values during a charging session.</blockquote><blockquote>The message includes elements like meterValues, connectorId, timestamp, value, and unit. These elements convey information about the charging progress.</blockquote><blockquote>The ws.send(xmlMessage) line sends the XML message to the central system through the WebSocket connection.</blockquote><p>These code examples illustrate the core functionalities of a charge point in the OCPP protocol. They cover the establishment of WebSocket communication, handling central system commands, and structured data transfer using XML messages.</p><p><strong>The Symbiotic Relationship</strong></p><p>OCPI and OCPP work hand in hand to create a seamless EV charging experience. While OCPI enables EV drivers to roam across different networks, OCPP empowers operators to efficiently manage and maintain their charging infrastructure.</p><p>Driving Towards a Connected Future: In the rapidly evolving landscape of electric vehicle charging, standardization and interoperability are key. OCPI and OCPP stand as cornerstones in this endeavor, creating a foundation for a connected, accessible, and efficient charging network. As the EV revolution accelerates, these protocols will continue to play pivotal roles in shaping the future of transportation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b02f0cfab19d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Graceful degradation in a microservice architecture using Kubernetes]]></title>
            <link>https://medium.com/@mani.saksham12/graceful-degradation-in-a-microservice-architecture-using-kubernetes-d47aa80b7d20?source=rss-6892c257514c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d47aa80b7d20</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[alerts]]></category>
            <category><![CDATA[graceful-degradation]]></category>
            <category><![CDATA[failure-injection]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Saksham]]></dc:creator>
            <pubDate>Thu, 14 Sep 2023 16:10:02 GMT</pubDate>
            <atom:updated>2023-09-14T16:10:02.376Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Microservices architecture has become a popular approach for building scalable and resilient applications. However, ensuring the reliability of microservices in dynamic environments can be challenging. One crucial aspect of this is implementing graceful degradation.</p><p>Graceful degradation allows a system to continue functioning, even when some of its components fail or are under heavy load. In a microservices context, this means that if one service experiences issues, the overall system continues to operate with reduced functionality rather than failing completely.</p><p>In this article, we will explore how to implement graceful degradation in a microservices architecture using Kubernetes, a powerful container orchestration platform.</p><h3>Implement Graceful Degradation in Kubernetes</h3><p>Implementing graceful degradation in a microservice architecture using Kubernetes involves setting up various components and configurations to handle service failures and resource constraints. Below are steps and techniques you can employ:</p><p>1. Circuit Breakers:<br> — Use libraries like Hystrix or Istio’s Circuit Breaker to implement circuit-breaking patterns in your microservices. This prevents cascading failures when a downstream service is unresponsive.</p><p>2. Resource Requests and Limits:<br> — Define appropriate resource requests and limits in your Kubernetes Deployment or Pod specifications. This ensures that each microservice gets the necessary resources and doesn’t starve others.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: sample-app<br>spec:<br>  replicas: 3<br>  template:<br>    spec:<br>      containers:<br>      - name: sample-app<br>        image: your-image:tag<br>        resources:<br>          requests:<br>            memory: &quot;64Mi&quot;<br>            cpu: &quot;250m&quot;<br>          limits:<br>            memory: &quot;128Mi&quot;<br>            cpu: &quot;500m&quot;</pre><p>Define CPU and memory requirements for each pod in your deployment. This allows Kubernetes to make informed scheduling decisions and ensure that each pod gets the necessary resources.</p><p>Here, we request a minimum of 64MiB memory and 250 milliCPU (one-quarter of a CPU core) for the pod, with a maximum limit of 128MiB memory and 500 milliCPU. These settings help Kubernetes schedule pods effectively and allocate resources as needed.</p><p>3. Horizontal Pod Autoscaling (HPA):<br> — Set up Horizontal Pod Autoscaling to automatically adjust the number of pods in a deployment based on observed CPU utilization or other custom metrics. This helps handle increased loads.</p><pre>apiVersion: autoscaling/v1<br>kind: HorizontalPodAutoscaler<br>metadata:<br>  name: myhpa<br>spec:<br>  scaleTargetRef:<br>    apiVersion: apps/v1<br>    kind: Deployment<br>    name: mydeployment<br>  minReplicas: 2<br>  maxReplicas: 5<br>  targetCPUUtilizationPercentage: 80</pre><p>This YAML code configures Horizontal Pod Autoscaling (HPA) for a deployment named mydeployment. It sets the minimum and maximum number of replicas and the target CPU utilization. When CPU usage exceeds 80%, HPA will increase pod replicas up to a maximum of 5.</p><p>4. Pod Disruption Budgets (PDB):<br> — Implement PodDisruptionBudgets to specify how many pods of a service can be down simultaneously during maintenance or disruptions. This prevents accidental overloads during updates.</p><pre>apiVersion: policy/v1beta1<br>kind: PodDisruptionBudget<br>metadata:<br>  name: mypdb<br>spec:<br>  maxUnavailable: 1<br>  selector:<br>    matchLabels:<br>      app: myapp</pre><p>In this example, we limit the maximum number of unavailable pods to 1. It prevents excessive disruptions to your microservices, maintaining overall stability.</p><p>5. Service Mesh(Istio):<br> — Utilize a service mesh like Istio or Linkerd to manage communication between microservices. Service meshes offer features like circuit breaking, retries, timeouts, and fault injection, which aid in graceful degradation.</p><p>Here’s an example of how you might utilize Istio, a popular service mesh, to manage communication between microservices and implement features like circuit breaking:</p><pre>apiVersion: networking.istio.io/v1alpha3<br>kind: DestinationRule<br>metadata:<br>  name: myapp-destination<br>spec:<br>  host: myapp-service.default.svc.cluster.local<br>  trafficPolicy:<br>    connectionPool:<br>      http:<br>        http1MaxPendingRequests: 1<br>        maxRequestsPerConnection: 1</pre><p>Explanation:</p><blockquote>apiVersion and kind: These fields specify the API version and kind of resource we are defining. In this case, it&#39;s a DestinationRule in Istio.</blockquote><blockquote>metadata: This section allows you to provide metadata about the resource, like its name.</blockquote><blockquote>spec: This is where we define the specifics of the DestinationRule.</blockquote><blockquote>host: Here, you specify the hostname of the microservice you&#39;re configuring. This should match the name of your microservice.</blockquote><blockquote>trafficPolicy: This section allows you to specify policies related to traffic for this microservice.</blockquote><blockquote>connectionPool: This is a sub-section that configures connection pooling for HTTP requests.</blockquote><blockquote>http: This sub-section is specific to HTTP connections.</blockquote><blockquote>http1MaxPendingRequests: This field sets the maximum number of pending requests to 1. This can be used to implement circuit breaking, as it limits the number of requests that can be pending at a time.</blockquote><blockquote>maxRequestsPerConnection: This field sets the maximum number of requests that can be made on a single connection. This can also be used to implement circuit breaking by limiting the number of requests a single connection can handle.</blockquote><p>This example demonstrates how you can use Istio to implement circuit breaking by configuring connection pooling for a specific microservice. Istio provides a rich set of features, and this is just a small example of how you can leverage it for graceful degradation in a microservice architecture. Keep in mind that you’ll need to have Istio installed in your Kubernetes cluster for this to work.</p><p>6. Readiness and Liveness Probes:<br> — Define appropriate readiness and liveness probes in your Pod specifications. These probes ensure that Kubernetes knows when a microservice is ready to receive traffic and when it’s healthy.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: mypod<br>spec:<br>  containers:<br>  - name: mycontainer<br>    image: myimage<br>    readinessProbe:<br>      httpGet:<br>        path: /health<br>        port: 80<br>      initialDelaySeconds: 5<br>      periodSeconds: 10<br>    livenessProbe:<br>      exec:<br>        command:<br>        - /bin/sh<br>        - -c<br>        - ps aux | grep myprocess<br>      initialDelaySeconds: 15<br>      periodSeconds: 20</pre><p>This YAML code defines a pod with readiness and liveness probes. The readiness probe checks if the pod is ready to serve traffic by sending an HTTP GET request to /health. The liveness probe checks if the process is running by executing a command.</p><p>7. Quality of Service (QoS) Classes:<br> — Use Kubernetes Quality of Service classes to prioritize resources for certain pods. This helps ensure critical services get the resources they need during resource contention.</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: mypod<br>spec:<br>  containers:<br>  - name: mycontainer<br>    image: myimage<br>    resources:<br>      requests:<br>        memory: &quot;64Mi&quot;<br>        cpu: &quot;250m&quot;<br>    qosClass: Guaranteed</pre><p>Here, we assign the Guaranteed QoS class to ensure that this critical pod gets priority access to resources.</p><p>8. Priority Classes:<br> — Assign priority classes to pods to influence scheduling decisions. Higher-priority pods will be scheduled first, ensuring critical services get resources during resource constraints.</p><p>9. Pod Anti-Affinity:<br> — Configure Pod Anti-Affinity to prevent pods from being scheduled on the same node, ensuring that services are distributed across the cluster and reducing the impact of node failures.</p><p>This is particularly useful for improving the resilience and availability of your services. Here’s how you can implement Pod Anti-Affinity:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: my-deployment<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: my-app<br>  template:<br>    metadata:<br>      labels:<br>        app: my-app<br>    spec:<br>      affinity:<br>        podAntiAffinity:<br>          requiredDuringSchedulingIgnoredDuringExecution:<br>            - labelSelector:<br>                matchExpressions:<br>                  - key: app<br>                    operator: In<br>                    values:<br>                      - my-app<br>              topologyKey: kubernetes.io/hostname<br>      containers:<br>        - name: my-container<br>          image: my-image</pre><p>Explanation:</p><blockquote>affinity: This is where you define the scheduling preferences for your pods.</blockquote><blockquote>podAntiAffinity: Indicates that you&#39;re setting a rule for pod anti-affinity.</blockquote><blockquote>requiredDuringSchedulingIgnoredDuringExecution: This specifies that the anti-affinity rule must be met during scheduling, but it&#39;s not enforced during execution (meaning, if nodes are limited and pods need to be placed together, Kubernetes will do so, but will avoid scheduling additional pods together).</blockquote><blockquote>labelSelector: Defines the label that Kubernetes should look at. In this case, it&#39;s looking for pods with the label app: my-app.</blockquote><blockquote>topologyKey: Specifies the key that Kubernetes should use to identify the topology. In this example, it&#39;s using the node&#39;s hostname.</blockquote><p>In this example, we’re saying that pods of the same app (my-app) should not be scheduled on the same node. This helps distribute the load across the cluster and ensures that if a node goes down, it doesn&#39;t take all instances of your service with it.</p><p>Remember to replace my-app and my-image with your actual app and image names. This YAML can be applied using kubectl apply -f &lt;filename&gt;.yaml.</p><p>This configuration ensures that Kubernetes will try to spread out the pods of my-app across different nodes in your cluster. This enhances availability and resilience by minimizing the impact of node failures.</p><p>10. Custom Metrics and Autoscaling:<br> — Implement custom metrics using tools like Prometheus and Grafana. Configure custom Horizontal Pod Autoscalers to scale based on these metrics.</p><p>11. Graceful Shutdown:<br> — Ensure that your microservices handle SIGTERM signals gracefully. Kubernetes sends a SIGTERM before terminating a pod. Use this signal to allow a microservice to finish processing before shutting down. The microservice should catch this signal and perform any necessary cleanup before shutting down.</p><p>Below is an example in Python:</p><pre>import signal<br>import sys<br>import time<br><br># Define a function to handle SIGTERM<br>def sigterm_handler(signal, frame):<br>    print(&quot;Received SIGTERM signal. Performing cleanup...&quot;)<br>    <br>    # Perform cleanup tasks here<br>    # For example, close database connections, release resources, etc.<br>    <br>    print(&quot;Cleanup complete. Exiting...&quot;)<br>    sys.exit(0)<br><br># Register the SIGTERM handler<br>signal.signal(signal.SIGTERM, sigterm_handler)<br><br># Simulate the microservice doing some work<br>while True:<br>    print(&quot;Microservice is running...&quot;)<br>    time.sleep(5)</pre><p>Explanation:</p><blockquote>The signal module is imported to handle signals.</blockquote><blockquote>We define a sigterm_handler function that will be called when a SIGTERM signal is received.</blockquote><blockquote>In the handler function, you should perform any necessary cleanup tasks (e.g., closing connections, releasing resources).</blockquote><blockquote>Finally, the signal.signal function is used to register the handler for SIGTERM.</blockquote><p>When the microservice is running, it will print “Microservice is running…” every 5 seconds. If a SIGTERM signal is received (e.g., when Kubernetes decides to terminate the pod), the sigterm_handler function will be called, performing cleanup tasks before exiting.</p><p>Remember to adapt this code to your specific microservice and programming language. The key is to capture the SIGTERM signal and perform any required cleanup tasks before allowing the microservice to shut down gracefully.</p><p>12. Failure Injection:<br> — Use chaos engineering tools like Chaos Mesh or Litmus to inject failures into your microservices. This helps you observe how your system behaves under various failure scenarios.</p><p>Failures can take various forms, such as:</p><ul><li>Network Latency: Introducing artificial delays in network communication.</li><li>Packet Loss: Simulating dropped or delayed packets.</li><li>Pod Kill: Forcibly terminating pods.</li><li>Node Failure: Simulating the failure of an entire node.</li><li>CPU/Memory Hogging: Consuming excessive resources.</li></ul><p>Example : <br>For this example, we’ll use Chaos Mesh to inject failures into a microservice.</p><p>Install Chaos Mesh:</p><pre>kubectl apply -f https://mirrors.chaos-mesh.org/v1.3.0/crds.yaml<br>kubectl apply -f https://mirrors.chaos-mesh.org/v1.3.0/chaos-mesh.yaml</pre><p>Create a Chaos Experiment (e.g., a pod network latency experiment):</p><pre>apiVersion: chaos-mesh.org/v1alpha1<br>kind: NetworkChaos<br>metadata:<br>  name: network-latency<br>  namespace: default<br>spec:<br>  action: delay<br>  mode: one<br>  selector:<br>    podSelector:<br>      matchLabels:<br>        app: your-microservice-label<br>  duration: &quot;10s&quot;  # Duration of the delay<br>  delay:<br>    latency: &quot;100ms&quot;  # Amount of latency to inject</pre><p>This Chaos Experiment will inject a network latency of 100ms to pods labeled with app: your-microservice-label</p><p>Failure Injection is a practice used to intentionally introduce failures or faults into a system to test its resilience and ability to handle unexpected situations. In the context of microservices and Kubernetes, this helps teams identify weaknesses in their applications and infrastructure, allowing them to implement mitigations and safeguards.</p><p>When injecting network latency using a tool like Chaos Mesh, there are several parameters you can monitor to assess the impact on your system. Some of the key parameters to observe include:</p><blockquote>a. Increased Response Times:<br> — Possible Error: The microservice is taking longer than usual to process requests.<br> — Rectification: Optimize the code, improve database queries, and ensure that external dependencies are responding promptly.</blockquote><blockquote>b. Higher Error Rates:<br> — Possible Error: More requests are failing due to the added latency.<br> — Rectification: Check error logs for specific error messages. Address the root cause, which could be related to network issues or overloaded resources.</blockquote><blockquote>c. Reduced Throughput:<br> — Possible Error: The system’s capacity to handle requests has decreased.<br> — Rectification: Scale your microservices horizontally to distribute the load or optimize the code for better performance.</blockquote><blockquote>d. Increased Resource Utilization:<br> — Possible Error: The system is using more CPU, memory, or network resources.<br> — Rectification: Investigate memory leaks, optimize resource-intensive operations, or consider upgrading the underlying infrastructure.</blockquote><blockquote>e. Altered Latency Distribution:<br> — Possible Error: The distribution of latencies has shifted, potentially impacting high-percentile response times.<br> — Rectification: Analyze which components are most affected and optimize them. Look for any bottlenecks that might be causing delays.</blockquote><blockquote>f. Growing Request Queues:<br> — Possible Error: Requests are piling up, indicating that the system is struggling to keep up.<br> — Rectification: Scale your microservices horizontally or vertically, or optimize the code to handle incoming requests more efficiently.</blockquote><blockquote>g. Disrupted Service Dependencies:<br> — Possible Error: Dependencies are failing due to added latency.<br> — Rectification: Identify and resolve issues with service-to-service communication. Consider implementing retry logic or circuit breakers.</blockquote><blockquote>h. Application Logs Indicating Errors:<br> — Possible Error: Detailed logs show specific errors or issues related to network interactions.<br> — Rectification: Investigate the error messages and address the underlying causes, which may include network timeouts, connection failures, or data format mismatches.</blockquote><blockquote>i. Poor User Experience:<br> — Possible Error: End-users are experiencing slower response times or other usability issues.<br> — Rectification: Optimize frontend code, implement client-side caching, or consider using techniques like lazy loading to improve the user experience.</blockquote><blockquote>j. Database Performance Degradation:<br> —Possible Error: Database interactions are slower due to added latency.<br> — Rectification: Optimize database queries, ensure indexes are used effectively, and consider caching frequently accessed data.</blockquote><p>Remember that each of these issues may have specific root causes, so thorough investigation and analysis are crucial for effective rectification. Additionally, consider implementing automated monitoring and alerting systems to detect and respond to these issues in real-time.</p><h3>Setting up Monitoring and Alerting with Prometheus and Alertmanager</h3><h4>Step 1: Install Prometheus</h4><ol><li>Apply the Prometheus manifests to your Kubernetes cluster:</li></ol><pre>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/alertmanager.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/prometheus.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/prometheusrule.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/servicemonitor.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/podmonitor.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/thanosruler.crd.yaml<br><br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/bundle.yaml</pre><ol><li>Create a namespace for Prometheus:</li></ol><pre>kubectl create namespace monitoring</pre><ol><li>Deploy Prometheus Operator:</li></ol><pre>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-deployment.yaml</pre><ol><li>Deploy a simple Prometheus instance:</li></ol><pre>apiVersion: monitoring.coreos.com/v1<br>kind: Prometheus<br>metadata:<br>  name: example<br>spec:<br>  replicas: 1<br>  serviceAccountName: prometheus-k8s<br>  serviceMonitorSelector:<br>    matchLabels:<br>      team: frontend<br>  resources:<br>    requests:<br>      memory: &quot;400Mi&quot;<br>  alerting:<br>    alertmanagers:<br>    - name: alertmanager-main<br>      namespace: monitoring<br>      port: web</pre><p>Apply this YAML using kubectl apply -f prometheus.yaml.</p><h4>Step 2: Set Up Alert Rules</h4><p>Create a PrometheusRule to define alerting rules:</p><pre>apiVersion: monitoring.coreos.com/v1<br>kind: PrometheusRule<br>metadata:<br>  name: alert-rules<br>  namespace: monitoring<br>spec:<br>  groups:<br>  - name: example<br>    rules:<br>    - alert: HighRequestLatency<br>      expr: job:request_latency_seconds:mean5m{job=&quot;api&quot;} &gt; 0.5<br>      for: 10m<br>      labels:<br>        severity: page<br>      annotations:<br>        summary: High request latency</pre><p>Apply this YAML using kubectl apply -f alert-rules.yaml.</p><h4>Step 3: Install Alertmanager</h4><ol><li>Apply the Alertmanager manifests:</li></ol><pre>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/alertmanager.crd.yaml<br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/example/prometheus-operator-crd/alertmanagerconfig.crd.yaml<br><br>kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/release-0.44/bundle.yaml</pre><ol><li>Create a namespace for Alertmanager:</li></ol><pre>kubectl create namespace alertmanager</pre><ol><li>Deploy Alertmanager:</li></ol><pre>kubectl create namespace alertmanager</pre><h4>Step 4: Set Up Alerting Routes</h4><p>Create an AlertmanagerConfig to configure alert routing:</p><pre>apiVersion: monitoring.coreos.com/v1<br>kind: AlertmanagerConfig<br>metadata:<br>  name: alertmanager-config<br>  namespace: alertmanager<br>spec:<br>  receivers:<br>  - name: null<br>  route:<br>    receiver: null<br>    routes:<br>    - match:<br>        alertname: Watchdog<br>      receiver: null<br>    group_by: [&#39;alertname&#39;, &#39;cluster&#39;, &#39;service&#39;]<br>    group_wait: 30s<br>    group_interval: 5m<br>    repeat_interval: 12h</pre><p>Apply this YAML using kubectl apply -f alertmanager-config.yaml.</p><h4>Step 5: Triggering and Handling Alerts</h4><p>In your application, introduce a condition that may trigger the “HighRequestLatency” alert. When this condition is met, Prometheus will evaluate the alerting rules, and if the condition persists, it will send an alert to Alertmanager.</p><p>Alertmanager will then route the alert based on the configuration defined in alertmanager-config.yaml. For example, if the alert&#39;s severity is &quot;page&quot;, Alertmanager can be configured to send a notification to a specific Slack channel, email, or any other supported receiver.</p><p>Explanation:</p><blockquote>Prometheus is responsible for collecting metrics and evaluating rules to generate alerts.</blockquote><blockquote>Alertmanager handles the routing and sending of alerts to various integrations.</blockquote><blockquote>Alert rules are defined in PrometheusRule objects.</blockquote><blockquote>Alert routing configuration is defined in AlertmanagerConfig objects.</blockquote><blockquote>This setup ensures that when an alert condition is met, the relevant stakeholders are promptly notified through their chosen communication channels. Remember to adapt the setup to your specific use case and integrate with your preferred notification services.</blockquote><p>Each microservice may have specific requirements and dependencies, so tailor these strategies to fit the characteristics of your services.</p><h3>Conclusion</h3><p>Implementing graceful degradation in a microservices architecture using Kubernetes is crucial for building resilient and reliable applications. By following the steps outlined in this article, you can create a system that adapts to different levels of service availability, ensuring uninterrupted core functionality even in the face of failures or high loads.</p><p>Remember, graceful degradation is an ongoing process that requires continuous monitoring and refinement. Regularly review and update your strategies to meet the evolving demands of your application. With the right practices in place, you can build microservices that deliver a seamless experience to users under any circumstances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ymOAxikiXWq8zoGbn7xAAA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d47aa80b7d20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Raft and Paxos : Consensus Algorithms for Distributed Systems]]></title>
            <link>https://medium.com/@mani.saksham12/raft-and-paxos-consensus-algorithms-for-distributed-systems-138cd7c2d35a?source=rss-6892c257514c------2</link>
            <guid isPermaLink="false">https://medium.com/p/138cd7c2d35a</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[paxos-and-raft]]></category>
            <category><![CDATA[data-consistency]]></category>
            <category><![CDATA[consensus-algorithm]]></category>
            <category><![CDATA[fault-tolerance]]></category>
            <dc:creator><![CDATA[Saksham]]></dc:creator>
            <pubDate>Mon, 07 Aug 2023 16:41:25 GMT</pubDate>
            <atom:updated>2023-08-07T16:41:25.927Z</atom:updated>
            <content:encoded><![CDATA[<h3>Raft and Paxos : Consensus Algorithms for Distributed Systems</h3><p>Consensus algorithms play a crucial role in ensuring data consistency and fault tolerance in distributed systems. Two of the most widely known consensus algorithms are Raft and Paxos.</p><p>The Need for Consensus Algorithms : In distributed systems, multiple nodes work together to maintain data consistency and provide fault tolerance. However, nodes can experience failures, network delays, and partitions, which can lead to data inconsistencies. Consensus algorithms are designed to address these challenges and enable a group of nodes to agree on a single value or sequence of operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*xwmgtPXTk7oSXnM1x0gIfg.png" /><figcaption>Consensus Algorithm in Distributed System</figcaption></figure><p>The main features of consensus algorithms in distributed systems include:</p><p>1. Agreement: Consensus algorithms aim to achieve agreement among a group of nodes regarding a single value or a sequence of operations. All nodes in the system should eventually agree on the same decision.</p><p>2. Fault Tolerance: Consensus algorithms are designed to handle node failures, communication delays, and network partitions. They ensure that the system can continue to make progress even in the presence of failures.</p><p>3. Safety: Consensus algorithms ensure safety by guaranteeing that only one value or decision is agreed upon. Conflicting decisions are prevented to maintain data consistency.</p><p>4. Liveness: Liveness ensures that the system can make progress and continue to agree on new values or decisions even in the absence of failures.</p><p>5. Quorum: Many consensus algorithms require a quorum, which is a majority of nodes, to agree on a value before it is accepted or committed. This helps ensure that enough nodes have seen and accepted the value.</p><p>6. Two-Phase Approach: Most consensus algorithms follow a two-phase approach, where proposals are first prepared and then accepted. This reduces the likelihood of conflicts and ensures safety.</p><p>7. Leader-Based or Leaderless: Some consensus algorithms use a leader-based approach, where a designated leader coordinates the consensus process, while others are leaderless, where nodes work collaboratively to achieve consensus.</p><p>8. Message Exchange: Nodes communicate with each other by exchanging messages to propose values, vote, and inform each other about their states.</p><p>9. Log Replication: Many consensus algorithms include log replication mechanisms to ensure that all nodes have a consistent view of the data.</p><p>10. Consistency and Replication: Consensus algorithms ensure data consistency across replicas by replicating data and ensuring that all replicas agree on the same data.</p><p>11. Membership Changes: Some consensus algorithms support dynamic changes in the membership of the cluster, allowing nodes to join or leave the system gracefully.</p><p>12. Performance Trade-offs: Different consensus algorithms offer varying trade-offs between fault tolerance, performance, and simplicity. Some prioritize simplicity for understandability, while others prioritize performance in large-scale systems.</p><p>Use Cases : Consensus algorithms find applications in distributed databases, distributed file systems, distributed key-value stores, consensus services, blockchain technology, and other distributed systems requiring coordination and agreement among nodes.</p><p>These main features collectively enable consensus algorithms to provide agreement, fault tolerance, and data consistency in distributed systems, making them fundamental components in building reliable and robust distributed applications.</p><p>Paxos and Raft are two prominent consensus algorithms used to achieve data consistency and fault tolerance in distributed systems. Both algorithms aim to ensure that a group of nodes in a distributed network agree on a single value or sequence of operations, even in the presence of failures and network partitions. Despite their similar goals, Paxos and Raft have different approaches and trade-offs.</p><h3><strong>Paxos Algorithm:</strong></h3><p>The Paxos algorithm operates in a series of phases, ensuring that a group of nodes reach a consensus on a single value. The consensus process is divided into three main phases: Prepare Phase, Promise Phase, and Accept Phase. These phases involve message exchanges between proposers and acceptors to reach an agreement on a value or sequence of values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*nUDtfmBBRHwDHncNmQKD7Q.png" /></figure><ol><li>Prepare Phase:</li></ol><ul><li>A proposer initiates the consensus process by sending a prepare message with a proposal number to the acceptors.</li><li>The proposal number is a unique identifier for the current proposal and helps prevent conflicts between competing proposals.</li><li>Upon receiving the prepare message, each acceptor checks if the proposal number is greater than any previous proposal number it has seen.</li><li>If the proposal number is greater, the acceptor replies with a promise not to accept any proposals with lower numbers and includes information about the highest-numbered proposal it has accepted (if any).</li></ul><p>2. Promise Phase:</p><ul><li>After receiving prepare messages, acceptors respond with promise messages to the proposer.</li><li>The promise message includes the acceptor’s acceptance status and the highest-numbered proposal it has accepted (if any).</li><li>If an acceptor has not accepted any proposals before, it responds with a promise but without any accepted value.</li><li>If an acceptor has accepted a proposal before, it includes the proposal number and value in its promise.</li></ul><p>3. Accept Phase:</p><ul><li>If a proposer receives promises from a majority of acceptors (a quorum), it moves on to the accept phase.</li><li>In the accept phase, the proposer sends an accept message to the acceptors with the same proposal number and the value it wants to be accepted.</li><li>Acceptors check if the proposal number is not lower than any previous proposal number they have seen.</li><li>If the proposal number is valid, the acceptor accepts the proposal and informs the proposer.</li></ul><p>Learn Phase: The Learn Phase ensures that the decision is reliably communicated to all nodes in the system, including learners and proposers, so that the distributed system achieves agreement on the chosen value. This phase completes the consensus process and ensures that all correct nodes eventually have the same agreed-upon value, maintaining data consistency across the distributed system.</p><p>Paxos ensures two critical properties: safety (only one value is agreed upon) and liveness (the algorithm makes progress even in the presence of failures and message delays).</p><p>Raft is designed to be more understandable than Paxos and operates based on a strong leader model. It is divided into three main components: Leader Election, Log Replication, and Safety.</p><p>1. Leader Election:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*sxnOzXIEtiNYlH1N9LlQBg.png" /></figure><ul><li>In Raft, nodes use randomized timeouts to elect a leader. Each node has a timeout period, and when it times out, it becomes a candidate and starts a leader election process.</li><li>The candidate sends a “request for votes” to other nodes. If a node has not voted for any other candidate in the current term and it has not already become a leader, it votes for the candidate.</li><li>If a candidate receives votes from a quorum of nodes (majority), it becomes the leader.</li></ul><p>2. Log Replication:</p><ul><li>The leader receives client requests and appends them to its log, forming log entries.</li><li>The leader then sends the log entries to followers (other nodes) to replicate the data.</li><li>Once a log entry is replicated to a quorum of nodes, the leader commits the entry and notifies followers to apply the log entry to their state machines.</li></ul><p>3. Safety:</p><ul><li>Raft ensures safety by always having the most up-to-date log on the leader. If a follower discovers a more recent log from another node, it reverts to the follower state and follows the new leader.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gnApVwPkjKZ-yz2j.png" /></figure><p>Raft prioritizes understandability over complexity, making it easier to implement and reason about. It retains Paxos’s fundamental concepts while providing a more structured and intuitive approach to distributed consensus.</p><h3>Comparision of Raft and Paxos :</h3><ol><li>Readability and Understandability:</li></ol><ul><li>Raft is often regarded as more understandable and easier to reason about than Paxos. Its design is more intuitive and structured, making it easier for developers to grasp and implement.</li><li>Paxos, on the other hand, is considered more complex and difficult to understand due to its original formulation. It requires multiple rounds of communication and has various variants, leading to increased complexity.</li></ul><p>2. Leader Election and Role Separation:</p><ul><li>In Raft, the consensus algorithm includes a leader election mechanism. Nodes in the cluster have defined roles as either followers, candidates, or leaders. The leader is responsible for coordinating the consensus process and handling client requests.</li><li>In Paxos, leadership is not explicitly defined in the algorithm. While a leader can be determined from the participants’ responses, the algorithm itself does not have built-in leader election mechanisms. Paxos variants, like Multi-Paxos, address leadership issues separately.</li></ul><p>3. Membership Changes:</p><ul><li>Raft has built-in support for handling membership changes, such as adding or removing nodes from the cluster. These changes are explicitly addressed in the algorithm.</li><li>Paxos does not natively handle membership changes, and modifying the group of participants requires additional coordination mechanisms.</li></ul><p>4. Safety and Liveness Trade-offs:</p><ul><li>Both Paxos and Raft achieve safety, ensuring that a single value is agreed upon by all nodes when a decision is reached.</li><li>Paxos prioritizes safety over liveness, meaning it focuses on ensuring that decisions are not made prematurely or inconsistently. This can lead to a slower recovery in certain failure scenarios.</li><li>Raft prioritizes liveness over safety, aiming to make progress even if it may occasionally lead to temporary inconsistencies (e.g., split-brain situations).</li></ul><p>5. Implementations and Adoption:</p><ul><li>Raft has gained popularity due to its simplicity and ease of implementation. It has inspired several open-source projects and is used in popular systems like etcd and Consul.</li><li>Paxos, being an earlier algorithm, is foundational and has influenced various consensus protocols, but its original formulation is less frequently used directly in practical applications.</li></ul><p>In summary, both Paxos and Raft are consensus algorithms that ensure data consistency in distributed systems. Raft is often favored for its readability and ease of implementation, while Paxos has made significant contributions to the distributed systems field and has influenced the design of other consensus protocols. The choice between the two depends on specific project requirements and trade-offs between complexity and understandability.</p><h3>ALTERNATIVES :</h3><p>Paxos and Raft have alternatives and variations, as the field of distributed systems research and development has seen continuous progress over the years. Some of the notable alternatives and variations include:</p><p>For Paxos:</p><ol><li>Multi-Paxos: Multi-Paxos is an optimization of the original Paxos algorithm that reduces the number of communication rounds required to reach consensus. It allows the leader to propose multiple values in sequence without going through the full Prepare Phase each time.</li><li>Fast Paxos: Fast Paxos is another optimization that aims to further reduce the number of communication rounds by allowing acceptors to bypass the leader and directly send messages to each other during the Accept Phase.</li><li>Generalized Paxos: Generalized Paxos is a generalization of Paxos that allows multiple leaders to propose values concurrently, providing increased parallelism in the consensus process.</li><li>EPaxos: EPaxos is an improvement over traditional Paxos that achieves lower latency and better performance by leveraging dependencies between commands to optimize the commit process.</li></ol><p>For Raft:</p><ol><li>Raft Variants: Several Raft variants have been proposed to enhance specific aspects of the algorithm, such as Flexible Paxos, which allows dynamic leader selection and reconfiguration.</li><li>Raft Log Compaction: Various approaches have been developed to optimize log compaction, which is essential for managing storage in Raft-based systems.</li><li>Raft with Membership Changes: Modifications to Raft have been proposed to handle dynamic changes in the membership of the cluster, allowing nodes to join or leave the system gracefully.</li></ol><p>Other Consensus Algorithms: Apart from Paxos and Raft, other consensus algorithms have been developed, each with its own strengths and weaknesses. Some notable ones include:</p><ol><li>Zab (ZooKeeper Atomic Broadcast): Zab is the underlying protocol used in Apache ZooKeeper for coordinating distributed systems. It is designed for high throughput and low latency in leader-based systems.</li><li>Viewstamped Replication: A predecessor to Paxos, Viewstamped Replication is an early consensus algorithm designed for fault-tolerant replication in distributed systems.</li><li>Raft-based Protocols: Apart from Raft, there are other Raft-based consensus protocols like etcd-raft and HashiCorp’s Raft.</li></ol><p>Each of these alternatives and variations offers specific trade-offs, addressing different use cases and requirements in distributed systems. The choice of consensus algorithm depends on factors like system requirements, fault tolerance needs, and performance considerations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=138cd7c2d35a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Andromeda : Google Cloud Platform’s network virtualization stack]]></title>
            <link>https://medium.com/@mani.saksham12/googles-andromeda-23147b9af86b?source=rss-6892c257514c------2</link>
            <guid isPermaLink="false">https://medium.com/p/23147b9af86b</guid>
            <category><![CDATA[research-paper]]></category>
            <category><![CDATA[virtualization]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud-networking]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Saksham]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 10:32:35 GMT</pubDate>
            <atom:updated>2023-07-19T17:36:14.032Z</atom:updated>
            <content:encoded><![CDATA[<h3>(Performance, Isolation, and Velocity at Scale in Cloud Network Virtualization)</h3><p>Andromeda is an architecture designed for network virtualization in Google Cloud Platform. It focuses on achieving high performance, isolation, scalability, rapid provisioning, low latency, and feature velocity. The architecture is based on a flexible hierarchy of flow processing paths and utilizes a combination of software and hardware acceleration for efficient packet processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*Jti2dpk7PkSDvqev.jpeg" /><figcaption>Andromeda Stack</figcaption></figure><p>Here are key components and concepts in the Andromeda architecture:</p><ol><li>Flow Processing Hierarchy: Andromeda employs a flexible hierarchy of flow processing paths. Flows are network traffic streams that are dynamically assigned to specific programming paths based on their requirements. This approach allows different flows to be processed optimally, based on their specific needs for performance, features, and isolation.</li><li>Hoverboard Programming Model: The Hoverboard programming model is introduced in Andromeda to handle the long tail of low-bandwidth flows. It leverages gateways to efficiently manage these flows and enables the control plane to program network connectivity for a large number of virtual machines (VMs) in a matter of seconds. This model ensures rapid provisioning and connectivity for VMs while efficiently utilizing network resources.</li><li>On-Host Dataplane: The on-host dataplane in Andromeda is responsible for packet processing on individual virtual hosts. It is designed for high performance and utilizes an OS bypass software packet processing path. By bypassing the traditional operating system networking stack, Andromeda achieves lower latency and higher throughput. This approach helps to maintain performance levels comparable to hardware-based solutions.</li><li>Coprocessor Threads: Andromeda offloads CPU-intensive per-packet operations with higher latency targets to coprocessor threads. These threads handle specific tasks that require additional processing, such as cryptography, deep packet inspection, or other advanced network functions. By separating these operations from the main processing path, Andromeda ensures efficient packet processing without impacting the overall performance.</li><li>Hardware Acceleration: Andromeda leverages hardware acceleration techniques to further enhance performance. This includes utilizing specialized hardware components or features, such as dedicated network interface cards (NICs), hardware offloading, or other hardware-assisted acceleration mechanisms. By leveraging hardware capabilities, Andromeda achieves high-speed packet processing and reduces the burden on the host CPU.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/0*8gESQaxoZT_740G6.png" /><figcaption>Hoverboard packet forwarding</figcaption></figure><p>The Andromeda VM host stack sends all packets for which it does not have a route to Hoverboard gateways, which have forwarding information for all virtual networks.</p><p>By combining these architectural elements, Andromeda provides a robust and efficient network virtualization solution. It delivers high performance, isolation, scalability, rapid provisioning, low latency, and feature velocity for Google Cloud Platform’s network infrastructure, ensuring optimal network performance and resource utilization for cloud customers.</p><ol><li>Performance Isolation: Andromeda emphasizes performance isolation among customer virtual networks. By dynamically assigning flows to different programming paths based on their requirements, Andromeda ensures that network traffic from different customers or tenants remains isolated, preventing performance interference or congestion.</li><li>Scalability: Andromeda is designed to scale effectively, allowing for the rapid provisioning of large numbers of virtual hosts. The Hoverboard programming model and efficient flow processing paths enable the control plane to handle connectivity programming for tens of thousands of virtual machines within seconds, facilitating the scalability of network resources.</li><li>Bandwidth and Latency: One of the goals of Andromeda is to provide network performance that is largely indistinguishable from the underlying hardware. By utilizing high-performance OS bypass software packet processing and hardware acceleration techniques, Andromeda achieves low latency and high bandwidth, enabling virtual networks to deliver network performance comparable to physical infrastructure.</li><li>Feature Velocity and High Availability: Andromeda aims to combine high feature velocity with high availability. The architecture allows for the decoupling of feature growth from fast path performance by implementing many features on coprocessor threads. This approach enables rapid deployment of new features and enhancements while maintaining high-performance levels and availability of network services.</li><li>Flexibility and Software-Based Architecture: Andromeda’s architecture is designed to provide the flexibility and agility of a software-based solution. By utilizing a programmable flow processing hierarchy and a software-defined networking approach, Andromeda can adapt to changing requirements and evolve with customer needs. This flexibility allows for efficient management and provisioning of network resources in a cloud environment.</li><li>Competitive Performance: The Andromeda datapath achieves performance that is competitive with hardware-based solutions while leveraging the advantages of a software-based architecture. By optimizing packet processing and offloading CPU-intensive tasks, Andromeda can deliver high-speed packet handling, low latency, and efficient resource utilization.</li></ol><p>Fast Path</p><ul><li>Performs packet processing actions required for performance-critical VM flows, such as intra-cluster VM-VM.</li><li>VM and Host NIC queues are the sources and sinks of element chains. To avoid thread handoffs and system calls, the Fast Path directly accesses both VM virtual NIC and host physical NIC queues via shared memory, bypassing the VMM and host OS.</li></ul><p>Coprocessor Path (Slow)</p><ul><li>Implements features that are CPU-intensive or do not have strict latency requirements.</li><li>Coprocessor stages may acquire locks, allocate memory, and perform system calls.</li></ul><p>Flow Table</p><ul><li>The FT is a cache of the vswitchd flow tables.</li><li>Each engine maintains its own FT flow statistics, which vswitchd periodically reads and aggregates.</li><li>When a packet is sent through the FT, the FT computes the flow key for the packet, looks up the key in the flow index table, then applies the specified flow actions and any enabled Fast Path packet stages, and finally updates statistics.</li><li>When Coprocessor stages are enabled for the flow, the packet is sent to the appropriate Coprocessor thread.</li></ul><p>Dataplane Performance</p><ul><li>The Dataplane performance has improved significantly throughout the evolution of Andromeda.</li><li>Pre-Andromeda was implemented entirely in the VMM and used UDP sockets for packet I/O. The dataplane supported only a single queue virtual NIC with zero offloads, such as LRO and TSO.</li></ul><p>Andromeda 1.0 included an optimized VMM packet pipeline and a modified kernel Open vSwitch (OVS). We added virtual NIC multi-queue and egress offloads.</p><p>Andromeda 1.5 added ingress virtual NIC offloads and further optimized the packet pipeline by coalescing redundant lookups in the VMM with the kernel OVS flow table lookup. Host kernel scheduling and C-State management were also optimized, improving latency.</p><p>Andromeda 2.0 consolidated prior VMM and host kernel packet processing into a new OS-bypass busy-polling userspace dataplane. The VMM continued to handle VM virtual NIC ring access and interrupts, but all packet processing was performed by the new dataplane. The VMM exchanged packets with the dataplane via SPSC shared memory rings. The dataplane maps in all VM memory, and directly copies packet to/from VM memory.</p><p>Andromeda 2.1 directly accesses VM virtual NIC rings in the dataplane, bypassing the VMM. Performancecritical packets are processed end-to-end by the busypolling dataplane CPU without thread handoffs or context switches. Eliminating the VMM from the packet datapath removed four thread wakeups per network round trip which significantly improved latency and CPU efficiency.</p><p>Andromeda 2.2 uses Intel QuickData DMA Engines to offload larger packet copies, improving throughput. DMA engines use an IOMMU for safety and are directly accessed by the dataplane via OS bypass. Tracking async packet copies and maintaining order caused a slight latency increase over Andromeda 2.1 for small packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*6x2jUNB9uZcAjy35.png" /><figcaption>Multi-stream TCP throughput.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*wqi633EdqOPCurB6.png" /><figcaption>CPU Efficiency. Note: Guest versus host breakdown is unavailable for Pre-Andromeda</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/0*M4KR8tnHt72TZ_3Q.png" /><figcaption>TCP round trip latency</figcaption></figure><p>Reference Paper : <a href="https://www.usenix.org/conference/nsdi18/presentation/dalton">https://www.usenix.org/conference/nsdi18/presentation/dalton</a></p><p>The paper showcases how Andromeda addresses the complex requirements of network virtualization in a cloud environment. It presents the use of a flexible flow processing hierarchy, the Hoverboard programming model, and a high-performance dataplane design to deliver performance, isolation, scalability, rapid provisioning, low latency, and high feature velocity for Google Cloud Platform’s network infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23147b9af86b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>