<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Posts on Devansh</title><link>https://devansh.engineer/posts/</link><description>Recent content in Posts on Devansh</description><generator>Hugo</generator><language>en-us</language><copyright>Devansh Bhavsar</copyright><lastBuildDate>Fri, 25 Sep 2026 08:03:18 +0000</lastBuildDate><atom:link href="https://devansh.engineer/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Engineering Blogs Every Developer Should Read</title><link>https://devansh.engineer/posts/top-engineering-blogs/</link><pubDate>Fri, 24 Jul 2026 00:00:00 +0000</pubDate><guid>https://devansh.engineer/posts/top-engineering-blogs/</guid><description/><content:encoded><![CDATA[<h2 id="artifical-intelligence">Artifical Intelligence</h2>
<ul>
<li><a href="https://www.anthropic.com/engineering" target="_blank" rel="noopener noreferrer">Anthropic</a>
</li>
<li><a href="https://openai.com/news/" target="_blank" rel="noopener noreferrer">OpenAI</a>
</li>
<li><a href="https://cursor.com/blog" target="_blank" rel="noopener noreferrer">Cursor</a>
</li>
<li><a href="https://github.blog/engineering/" target="_blank" rel="noopener noreferrer">GitHub</a>
</li>
<li><a href="https://www.kimi.com/blog/" target="_blank" rel="noopener noreferrer">Kimi</a>
</li>
</ul>
<h2 id="cloud--infrastructure">Cloud &amp; Infrastructure</h2>
<ul>
<li><a href="https://aws.amazon.com/blogs/" target="_blank" rel="noopener noreferrer">AWS</a>
</li>
<li><a href="https://blog.cloudflare.com/" target="_blank" rel="noopener noreferrer">Cloudflare</a>
</li>
<li><a href="https://www.digitalocean.com/blog/tags/engineering" target="_blank" rel="noopener noreferrer">DigitalOcean</a>
</li>
<li><a href="https://vercel.com/blog/category/engineering" target="_blank" rel="noopener noreferrer">Vercel</a>
</li>
</ul>
<h2 id="data-engineering">Data Engineering</h2>
<ul>
<li><a href="https://www.cockroachlabs.com/blog/" target="_blank" rel="noopener noreferrer">CockroachDB</a>
</li>
<li><a href="https://www.databricks.com/blog/category/engineering" target="_blank" rel="noopener noreferrer">Databricks</a>
</li>
<li><a href="https://planetscale.com/blog" target="_blank" rel="noopener noreferrer">PlanetScale</a>
</li>
<li><a href="https://www.scylladb.com/category/engineering/" target="_blank" rel="noopener noreferrer">ScyllaDB</a>
</li>
</ul>
<h2 id="gaming">Gaming</h2>
<ul>
<li><a href="https://www.riotgames.com/en/news?q=tech%20blog" target="_blank" rel="noopener noreferrer">Riot Games</a>
</li>
</ul>
<h2 id="media--streaming">Media &amp; Streaming</h2>
<ul>
<li><a href="https://netflixtechblog.com/" target="_blank" rel="noopener noreferrer">Netflix</a>
</li>
<li><a href="https://engineering.atspotify.com/" target="_blank" rel="noopener noreferrer">Spotify</a>
</li>
</ul>
<h2 id="social-platforms">Social Platforms</h2>
<ul>
<li><a href="https://discord.com/category/engineering" target="_blank" rel="noopener noreferrer">Discord</a>
</li>
<li><a href="https://www.linkedin.com/blog/engineering" target="_blank" rel="noopener noreferrer">LinkedIn</a>
</li>
<li><a href="https://engineering.fb.com/" target="_blank" rel="noopener noreferrer">Meta</a>
</li>
<li><a href="https://quoraengineering.quora.com/" target="_blank" rel="noopener noreferrer">Quora</a>
</li>
<li><a href="https://slack.engineering/" target="_blank" rel="noopener noreferrer">Slack</a>
</li>
<li><a href="https://stackoverflow.blog/" target="_blank" rel="noopener noreferrer">Stack Overflow</a>
</li>
</ul>
<h2 id="independent-authors">Independent Authors</h2>
<ul>
<li><a href="https://benjdd.com/work/" target="_blank" rel="noopener noreferrer">Ben Dicken</a>
</li>
</ul>
]]></content:encoded></item><item><title>The Google File System</title><link>https://devansh.engineer/posts/the-google-file-system/</link><pubDate>Thu, 28 May 2026 00:00:00 +0000</pubDate><guid>https://devansh.engineer/posts/the-google-file-system/</guid><description/><content:encoded><![CDATA[<h2 id="abstract">Abstract</h2>
<p>This blog covers fundamental and important topics related to The Google File System paper published in 2003. I will try to cover everything from the ground up.</p>
<p>You don&rsquo;t need to have any prerequisite knowledge to understand the blog itself, but some coffee and motivation is appreciated.</p>
<p>Let&rsquo;s start from the basics.</p>
<h2 id="what-is-a-distributed-file-system">What is a Distributed File System?</h2>
<blockquote>
<p><em>In computing, a file system or filesystem (often abbreviated to FS or fs) governs file organization and access.</em><sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
</blockquote>
<p>The purpose of a file system is to provide abstract view over the physical data stored on a disk. Windows uses NTFS, Linux uses ext4, btrfs, etc. This are examples of a local file system, because all of the files are available on a single machine.</p>
<p>In contrast, Distributed File System is shared over multiple machines. Some files might resides on machine A, and other on machine B.</p>
<h3 id="why-do-you-need-one">Why do you need one?</h3>
<h4 id="performance">Performance</h4>
<p>By distributing the file system across machines, overall performance of the system is increased. Instead of one machine handling all the operations like creating a file, reading it or updating it. The workload is now distributed across multiple machine.</p>
<h4 id="reliability--availability">Reliability &amp; Availability</h4>
<p>System can replicate files across multiple machines, which makes the system more reliable, and less susceptible to data loss and corruptions. Similarly, when the user request some file and if the machine A goes down, the system can serve the request from machine B.</p>
<h4 id="scalability">Scalability</h4>
<p>In local file system, single machine was bottleneck. A single machine can process requests till certain limits no matter how much you scale it vertically. By sharing the file system across machine, the system becomes more scalable. New machines can be added easily in DFS (Distributed File System).</p>
<h2 id="the-google-file-system">The Google File System</h2>
<p>The GFS (Google File System) was initially created as backend file system for google&rsquo;s production systems, which later evolved and started being used for analytics, research and development. Enough yapping, let&rsquo;s take a look into the design &amp; architecture.</p>
<h3 id="design-decisions">Design Decisions</h3>
<p>GFS was designed for the google&rsquo;s application workload. Their workload required,</p>
<ul>
<li>Fault-Tolerance, because, they used inexpensive commodity hardware that fails often.</li>
<li>Large multi-GB files, rather than few small KB files.</li>
<li>Sequential appends to files are more often than few random writes.</li>
<li>Supporting concurrency with low synchronization overhead.</li>
<li>High Bandwidth, than lower latency</li>
<li>Relaxed Consistency</li>
</ul>
<p>With this key designs in mind. Let&rsquo;s take a look at the core architecture.</p>
<h3 id="architecture">Architecture</h3>
<p><img src="/posts/the-google-file-system/architecture.png" alt="GFS Architecture"></p>
<p>A GFS cluster contains a <strong>single</strong> Master, several chunkservers and clients. Master and chunkservers are Linux user-level process.</p>
<p>Each file in GFS is represented as multiple <strong>fixed-size chunks</strong> (typically 64MB), each chunk have a globally unique chunk handle. For reliability, all the chunks are replicated across chunkservers with replication factor of 3 by default.</p>
<p>The master orchestrates all the operation like creating file chunks, deleting unnecessary chunks, chunk lease management and maintaining metadata about files. Master keeps all the information about the system in main memory(RAM) and <strong>does not</strong> interact with the chunks directly. Chunkservers are the ones who manages the chunk.</p>
<p>To interact with the filesystem, GFS Client is attached to each application, which communicates with the master and chunkservers to perform application tasks.</p>
<h4 id="why-chunks-of-64mb">Why Chunks of 64MB?</h4>
<p>By default GFS divides files into 64MB chunks, which gives us following benefits,</p>
<ul>
<li>Since each chunk&rsquo;s metadata is stored in the master&rsquo;s main memory, larger chunk sizes produces less metadata to manage.</li>
<li>If the application wants multiple updates in single chunk, larger chunk size allows less interaction with the master for fetching metadata about different chunks.</li>
<li>Clients can make a persistent TCP connection to the chunkserver and perform multiple taks within the same chunk and reduce network overload.</li>
</ul>
<h4 id="is-master-a-bottleneck">Is Master a Bottleneck?</h4>
<p>One key decision in the master design is that, all the metadata about the chunks are stored in the master&rsquo;s main memory(RAM). Meaning, the filesystem&rsquo;s capacity is limited by the memory of the master??</p>
<p>Yes, but the paper describes that the master maintains less than 64 bytes of metadata for each 64MB chunk. Hence, with only 8GB of main memory the upperbound on how much data that can be stored in a single GFS cluster will be,</p>
<p>$\text{Max Data Size} = \text{8GB} * 10^{6} = 8PB$</p>
<p>8PB of data with only 8GB of main memory on a single cluster is surely not a bottleneck.</p>
<p>The master employs various technique to ensure only 64B are required for storing the metadata. e.g, Prefix compression for storing the file.</p>
<h4 id="master-failure-and-recovery">Master Failure and Recovery</h4>
<p>To tolerate master crashes, the master maintains an Operation Log. Operation Log is a simple AOF(Append Only File), which is updated whenever the metadata about files changes. It is also periodically persisted on the local disk and remote servers for availability. In case of master crash, the master just replays all the logs in sequence and recover its original state.</p>
<p>Recovering from a long Operation Log is redundant and slow. So, the master creates checkpoints after Operation Log crosses certain size. Checkpoints are int B-Tree like form which can be easily mapped in the memory when recovering. Checkpoints are also replicated on remote machines.</p>
<h3 id="filesystem-interactions">Filesystem Interactions</h3>
<p>This section contains information on how GFS client interacts with the filesystem for operations like read, append, write &amp; delete.</p>
<h4 id="reads">Reads</h4>
<ol>
<li>
<p>When the application want to read for a specific byte offset from a file, the GFS client translates the byte offset into a chunk index (1) and send the request to GFS master.</p>
<p>$$
\begin{equation}
\text{Chunk Index} = \frac{\text{Byte Offset}}{\text{Chunk Size}}
\end{equation}
$$</p>
</li>
<li>
<p>GFS Master responds with a chunk handle (64 bit unique identifier) and locations of the chunk replicas.</p>
</li>
</ol>
<p><img src="/posts/the-google-file-system/master-response.svg" alt="Master’s Response"></p>
<ol start="3">
<li>GFS client caches this response for some period of time to save a round-trip from fetching the same metadata again. With the location of the chunk replicas, client can now make request to any one replica with chunk handle and byte range to read from that chunk.</li>
</ol>
<p><img src="/posts/the-google-file-system/client-request.svg" alt="Client’s Request"></p>
<p>For every subsequent request to the same chunk, client don&rsquo;t need to request the master for replica locations. Instead, it can use the client cache.</p>
<h4 id="writes">Writes</h4>
<p>Writes in GFS are little complex, because it includes chunk lease management for supporting concurrent writes.</p>
<p>When a GFS client wants to write to a particular chunk, the chunk needs to be leased by one replica of that chunk. The replica which holds the lease for a particular chunk is called <strong>Primary Replica</strong>. A chunk can only have one Primary Replica. But a chunkserver can have multiple Primary Replicas which corresponds to different chunks. All of the lease information is stored in master&rsquo;s main memory.</p>
<p>Let&rsquo;s take a look at how a typical write operations is performed,</p>
<ol>
<li>GFS client requests the master for writing to a file with the filename and its chunk index (1). The master returns the primary and other replica (secondary) locations, if a replica already holds a lease for that chunk, otherwise the master grants one replica a lease.</li>
</ol>
<p><img src="/posts/the-google-file-system/client-requests-write.svg" alt="Client Request’s Write"></p>
<ol start="2">
<li>GFS client pushes the new data to all the chunk replicas, and the chunkserver holding the replica stores the data in its LRU buffer and returns acknowledgement to the client. The data is still <strong>not</strong> written to the disk.</li>
</ol>
<p><img src="/posts/the-google-file-system/client-pushes-data.svg" alt="Client Pushes Data"></p>
<ol start="3">
<li>A write request to the primary replica is sent. The primary replica creates a serialized order of mutation which is called <strong>Mutation Order</strong>. It applies the mutation on its disk according to the order and forwards the mutation order to all other secondary replicas. Secondary replicas applies mutations as per mutation order and returns back acknowledgement. Any error occurred during this step, results in the request being failed and then retried again by GFS client from step 2.</li>
</ol>
<p><img src="/posts/the-google-file-system/gfs-processes-write-request.svg" alt="GFS Processes Write Request"></p>
<p>Mutation Order created by the primary replica is applied as is to all the secondary replica. Meaning that the secondary replica will write at the same byte offset as primary replica did.</p>
<p>You may have a question, if the primary replica and some subset of secondary replicas applied the mutation and the remaining replicas failed, doesn&rsquo;t the replicas became inconsistent?</p>
<p>Yes, more on that later.</p>
<h4 id="record-append">Record Append</h4>
<p>Record append is used to append data to the end of the file at-most-once atomically.</p>
<p>The only difference between traditional writes and record append is that, GFS client doesn&rsquo;t need to specify byte offset, it is automatically chosen by GFS and sent to the client.</p>
<p>When appending primary replica handles cases that exceeds the chunk&rsquo;s maximum size. Otherwise, all the steps are same as writing.</p>
<h4 id="deletes">Deletes</h4>
<p>When the GFS client sends a file deletion request, the master immediately logs it in its operation log and renames the file to a hidden name.</p>
<p>The file is still kept on the disk with hidden name till three days by default. Until then, the file can still be read and undeleted by renaming.</p>
<p>After three days the master removes related metadata about the files and allows the chunkserver to reclaim the space.</p>
<h3 id="inconsistent-updates">Inconsistent Updates</h3>
<p>GFS have relaxed consistency, meaning the data will not be exactly byte-wise similar on all of the replicas. Let&rsquo;s take a look at how the data will become inconsistent after performing some record append operations.</p>
<p>A client requests record append on some file and the record append might apply to all primary and secondary replicas of the last chunk of that file.</p>
<p><img src="/posts/the-google-file-system/inconsistent-update-1.svg" alt="Successful Append"></p>
<p>Client requests another record append but, this time it only applies to the primary and one secondary replica. The third replica fails while appending and making the overall operation report an error to the client.</p>
<p><img src="/posts/the-google-file-system/inconsistent-update-2.svg" alt="Failed Append to 2 Replicas"></p>
<p>Because the record append failed, client might retry the operation and it may succeed this time, resulting in the following replica state.</p>
<p><img src="/posts/the-google-file-system/inconsistent-update-3.svg" alt="Successfull Retry Append"></p>
<p>As you can see, the replicas are not byte-wise same. There are duplicates in some of the replicas &amp; padding where the append failed.</p>
<p>Successful record appends results in consistent state, but the intervening regions are left inconsistent. The paper describes few ways to detect this on the client side, which you can further read.</p>
<h2 id="conclusion">Conclusion</h2>
<p>I&rsquo;ve tried to cover all the fundamental &amp; important topics, but there is still lot more to learn like,</p>
<ul>
<li>Namespace management &amp; locking,</li>
<li>Replica optimizations,</li>
<li>Garbage collection,</li>
<li>Availability optimizations,</li>
<li>Data Integrity,</li>
<li>and more&hellip;</li>
</ul>
<p>If you have read the blog till here, give the original paper a read. I assure you, you will learn something new at the end.</p>
<p>A lot of google&rsquo;s internal operations and research was done on top of GFS after successfully implementing it in the production systems like, MapReduce. GFS was massively successful piece of technology in the industry at the time. It doesn&rsquo;t innovated something new, rather created a robust system with already found technologies. Google has replaced GFS with Colossus, with improvements in fault-tolerance and the master performance.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><a href="https://en.wikipedia.org/wiki/File_system" target="_blank" rel="noopener noreferrer">File System(Wikipedia)</a>
&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>