<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vignesh on Medium]]></title>
        <description><![CDATA[Stories by Vignesh on Medium]]></description>
        <link>https://medium.com/@vignesh2002?source=rss-4b9359f10871------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Vignesh on Medium</title>
            <link>https://medium.com/@vignesh2002?source=rss-4b9359f10871------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:17:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vignesh2002/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[How Node.js Works Internally: V8, libuv, and the Operating System]]></title>
            <link>https://medium.com/@vignesh2002/how-node-js-works-internally-v8-libuv-and-the-operating-system-d3f4cffae0c1?source=rss-4b9359f10871------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f4cffae0c1</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[internal-wokring]]></category>
            <category><![CDATA[os]]></category>
            <category><![CDATA[libuv]]></category>
            <category><![CDATA[v8]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 10:35:19 GMT</pubDate>
            <atom:updated>2026-11-20T10:35:19.762Z</atom:updated>
            <content:encoded><![CDATA[<p>When we execute a JavaScript application using Node.js, we usually think about the code we’ve written and the output it produces.</p><p>But behind that simple execution, several components work together to make it possible.</p><p>For example, consider a simple file-reading operation:</p><pre>const fs = require(&quot;node:fs&quot;);</pre><pre>fs.readFile(&quot;example.txt&quot;, &quot;utf8&quot;, (err, data) =&gt; {<br>  if (err) throw err;</pre><pre>  console.log(data);<br>});</pre><p>We know that readFile() performs an asynchronous operation. But what actually happens behind the scenes?</p><ul><li>How does Node.js execute JavaScript?</li><li>How does a JavaScript API communicate with lower-level system components?</li><li>Who handles the file-reading operation?</li><li>How does Node.js know when the operation has completed?</li><li>How does the callback get executed?</li></ul><p>To answer these questions, we need to understand the internal architecture of Node.js.</p><p>At a high level, Node.js relies on three important components:</p><ol><li><strong>V8:</strong> JavaScript execution engine.</li><li><strong>libuv:</strong> Event loop and asynchronous I/O infrastructure.</li><li><strong>Operating System:</strong> Provides access to system resources and I/O facilities.</li></ol><p>However, there is another important piece connecting these components: Node.js core and its C++ bindings.</p><p>Let’s understand how everything fits together.</p><h3>1. Understanding the Node.js Runtime Architecture</h3><p>Node.js is a JavaScript runtime environment built on Google’s V8 JavaScript engine.</p><p>But V8 alone is not Node.js.</p><p>V8 provides the ability to execute JavaScript. Node.js extends that capability by providing built-in APIs such as:</p><ul><li>File System (fs)</li><li>HTTP (http)</li><li>Networking (net)</li><li>Cryptography (crypto)</li><li>Streams (stream)</li></ul><p>These APIs are implemented using a combination of JavaScript, C++, V8 interfaces, and libuv.</p><p>A simplified view of the architecture looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7u1ZuIqCogfoAyOjQTsYA.png" /></figure><p><strong>CPU, Memory, Storage and Network</strong></p><p>This is a conceptual representation rather than a strict execution pipeline. Different operations interact with different runtime components.</p><p>Let’s examine the important components individually.</p><h3>2. V8: The JavaScript Execution Engine</h3><p>V8 is an open-source JavaScript engine developed by Google. It is used by Google Chrome and Node.js.</p><p>Its primary responsibility is to parse, compile, and execute JavaScript.</p><p>When we execute JavaScript, V8 performs several stages:</p><p><strong>1. Parsing</strong></p><p>V8 parses the JavaScript source code and generates an Abstract Syntax Tree (AST), representing the structure of the program.</p><p><strong>2. Compilation</strong></p><p>V8 converts the parsed representation into an internal executable representation, including bytecode.</p><p><strong>3. Execution</strong></p><p>V8 executes the generated bytecode using its interpreter.</p><p><strong>4. Optimization</strong></p><p>V8 monitors frequently executed code and can optimize it into machine code to improve execution performance.</p><p>The important thing to understand is that V8 doesn’t simply translate every JavaScript statement directly into machine code.</p><p>It uses multiple stages to execute and optimize JavaScript efficiently.</p><p>However, V8 is responsible only for JavaScript execution. It doesn’t independently provide all the operating-system functionality needed by a backend application.</p><p>For example, when we call fs.readFile(), V8 executes the JavaScript API call, but the actual file-reading operation involves additional Node.js runtime components.</p><p>This brings us to the next component.</p><h3>3. Node.js Core, C++ Bindings, and libuv</h3><p>One important aspect of Node.js architecture is how JavaScript APIs communicate with lower-level functionality.</p><p>Node.js provides built-in JavaScript modules, but not all their functionality is implemented in JavaScript.</p><p>Some operations require native functionality implemented in C or C++.</p><p>This is where Node.js core and its C++ bindings come into play.</p><h3>C++ Bindings</h3><p>C++ bindings provide a bridge between JavaScript APIs and native functionality.</p><p>For example, when we call a built-in Node.js API, the JavaScript implementation may invoke native functionality through internal bindings.</p><p>These bindings allow Node.js to interact with components such as V8, libuv, and other native system libraries.</p><p>This means JavaScript code can access capabilities that are not directly available in the JavaScript language itself.</p><h3>Understanding libuv</h3><p>libuv is a cross-platform C library used by Node.js to provide asynchronous I/O and event loop functionality.</p><p>Some of its major responsibilities include:</p><ul><li>Managing the event loop.</li><li>Providing asynchronous I/O infrastructure.</li><li>Managing a worker thread pool.</li><li>Providing cross-platform abstractions for operating-system functionality.</li></ul><p>Two important mechanisms provided by libuv are:</p><p><strong>1. Event Loop</strong></p><p>The event loop coordinates asynchronous operations and determines when their callbacks can execute on the JavaScript thread.</p><p>It allows Node.js to handle multiple I/O operations without blocking JavaScript execution while waiting for each operation to complete.</p><p><strong>2. Thread Pool</strong></p><p>libuv provides a worker thread pool for operations that need to be performed outside the main event loop.</p><p>For example, asynchronous file system operations use this thread pool.</p><p>The default thread pool size is four threads and can be configured</p><p>An important distinction: not every asynchronous operation uses the thread pool. Network I/O generally uses operating-system mechanisms for non-blocking I/O and event notification.</p><p>We’ll explore both the event loop and thread pool in greater detail in upcoming articles.</p><h3>4. How Node.js Interacts with the Operating System</h3><p>Node.js doesn’t directly interact with hardware resources. It relies on the operating system to perform operations involving files, networking, and other system resources.</p><p>The operating system exposes interfaces through which applications can request these operations.</p><p>For example:</p><ul><li>File operations interact with the file system.</li><li>Network operations use operating-system networking facilities.</li><li>Memory allocation and process management involve operating-system functionality.</li></ul><p>When Node.js performs an asynchronous operation, the runtime coordinates with the operating system or other native components to complete the requested work.</p><p>The exact mechanism depends on the operation and the operating system.</p><p>For example, Linux uses mechanisms such as epoll for scalable I/O event notification, while other platforms use their own facilities.</p><p>This is one reason libuv is important: it provides a consistent abstraction across different operating systems.</p><h3>5. Putting Everything Together: Synchronous vs Asynchronous Execution</h3><p>Now that we understand the architecture, let’s see how these components work together during actual JavaScript execution.</p><h3>A. Synchronous Execution</h3><p>Consider the following example:</p><pre>console.log(&quot;first&quot;);</pre><pre>for (let i = 0; i &lt; 1000000000; i++) {<br>  // CPU-intensive operation<br>}</pre><pre>console.log(&quot;second&quot;);</pre><p><strong>Output:</strong></p><pre>first<br>second</pre><p>What happens internally?</p><ol><li>V8 executes console.log(&quot;first&quot;).</li><li>The for loop starts executing on the main JavaScript thread.</li><li>The loop performs CPU-intensive work and occupies the JavaScript thread.</li><li>Until the loop finishes, the event loop cannot execute other JavaScript callbacks on that thread.</li><li>Once the loop completes, V8 executes console.log(&quot;second&quot;).</li></ol><p>Ths demonstrates an important characteristic of Node.js:</p><p><strong>CPU-intensive JavaScript execution can block the event loop.</strong></p><p>Although Node.js supports asynchronous I/O, it doesn’t automatically make CPU-intensive JavaScript operations non-blocking.</p><p>This is why we need to understand the difference between asynchronous I/O and CPU-intensive work.</p><h3>B. Asynchronous Non-Blocking I/O</h3><p>Now let’s consider the file-reading example again.</p><pre>const fs = require(&quot;node:fs&quot;);</pre><pre>console.log(&quot;first&quot;);</pre><pre>fs.readFile(&quot;example.txt&quot;, &quot;utf8&quot;, (err, data) =&gt; {<br>  if (err) {<br>    console.error(err);<br>    return;<br>  }</pre><pre>  console.log(data);<br>});</pre><pre>console.log(&quot;third&quot;);</pre><p><strong>Output:</strong></p><pre>first<br>third<br>Contents of example.txt</pre><p>Let’s understand the execution flow.</p><p><strong>Step 1: JavaScript execution begins</strong></p><p>V8 executes:</p><pre>console.log(&quot;first&quot;);</pre><p>Output:</p><pre>first</pre><p><strong>Step 2: File-reading operation is initiated</strong></p><p>When fs.readFile() is called, Node.js processes the API request and initiates the asynchronous file-reading operation.</p><p>For asynchronous file system operations, Node.js uses libuv’s worker thread pool.</p><p>The file-reading work is performed outside the main JavaScript execution thread.</p><p><strong>Step 3: JavaScript continues execution</strong></p><p>While the file is being read, the main JavaScript thread doesn’t wait for the operation to complete.</p><p>It continues executing:</p><pre>console.log(&quot;third&quot;);</pre><p>Output:</p><pre>third</pre><p><strong>Step 4: File-reading operation completes</strong></p><p>Once the worker finishes reading the file, the completion is communicated back to the event loop.</p><p><strong>Step 5: Callback execution</strong></p><p>The event loop coordinates the execution of the registered callback on the main JavaScript thread.</p><p>Finally, the file contents are printed.</p><p>This demonstrates how Node.js can perform I/O operations without blocking JavaScript execution while waiting for those operations to complete.</p><p>The important distinction is that the file-reading operation happens outside the main JavaScript execution thread, but the JavaScript callback still executes on that thread.</p><h3>6. Key Takeaways</h3><p>Let’s summarize the responsibilities of each component.</p><p>Component Responsibility <br><strong>V8</strong> Parses, compiles, and executes JavaScript<br><strong>Node.js Core</strong> Provides built-in JavaScript APIs and runtime functionality<br><strong>C++ Bindings</strong> Connect JavaScript APIs with native functionality <br><strong>libuv</strong> Provides the event loop, asynchronous I/O infrastructure, and worker thread pool<br><strong>Operating System</strong> Provides system-level interfaces for files, networking, and other resources</p><p>There are a few important things to remember:</p><ul><li>Node.js uses V8 to execute JavaScript.</li><li>Node.js core exposes APIs that developers use to interact with system functionality.</li><li>libuv provides the event loop and worker pool.</li><li>Not all asynchronous operations use the worker pool.</li><li>JavaScript callbacks execute on the main JavaScript thread by default.</li><li>CPU-intensive JavaScript can block the event loop.</li></ul><h3>Conclusion</h3><p>Node.js is more than just a JavaScript runtime. It brings together V8, Node.js core, C++ bindings, libuv, and the operating system to execute JavaScript and handle operations beyond the JavaScript engine itself.</p><p>Understanding how these components interact gives us the architectural foundation needed to explore Node.js internals in greater depth.</p><p>In the next article, we’ll look at the <strong>Node.js Event Loop</strong> and understand how it coordinates asynchronous operations and callback execution.</p><p><em>This is Part 01 of the Understanding Node.js Internals series.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f4cffae0c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How AWS S3 Protects Your Data Using Erasure Coding]]></title>
            <link>https://medium.com/@vignesh2002/how-aws-s3-protects-your-data-using-erasure-coding-942667558b1e?source=rss-4b9359f10871------2</link>
            <guid isPermaLink="false">https://medium.com/p/942667558b1e</guid>
            <category><![CDATA[data-retrieval]]></category>
            <category><![CDATA[erasure-coding]]></category>
            <category><![CDATA[data-loss]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Vignesh]]></dc:creator>
            <pubDate>Thu, 08 Jan 2026 09:35:46 GMT</pubDate>
            <atom:updated>2026-01-08T09:43:20.876Z</atom:updated>
            <content:encoded><![CDATA[<h3>How AWS S3 Uses Erasure Coding to Protect Your Data</h3><p>When a file is uploaded to an Amazon S3 bucket, it is automatically stored across multiple Availability Zones, S3 is engineered to deliver 11 nines of durability (99.999999999%), which often leads beginners to assume that AWS simply stores three full copies of the same object — one in each Availability Zone.</p><p>However, S3 <strong>does not</strong> rely on naïve replication. Storing raw copies is inefficient, increases storage costs, and still exposes risk: if all three replicas were ever corrupted or lost at the same time, the object would be unrecoverable.</p><p>Instead, AWS uses far more advanced techniques — specifically <strong>erasure coding and Reed–Solomon encoding</strong> — to distribute data and parity fragments across Availability Zones. This approach drastically reduces redundancy while still ensuring that even if entire AZs or multiple fragments fail, S3 can automatically reconstruct the object without any data loss.</p><blockquote>What is Erasure Coding?</blockquote><blockquote>Erasure Coding is a data-protection technique in which data is divided into multiple fragments and supplemented with additional <em>parity</em> fragments. Even if several of these fragments are lost or corrupted, the original data can still be reconstructed mathematically.</blockquote><h3>How Does Erasure Coding Work?</h3><p>When a file is uploaded, S3 breaks it into smaller pieces and generates extra parity pieces using mathematical algorithms (often Reed–Solomon codes). These pieces are then distributed across multiple Availability Zones.</p><p>For example, consider uploading a 100 MB object:</p><p><strong><em>1. Data is split into smaller blocks</em></strong><em><br> </em>S3 may divide the file into <strong>10 data blocks</strong>, each containing a portion of the original file</p><p><strong><em>2. Parity blocks are generated</em></strong><em><br> </em>It then computes <strong>4 additional parity blocks</strong> using erasure-coding math.</p><p><strong><em>3. Blocks are distributed across Availability Zones</em></strong><em><br></em> All 14 blocks (10 data + 4 parity) are stored across multiple storage nodes in <strong>three or more AZs</strong>.</p><blockquote><strong>To understand the idea behind erasure coding, let’s start with a very basic example using small numbers.</strong></blockquote><p>Suppose we want to store two pieces of data</p><pre>D1 = 10;<br>D2 = 20;</pre><p>If we store only these two values and one of them is lost, the data becomes unrecoverable.<br>To avoid this, we introduce a <em>parity</em> value.</p><p>We compute a simple parity using:</p><pre>P = D1 + D2<br>P = 10 + 20 = 30</pre><p>Assume second disk value is lost to recover the lost data</p><pre>P = D1 + D2</pre><pre>D2 = P - D1</pre><p>Now substitute the known values:</p><pre>D2 = 30 - 10 = 20</pre><p>The missing data is fully reconstructed.</p><blockquote><strong>Erasure Coding Example (3 Data Chunks → 2 Parity Chunks)</strong></blockquote><p>To illustrate how real erasure-coding systems work (similar to those used in cloud storage), let’s walk through a simplified Reed–Solomon–style example</p><p>We start with three data values (data chunks):</p><pre>D1 = 5 <br>D2 = 7<br>D3 = 9</pre><p>Reed–Solomon encoding treats these values as points on a polynomial.<br> For simplicity, imagine we evaluate this polynomial at five points:</p><p><strong><em>F(1), F(2), F(3)</em></strong><em> → Data chunks</em></p><p><strong><em>F(4), F(5)</em></strong><em> → Parity chunks</em></p><p>For demonstration, suppose the polynomial is:</p><pre>F(x) = x² + 3x + 1</pre><p>I have taken a polynomial with degree 3 since i used 3 chunks usually it should be ( k — 1 )</p><p><em>Evaluate F(x) at x = 1 to 5:</em></p><pre>| x | F(x) | Purpose  |<br>| - | ---- | -------- |<br>| 1 | 5    | Data 1   |<br>| 2 | 11   | Data 2   |<br>| 3 | 19   | Data 3   |<br>| 4 | 29   | Parity 1 |<br>| 5 | 41   | Parity 2 |</pre><blockquote>Simulate a Failure</blockquote><p>Assume two chunks are lost:</p><pre>F(2) = 11<br>F(4) = 29</pre><p>Remaining chunks:</p><pre>F(1) = 5 <br>F(3) = 19<br>F(5) = 41</pre><p>A polynomial of degree 2 can be reconstructed from <strong>any 3 points</strong>, so recovery is still possible.Rebuild the Original Polynomial</p><p>We know:</p><pre>F(x) = ax² + bx + c</pre><p>Using the three known points:</p><p><em>From F(1) = 5</em></p><pre>a + b + c = 5          ...(1)</pre><p><em>From F(3) = 19</em></p><pre>9a + 3b + c = 19       ...(2)</pre><p><em>From F(5) = 41</em></p><pre>25a + 5b + c = 41      ...(3)</pre><blockquote>Solve the equations</blockquote><p>(2) − (1):</p><pre>8a + 2b = 14<br>4a + b = 7              ...(4)</pre><p>(3) − (1):</p><pre>24a + 4b = 36<br>6a + b = 9              ...(5)</pre><p>(5) − (4):</p><pre>2a = 2<br>a = 1</pre><p><em>Substitute a = 1 into (4):</em></p><pre>4(1) + b = 7<br>b = 3</pre><p><em>Substitute a = 1, b = 3 into (1):</em></p><pre>1 + 3 + c = 5<br>c = 1</pre><blockquote>Recover the Missing Chunks</blockquote><p>Now evaluate the missing values:</p><p><em>Recover F(2) and Recover F(4):</em></p><pre>F(x) = ax² + bx + c</pre><p>now substitute the x and the values a, b, c</p><pre>F(2) = 4 + 6 + 1 = 11<br>F(4) = 16 + 12 + 1 = 29</pre><p>Both lost chunks are reconstructed exactly.</p><blockquote><strong>Now Let’s Jump to the real calculation on how the files are stored across multiple location</strong></blockquote><p>Consider uploading a <strong>4 MB file</strong> to cloud storage.</p><pre>4 MB = 4,194,304 bytes</pre><p>The storage system divides each object internally into fixed-size stripes of <strong>64 KB</strong> (this is just an example; the actual size may vary).</p><pre>size = 64 KB = 65,536 byte</pre><blockquote><strong><em>1. Calculate the total stripes</em></strong></blockquote><pre>4,194,304 bytes(4Mb) ÷ 65,536 bytes(64Kb) = 64 stripes</pre><p>So the object is split into <strong>64 stripes</strong>.</p><blockquote>2. <strong><em>Erasure Coding Inside Each Stripe</em></strong></blockquote><p>Each stripe is then erasure-coded independently, In this example, the system uses a <strong>6 data + 3 parity</strong> scheme</p><p><em>6 data blocks ,3 parity blocks ,Total = 9 blocks per stripe</em></p><p>The usable data per stripe is evenly divided across the 6 data blocks:</p><pre>65,536 bytes ÷ 6 ≈ 10,922 bytes per data block(approximately)</pre><p>(Any remaining bytes are handled internally via padding).</p><blockquote>Stripes layout</blockquote><pre>┌────────────── Stripe 0 (64 KB) ──────────────┐<br>│                                              │<br>│ D0 │ D1 │ D2 │ D3 │ D4 │ D5 │  P0 │  P1 │ P2 │<br>│≈10k│≈10k│≈10k│≈10k│≈10k│≈10k│  parity blocks │<br>└──────────────────────────────────────────────┘<br><br>┌────────────── Stripe 63(64 KB) ──────────────┐<br>│                                              │<br>│ D0 │ D1 │ D2 │ D3 │ D4 │ D5 │  P0 │  P1 │ P2 │<br>│≈10k│≈10k│≈10k│≈10k│≈10k│≈10k│  parity blocks │<br>└──────────────────────────────────────────────┘</pre><p><strong><em>D0–D5</em></strong><em> → Data blocks (split from the stripe payload) </em><strong><em>P0–P2</em></strong><em> → Parity blocks (computed mathematically)</em></p><p>how parity are generate the parity are generated (Real math)</p><p>S3 uses the <strong><em>Reed–Solomon Ersure coding and Vendermonde Matrix</em></strong></p><blockquote><strong><em>3. Reed — solomon</em></strong> erasure coding included <strong><em>Galois Field GF (2⁸) which does </em></strong>⊕ for normal addition and multiplication in table based format</blockquote><blockquote>let dive deep into how the parity is generated</blockquote><p>let’s take stripe 0 in this example ,which has 6 data shards and 3 parity block each shard has data from 0 to 10921</p><pre>┌────────┬─────┬─────┬─────┬─────┬─────┬─────┐<br>│ j      │ D0  │ D1  │ D2  │ D3  │ D4  │ D5  │<br>├────────┼─────┼─────┼─────┼─────┼─────┼─────┤<br>│ 0      │  a  │  b  │  c  │  d  │  e  │  f  │<br>│ 1      │  g  │  h  │  i  │  j  │  k  │  l  │<br>│ 2      │  m  │  n  │  o  │  p  │  q  │  r  │<br>│ ...    │ ... │ ... │ ... │ ... │ ... │ ... │<br>│ j      │ x0  │ x1  │ x2  │ x3  │ x4  │ x5  │<br>└────────┴─────┴─────┴─────┴─────┴─────┴─────┘</pre><p>assume it like a table ( the values in the table are placeholders values ) and for each row the parity is created it will be having 3 parity blocks</p><p>with the help of the <strong>vendermonde matrix</strong> ( it has distinct element it help use the achieve the recovery of lost data )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*5cs8j-_43ynaebvuO4O_lw.png" /></figure><blockquote><strong><em>4. parity calculations</em></strong></blockquote><p>Let j=10 The value D[0] for 10 is 0x10 also the same for the other below defined values</p><pre>D0 = 0x01 - 1<br>D1 = 0x02 - 2<br>D2 = 0x03 - 3<br>D3 = 0x04 - 4<br>D4 = 0x05 - 5<br>D5 = 0x06 - 6 </pre><p>to build the matrix choose 6 distinct values should be in the range GF (2ˆ8)</p><pre>α = [1, 2, 3, 4, 5, 6]</pre><p>so the matrix will be looking like</p><pre>P0 = [1, 1, 1, 1, 1, 1]<br>P1 = [1, 2, 3, 4, 5, 6]<br>P2 = [1, 4, 9, 16, 25, 36]</pre><p>the parity rows are obtained by substituting in the α in the above formula</p><pre>[ P0 ]   [ 1  1  1   1   1   1 ]   [ D0 ]<br>[ P1 ] = [ 1  2  3   4   5   6 ] × [ D1 ]<br>[ P2 ]   [ 1  4  9  16  25  36 ]   [ D2 ]<br>                                   [ D3 ]<br>                                   [ D4 ]<br>                                   [ D5 ]</pre><p>the above are the parity rows and the matrix formed from thr parity rows</p><p>let make it simple by using the formula to calcluate the parity rows one by one</p><pre>P0[j] = 1·D0[j] ⊕ 1·D1[j] ⊕ 1·D2[j] ⊕ 1·D3[j] ⊕ 1·D4[j] ⊕ 1·D5[j]<br><br>P1[j] = 1·D0[j] ⊕ 2·D1[j] ⊕ 3·D2[j] ⊕ 4·D3[j] ⊕ 5·D4[j] ⊕ 6·D5[j]<br><br>P2[j] = 1·D0[j] ⊕ 4·D1[j] ⊕ 9·D2[j] ⊕ 16·D3[j] ⊕ 25·D4[j] ⊕ 36·D5[j]</pre><p><strong>Addition (⊕)</strong> = bitwise XOR , <strong>Multiplication</strong> = polynomial multiplication <strong>modulo</strong> the irreducible polynomial</p><p>multiplication ()</p><p><strong><em>P0 (simple XOR)</em></strong></p><pre>P0 = 01 ⊕ 02 ⊕ 03 ⊕ 04 ⊕ 05 ⊕ 06<br>   = 07</pre><p>convert the decimal to binary and perform the XOR operation</p><p><strong><em>P1 (weighted)</em></strong></p><pre>1·01 = 01<br>2·02 = 04<br>3·03 = 06 ⊕ 03 = 05<br>4·04 = 10<br>5·05 = 14 ⊕ 05 = 11<br>6·06 = (4·06) ⊕ (2·06) = 18 ⊕ 0C = 14</pre><p>let me explain how the multiplication takes place</p><pre> (3.03) is splitted into (2.03) ⊕ (1.03) <br> (2.03) - 3 multiplied 2 (i.e) which is leftshift &lt;&lt; 1 (by 1 bit)<br>  3 &lt;&lt; 1 = 00000110 (6)<br><br>now we got the answer for (2.03) = 00000110 <br><br>00000110 = (2.03)<br>       ⊕<br>00000011 = (1.03)<br>--------<br>00000101 = 5 <br>--------</pre><p>the same calculation applies for all the above weighted P1</p><pre>P1 = 01 ⊕ 04 ⊕ 05 ⊕ 10 ⊕ 11 ⊕ 14<br>   = 15</pre><p><strong><em>P2 (squared coefficients)</em></strong></p><pre>1·01  = 01<br>4·02  = 08<br>9·03  = (8·03) ⊕ 03 = 18 ⊕ 03 = 1B<br>16·04 = 40<br>25·05 = 16·05 ⊕ (8·05 ) ⊕ (1·05) = 41<br>36·06 = (32·06) ⊕ (4·06) = C0 ⊕ 18 = D8</pre><pre>P2 = 01 ⊕ 08 ⊕ 1B ⊕ 40 ⊕ 41⊕ D8<br>   = CB</pre><p>what S3 will store in one stripe is these 9 shards are stored across <strong>3 AZs</strong>.</p><pre>D0 = 01<br>D1 = 02<br>D2 = 03<br>D3 = 04<br>D4 = 05<br>D5 = 06<br>P0 = 07<br>P1 = 15<br>P2 = CF</pre><blockquote><strong><em>5.data recovery of the lost nodes</em></strong></blockquote><p>Lost shards:</p><pre>D1, D4, P1</pre><p>Survivors (6 shards):</p><pre>D0, D2, D3, D5, P0, P2</pre><p>This is <strong>worst-case</strong>: mixed data + parity loss</p><p>from p0</p><pre>Unknowns :D1, D4<br>Known equations:<br><br>D1 ⊕ D4 = P0 ⊕ (D0 ⊕ D2 ⊕ D3 ⊕ D5)<br>        = 07 ⊕ (01 ⊕ 03 ⊕ 04 ⊕ 06)<br>        = 07 ⊕ 00<br>        = 07<br><br>D1 ⊕ D4 = 07 --equation 1</pre><p>from p2</p><pre>P2 = 1*D0 ⊕ 4*D1 ⊕ 9*D2 ⊕ 16*D3 ⊕ 25*D4 ⊕ 36*D5<br><br>Unknown data: D1, D4<br>known equation: 4*D1 ⊕ 25*D4 = P2 ⊕ (1*D0 ⊕ 9*D2 ⊕ 16*D3 ⊕ 36*D5)<br><br>(1.01) = 1<br><br>(4·02) = 08<br><br>(9.03) = (8.03) ⊕ 03 <br>       = 1B <br><br>16·04 = (2^4). 04<br>        16₁₆ = 0x10 = 00010000₂ <br>        04₁₆ = 0x04 = 00000100₂<br>         so we need 4 times left shift <br>         00000100 &lt;&lt; 4 = 01000000₂ <br>      = 40₁₆<br><br>25·05 = 16·05 ⊕ (8·05 ) ⊕ (1·05)<br>      = 41<br><br>36·06 = (32·06) ⊕ (4·06)<br>        (32·06) = (2^5).06<br>          so we need 5 times left shift<br>          06 &lt;&lt; 5 = 11000000₂ <br><br>        (4·06) = (2^2).06  <br>          so we need 2 times left shift  <br>          06 &lt;&lt; 2 = 00011000₂<br>      = D8 <br><br>(1*D0 ⊕ 9*D2 ⊕ 16*D3 ⊕ 36*D5) = 82 <br></pre><pre>(1*D0 ⊕ 9*D2 ⊕ 16*D3 ⊕ 36*D5) = 82 and P2 =CF by substitution<br><br>now the equation becomes,<br>4·D1 ⊕ 25·D4 = CF ⊕ 82<br><br>4·D1 ⊕ 25·D4 = 4D -- equation 2 <br></pre><p>The both equations are :</p><p><em>D1 ⊕ D4 = 07 — equation 1</em><br><em>4·D1 ⊕ 25·D4 = 4D — equation 2</em></p><pre><br><br>from the above equation D1 = D4 ⊕ 07 <br><br>   4·(D4 ⊕ 07) ⊕ 25·D4 = 4D<br><br>   (4·D4) ⊕ (4·07) ⊕ (25·D4) = 4D<br><br>07 = 00000111<br> 4 = 00000100<br><br>(4·07) = 07 &lt;&lt; 2 <br>       = 00011100<br>       = 1C<br><br>(4 ⊕ 25).D4 ⊕ 1C = 4D<br><br>(4 ⊕ 25).D4 = 1C ⊕ 4D <br><br><br>  04 = 00000100<br>  25 = 00010101<br>  ⊕   <br>     = 00010001 = 11 (hex) <br><br>  4D ⊕ 1C = 51<br><br>  11.D4 = 51 <br></pre><p>The final equation is <em>11.D4 = 51</em></p><p>now the inverse multiplication occurs</p><p>basically in GF (2⁸) a . a-¹= 01</p><pre>11 · 11⁻¹ = 01   (in GF(2⁸))<br><br>We multiply both sides by 11⁻¹:<br><br>D4 = 51 · 11⁻¹ <br></pre><p>what is the value for the 11⁻¹ ( inverse )</p><pre>11 (hex) → binary → polynomial<br><br>0x11 = 00010001₂<br>     = x⁴ + 1<br><br>11⁻¹ = 94</pre><p>The inverse values are pre calculate and kept in the tables for fast lookups</p><pre>D4 = 51 . 94 , D4 = 05</pre><p>substitute in the equation <em>D1 ⊕ D4 = 07</em></p><p>D1 = 07 <em>⊕ 05</em></p><p>we have calculated the D1= 02 and D4 =05 from the remaining shards</p><p>The missing parity P1 will be generated with the shards</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=942667558b1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>