<?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 Shivam Rajput on Medium]]></title>
        <description><![CDATA[Stories by Shivam Rajput on Medium]]></description>
        <link>https://medium.com/@shiviraj?source=rss-d5f7ca4c89ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UXpySyxCpm38G8dXhj-Ilw.png</url>
            <title>Stories by Shivam Rajput on Medium</title>
            <link>https://medium.com/@shiviraj?source=rss-d5f7ca4c89ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:04:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shiviraj/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[Looking at Computers Differently]]></title>
            <link>https://shiviraj.medium.com/looking-at-computers-differently-e21f2e66aded?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/e21f2e66aded</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 12:14:25 GMT</pubDate>
            <atom:updated>2026-07-21T12:14:25.182Z</atom:updated>
            <content:encoded><![CDATA[<p>When I started writing <a href="https://medium.com/@shiviraj/how-computers-actually-work-9c4266b8d0f7">this series</a>, I thought I was trying to understand memory.</p><p>I didn’t expect it to change the way I think about software.</p><p>Like many developers, I spent years working with abstractions.</p><p>Variables.</p><p>Objects.</p><p>Functions.</p><p>Threads.</p><p>Caches.</p><p>Databases.</p><p>Cloud services.</p><p>They became part of my everyday vocabulary.</p><p>But somewhere along the way, I realized something.</p><p>It’s easy to use abstractions without understanding why they exist.</p><p>This series wasn’t about removing those abstractions.</p><p>It was about looking beneath them.</p><p>We started with a single bit.</p><p>Just one.</p><p>From there, we discovered how a capacitor can temporarily remember electrical charge.</p><p>We built a DRAM cell.</p><p>We learned why reading a row is different from reading a single bit.</p><p>We explored why CPUs use SRAM instead of DRAM.</p><p>We learned how hard disks preserve data using magnetism.</p><p>And finally, we saw how SSDs remember information without a spinning disk by trapping electrons inside tiny memory cells.</p><p>Each chapter introduced a new technology.</p><p>But more importantly, each technology solved a problem created by the one before it.</p><p>That’s what I love most about computer engineering.</p><p>Nothing exists by accident.</p><p>Every design is a trade-off.</p><p>Every optimization solves one problem while introducing another.</p><p>Understanding those trade-offs has changed the way I think about performance.</p><p>It has changed the way I think about caching.</p><p>It has changed the way I think about storage.</p><p>And perhaps most importantly…</p><p>It has reminded me that every line of code we write ultimately depends on billions of tiny electronic components working together with incredible precision.</p><p>The next time you write something as simple as:</p><pre>int age = 25;</pre><p>I hope you’ll pause for just a moment.</p><p>Not because the code is complicated.</p><p>But because now you know the remarkable journey that value takes — from CPU registers, to cache, to RAM, and eventually to permanent storage.</p><p>One simple variable.</p><p>Decades of engineering.</p><h4>Thank You</h4><p>If you’ve read the entire series, thank you for coming along on this journey.</p><p>I hope it helped bridge the gap between software and hardware.</p><p>More importantly, I hope it encouraged you to keep asking questions.</p><p>Because every interesting engineering topic begins the same way.</p><p>With someone asking,</p><blockquote><strong><em>“How does that actually work?”</em></strong></blockquote><h4>🎬 Post-Credit Scene</h4><p>While working on a database recently, I stumbled upon something that completely changed the way I think about storage.</p><p>I limited the database to just <strong>512 MB</strong> of disk space.</p><p>Then I created a table and kept inserting rows until the database finally reported that it was full. At that point, I had inserted roughly <strong>300,000 rows</strong>.</p><p>So I thought, <em>“Easy. I’ll just delete some data.”</em></p><p>I deleted <strong>100,000 rows</strong> — about one-third of the table.</p><p>Surely that should free enough space to insert a few more rows, right?</p><p>I tried inserting <strong>just 100 new rows</strong>.</p><p>It failed and reported that it is full.</p><p>Wait… what?</p><p>If one-third of the data is gone, why is it reporting full?</p><p>Where did the “freed” storage go?</p><p>Is the database lying?</p><p>We’ll unravel that mystery in the next series.</p><p><strong>See you there. 👋</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e21f2e66aded" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Can a Computer Remember Without a Disk?]]></title>
            <link>https://shiviraj.medium.com/how-can-a-computer-remember-without-a-disk-b7294e7c3460?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7294e7c3460</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[ssd]]></category>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 12:05:56 GMT</pubDate>
            <atom:updated>2026-07-21T12:15:25.135Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 6 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><p><a href="https://shiviraj.medium.com/how-can-a-computer-remember-without-power-11904425c53d"><strong><em>Missed Part 5?</em></strong></a><strong><em> </em></strong><em>In the previous chapter, we discovered how hard disks use magnetism to remember data even after the power is removed.</em></p><p><em>But they came with a price.</em></p><p><em>Motors.</em></p><p><em>Platters.</em></p><p><em>Read heads.</em></p><p><em>Actuator arms.</em></p><p><em>Every read and write depended on mechanical movement.</em></p><p><em>Today, we’re going to solve one final storage problem.</em></p><p><strong><em>Can a computer remember data without using a disk at all?</em></strong></p><h4>📚 How Computers Actually Work — Series</h4><ul><li>✅ Part 1 — We Need to Talk About RAM</li><li>✅ Part 2 — How Does a Computer Remember a Single Bit?</li><li>✅ Part 3 — Why Does RAM Read an Entire Row?</li><li>✅ Part 4 — We Need to Talk About CPU Cache</li><li>✅ Part 5 — How Can a Computer Remember Without Power?</li><li><strong>👉 Part 6 — How Can a Computer Remember Without a Disk?</strong> <em>(You’re reading)</em></li></ul><h4>Let’s Remove the Disk</h4><p>Imagine opening a hard disk.</p><p>Inside you’ll find:</p><ul><li>Spinning platters.</li><li>A spindle motor.</li><li>An actuator arm.</li><li>Tiny read/write heads.</li></ul><p>Now imagine removing every one of those parts.</p><p>No platter.</p><p>No motor.</p><p>No arm.</p><p>No magnetic surface.</p><p>Nothing spins anymore.</p><p>At this point you might ask,</p><blockquote><em>“If there’s no disk left…”</em></blockquote><blockquote><strong><em>“Where is my data?”</em></strong></blockquote><p>That’s exactly the question engineers had to answer.</p><h4>Think Like an Engineer</h4><p>The hard disk already solved one problem.</p><p>It remembered data without power.</p><p>But it introduced another.</p><p>Every operation required physical movement.</p><p>The read head had to travel.</p><p>The platter had to rotate.</p><p>Physics limited how fast the drive could become.</p><p>So engineers asked a different question.</p><blockquote><strong><em>Can we build permanent storage using only electronics?</em></strong></blockquote><p>No motors.</p><p>No moving parts.</p><p>No magnetic disks.</p><h4>Forget Magnetism</h4><p>So far we’ve seen two different ways to store information.</p><p>DRAM stored electrical charge.</p><p>Hard disks stored magnetic orientation.</p><p>This time…</p><p>Engineers abandoned both ideas.</p><p>Instead of storing electricity.</p><p>Instead of storing magnetism.</p><p>They decided to store the electrons themselves.</p><p>Not flowing through a wire.</p><p>Not charging a capacitor.</p><p>Actually trapping them inside a transistor.</p><p>That idea became <strong>Flash Memory</strong>.</p><h4>Meet NAND Flash</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*Mebv9dJPf4aokErXc10qLA.png" /></figure><p>At first glance,</p><p>a NAND Flash cell looks very similar to the MOSFET we met back in Part 2.</p><p>But it hides one important secret.</p><p>Inside the transistor is an insulated region called the <strong>Floating Gate</strong>.</p><p>Think of it as a tiny sealed room.</p><p>Electrons can enter that room.</p><p>But once they’re inside,</p><p>they have nowhere to go.</p><p>Even after removing power,</p><p>they remain trapped for years.</p><p>Those trapped electrons become our memory.</p><h3>Storing a Bit</h3><p>Let’s use the same rule we’ve used throughout this series.</p><pre>Electrons Trapped<br>  ↓<br>  1</pre><pre>No Electrons<br>  ↓  <br>  0</pre><p>(Real NAND implementations may use the opposite convention depending on design, but the important idea is that two distinct states represent a bit.)</p><p>Unlike DRAM,</p><p>nothing leaks away within milliseconds.</p><p>Unlike a hard disk,</p><p>nothing needs to rotate.</p><p>The electrons simply stay where they are.</p><h4>Reading Without Touching</h4><p>Suppose the operating system asks,</p><blockquote><em>“Is this bit a 0 or a 1?”</em></blockquote><p>With DRAM,</p><p>we connected the capacitor to the Bit Line.</p><p>With a hard disk,</p><p>we measured a magnetic field.</p><p>Flash memory does something different.</p><p>It never removes the trapped electrons.</p><p>Instead,</p><p>it observes how those trapped electrons affect the transistor.</p><p>Their presence changes how easily the transistor turns ON.</p><p>By measuring that behavior,</p><p>the SSD controller determines the stored value.</p><p>The memory survives the read operation.</p><p>Nothing needs to be restored afterward.</p><h4>Writing Is Harder Than Reading</h4><p>Reading is relatively simple.</p><p>Writing is much more difficult.</p><p>To trap electrons inside the Floating Gate,</p><p>the SSD briefly generates a much higher voltage than the computer normally uses.</p><p>Those electrons are forced through an extremely thin insulating layer.</p><p>Once enough electrons become trapped,</p><p>the voltage disappears.</p><p>The electrons stay behind.</p><p>Programming a Flash cell takes much longer than reading one.</p><h4>Erasing Is Even Stranger</h4><p>Suppose you want to change one bit.</p><p>Easy?</p><p>Not quite.</p><p>Flash memory cannot simply overwrite existing data.</p><p>Instead,</p><p>it first has to remove the trapped electrons.</p><p>Here’s the surprising part.</p><p>It can’t erase a single page.</p><p>It must erase an entire block.</p><p>Imagine a notebook.</p><p>You only want to erase one sentence.</p><p>Someone hands you an eraser and says,</p><blockquote><em>“You have to erase every page first.”</em></blockquote><p>That sounds ridiculous.</p><p>Yet that’s exactly how NAND Flash works.</p><h4>Pages and Blocks</h4><p>To manage this limitation,</p><p>Flash memory is organized into two levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*t7PPgzsP16uiihcKL4nD3A.png" /></figure><p>A page is the smallest unit that can be read or programmed.</p><p>A block is the smallest unit that can be erased.</p><p>This design makes the hardware much simpler.</p><p>But it introduces new software challenges.</p><h4>The Hidden Work Inside Every SSD</h4><p>Imagine changing just one page.</p><p>The SSD cannot simply overwrite it.</p><p>Instead it usually performs something like this:</p><ol><li>Read the remaining valid pages.</li><li>Copy them elsewhere.</li><li>Erase the entire block.</li><li>Write the valid pages back.</li><li>Write the updated page.</li></ol><p>Your operating system never sees these extra steps.</p><p>The SSD controller performs them automatically.</p><p>This background cleanup process is called <strong>Garbage Collection</strong>.</p><h4>Flash Memory Wears Out</h4><p>Every erase operation slightly damages the insulating layer inside the Floating Gate.</p><p>Eventually,</p><p>after enough erase cycles,</p><p>the cell can no longer reliably trap electrons.</p><p>Does that mean SSDs wear out quickly?</p><p>Not really.</p><p>Because the controller has another clever trick.</p><p>Instead of repeatedly writing to the same physical location,</p><p>it spreads writes across the entire drive.</p><p>This process is called <strong>Wear Leveling</strong>.</p><p>The goal is simple.</p><p>Make every part of the SSD age together.</p><h4>The Real Brain of an SSD</h4><p>Most people think the NAND chips are the interesting part.</p><p>They’re important.</p><p>But they’re only half of the story.</p><p>Every SSD also contains a controller.</p><p>Think of it as a tiny computer dedicated to storage.</p><p>It continuously performs tasks like:</p><ul><li>Mapping logical addresses to physical locations.</li><li>Correcting bit errors.</li><li>Managing garbage collection.</li><li>Performing wear leveling.</li><li>Replacing worn-out blocks.</li><li>Scheduling reads and writes.</li></ul><p>To your operating system,</p><p>the SSD appears simple.</p><p>Behind the scenes,</p><p>it’s constantly reorganizing data.</p><h4>💡 Why This Matters</h4><p>When your application saves a file,</p><p>it feels like the data is written directly to a fixed location.</p><p>Often…</p><p>it isn’t.</p><p>The SSD quietly stores the data somewhere else,</p><p>updates its internal mapping table,</p><p>marks the old location as obsolete,</p><p>and cleans everything up later.</p><p>That’s why SSDs behave very differently from hard disks,</p><p>even though both appear as ordinary drives to your operating system.</p><h4>We’ve Built Modern Storage</h4><p>Let’s step back and look at the computer we’ve built throughout this series.</p><pre>CPU Registers<br>  ↓<br>CPU Cache (SRAM)<br>  ↓<br>System RAM (DRAM)<br>  ↓<br>SSD (NAND Flash)</pre><p>Every layer solves a different problem.</p><p>Registers provide incredible speed.</p><p>SRAM keeps the CPU moving.</p><p>DRAM offers large, affordable memory.</p><p>Flash remembers everything without power.</p><p>None of them replace one another.</p><p>They work together.</p><h4>What’s Next after this series</h4><p><a href="https://medium.com/@shiviraj/looking-at-computers-differently-e21f2e66aded">How I start Looking at Computers Differently</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7294e7c3460" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Can a Computer Remember Without Power?]]></title>
            <link>https://shiviraj.medium.com/how-can-a-computer-remember-without-power-11904425c53d?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/11904425c53d</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 12:01:01 GMT</pubDate>
            <atom:updated>2026-07-22T14:00:19.611Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 5 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><p><a href="https://shiviraj.medium.com/we-need-to-talk-about-cpu-cache-c12254ba72de"><strong><em>Missed Part 4</em></strong></a><strong><em>? </em></strong><em>In the previous chapter, we discovered why CPUs use SRAM while the rest of the computer uses DRAM. Today, we’re going to answer another question.</em></p><p><strong><em>If RAM forgets everything when the power is removed, where does your data actually live?</em></strong></p><h4>📚 How Computers Actually Work — Series</h4><ul><li>✅ Part 1 — We Need to Talk About RAM</li><li>✅ Part 2 — How Does a Computer Remember a Single Bit?</li><li>✅ Part 3 — Why Does RAM Read an Entire Row?</li><li>✅ Part 4 — We Need to Talk About CPU Cache</li><li><strong>👉 Part 5 — How Can a Computer Remember Without Power?</strong> <em>(You’re reading)</em></li><li>Part 6 — How Can a Computer Remember Without a Disk?</li></ul><h4>Everything We’ve Built So Far Has One Problem</h4><p>Let’s look at the computer we’ve built together.</p><pre>CPU Registers<br>    ↓<br>CPU Cache (SRAM)<br>    ↓<br>System RAM (DRAM)</pre><p>It’s incredibly fast.</p><p>Registers respond almost instantly.</p><p>CPU Cache keeps frequently used data close.</p><p>DRAM stores gigabytes of information.</p><p>But every one of them shares the same weakness.</p><p>Turn off the power…</p><p>Everything disappears.</p><p>Your browser tabs vanish.</p><p>Your running applications disappear.</p><p>Even the operating system itself is gone.</p><p>Clearly…</p><p>Computers need another kind of memory.</p><p>One that remembers even without electricity.</p><h4>Imagine Writing on Sand</h4><p>Suppose you write your name on a beach.</p><pre>Shivam</pre><p>A wave arrives.</p><p>Everything disappears.</p><p>Now write your name on a stone.</p><p>Years later…</p><p>It’s still there.</p><p>RAM is like writing on sand.</p><p>As long as power exists, everything is fine.</p><p>Remove power…</p><p>The information disappears.</p><p>What we need is something closer to stone.</p><p>Something permanent.</p><h4>🤔 Think Like an Engineer</h4><p>Imagine you’re building the first computer.</p><p>Capacitors don’t work.</p><p>SRAM doesn’t work.</p><p>Both lose their data when power disappears.</p><p>So here’s the challenge.</p><blockquote><strong><em>Can we store information without requiring continuous electricity?</em></strong></blockquote><p>Engineers solved this problem using magnetism.</p><h4>Electricity Comes and Goes</h4><p>Magnetism Doesn’t</p><p>Take a simple refrigerator magnet.</p><p>Stick it to the fridge.</p><p>Come back tomorrow.</p><p>It’s still magnetic.</p><p>Come back next year.</p><p>Still magnetic.</p><p>Unlike electrical charge…</p><p>Magnetic orientation doesn’t disappear when power is removed.</p><p>That simple observation changed computing forever.</p><h4>Meet the Hard Disk</h4><p>A Hard Disk Drive — or HDD — is surprisingly mechanical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMkQl6U4Xx5hJBxlPCmwAg.png" /></figure><p>Inside it you’ll find:</p><ul><li>One or more spinning metal platters.</li><li>A powerful motor.</li><li>An actuator arm.</li><li>Tiny read/write heads.</li></ul><p>It looks more like a miniature record player than a computer component.</p><p>The platters spin thousands of times every minute.</p><p>Typically:</p><ul><li>5,400 RPM</li><li>7,200 RPM</li><li>10,000 RPM</li><li>15,000 RPM</li></ul><p>While they spin…</p><p>The read/write head moves across the surface.</p><h4>How Can a Disk Store a Bit?</h4><p>Imagine the surface of the disk divided into billions of microscopic magnetic regions.</p><p>Each tiny region can be magnetized in one direction or the other.</p><p>Think of them like countless tiny compass needles.</p><pre>↑ ↑ ↓ ↓ ↑ ↓ ↑ ↑</pre><p>One direction might represent:</p><pre>1</pre><p>The opposite direction:</p><pre>0</pre><p>Unlike electrical charge,</p><p>these magnetic orientations remain stable without power.</p><p>That’s why your files survive after shutting down the computer.</p><h4>Writing Data</h4><p>Writing is surprisingly simple in principle.</p><p>The write head contains a tiny electromagnet.</p><p>When current flows through it,</p><p>a magnetic field is created.</p><p>That magnetic field changes the orientation of the tiny magnetic regions beneath it.</p><p>Move across the disk…</p><p>Repeat billions of times…</p><p>You’ve written a file.</p><h4>Reading Data</h4><p>Reading works differently.</p><p>The head no longer changes the disk.</p><p>Instead…</p><p>It senses the magnetic field produced by each tiny region.</p><p>As the platter spins beneath the head,</p><p>the changing magnetic fields become electrical signals.</p><p>Those signals are converted back into binary.</p><p>The operating system eventually sees:</p><pre>010101101...</pre><p>The process happens millions of times every second.</p><h4>Organizing the Disk</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k07jVLFEtJUY3Ma-SKdtTA.png" /></figure><p>Imagine trying to find one bit on an empty circular platter.</p><p>Impossible.</p><p>So engineers organize the surface.</p><p>First into <strong>Tracks</strong>.</p><p>Each circle is a track.</p><p>Next,</p><p>each track is divided into <strong>Sectors</strong>.</p><p>Every file ultimately lives inside one or more sectors.</p><p>The operating system never thinks about magnetic regions.</p><p>It thinks about sectors.</p><h4>Reading a File</h4><p>Suppose your application requests a file.</p><p>The hard disk has to perform three separate tasks.</p><p>First…</p><p>Move the read head to the correct track.</p><p>This is called <strong>Seek Time</strong>.</p><p>Second…</p><p>Wait for the spinning platter to rotate until the correct sector arrives beneath the head.</p><p>This is called <strong>Rotational Latency</strong>.</p><p>Finally…</p><p>Read the data as the platter continues spinning.</p><p>Only then can the bytes travel back to RAM.</p><h4>The Biggest Weakness</h4><p>At this point you may have noticed something.</p><p>Everything inside an HDD moves.</p><p>The platter spins.</p><p>The motor rotates.</p><p>The actuator arm swings.</p><p>The read head travels back and forth.</p><p>Mechanical movement is slow.</p><p>Not because the engineers weren’t clever.</p><p>Because physics has limits.</p><p>No matter how fast your CPU becomes…</p><p>A metal arm still needs time to move.</p><h4>💡 Why This Matters</h4><p>Imagine reading two files.</p><p>File A.</p><p>Located next to the previous file.</p><p>The head barely moves.</p><p>Fast.</p><p>File B.</p><p>Located on the opposite side of the disk.</p><p>Now the head travels across the platter.</p><p>The disk rotates.</p><p>Only then can reading begin.</p><p>That’s why <strong>sequential access</strong> is dramatically faster than <strong>random access</strong> on hard disks.</p><p>We’ll return to this idea in the final chapter.</p><h4>The Next Engineering Challenge</h4><p>Hard disks solved one enormous problem.</p><p>They remembered data without power.</p><p>But they introduced another.</p><p>Moving parts.</p><p>Motors.</p><p>Noise.</p><p>Heat.</p><p>Mechanical delays.</p><p>Engineers started asking a new question.</p><blockquote><strong><em>What if we could keep permanent storage… but remove every moving part?</em></strong></blockquote><p>That question led to one of the biggest changes in modern computing.</p><p>That’s exactly what we’ll discover in the <a href="https://medium.com/@shiviraj/how-can-a-computer-remember-without-a-disk-b7294e7c3460">next chapter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11904425c53d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Need to Talk About CPU Cache]]></title>
            <link>https://shiviraj.medium.com/we-need-to-talk-about-cpu-cache-c12254ba72de?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/c12254ba72de</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[memories]]></category>
            <category><![CDATA[cpu]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 04:44:25 GMT</pubDate>
            <atom:updated>2026-07-20T12:02:40.655Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 4 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><p><a href="https://shiviraj.medium.com/why-does-ram-read-an-entire-row-0f5459d81c90"><strong><em>Missed Part 3?</em></strong></a><strong><em> </em></strong><em>In the previous chapter, we discovered that DRAM reads an entire row, uses Sense Amplifiers, and temporarily stores the data inside a Row Buffer. Today, we’re going to answer another question.</em></p><p><strong><em>If DRAM is already so smart, why doesn’t the CPU use it directly?</em></strong></p><h4>📚 How Computers Actually Work — Series</h4><ul><li>✅ Part 1 — We Need to Talk About RAM</li><li>✅ Part 2 — How Does a Computer Remember a Single Bit?</li><li>✅ Part 3 — Why Does RAM Read an Entire Row?</li><li><strong>👉 Part 4 — We Need to Talk About CPU Cache </strong><em>(You’re reading)</em></li><li>Part 5 — How Can a Computer Remember Without Power?</li><li>Part 6 — How Can a Computer Remember Without a Disk?</li></ul><h4>We’ve Built RAM</h4><p>So far, we’ve built an impressive system.</p><p>A DRAM cell stores one bit.</p><p>Billions of those cells form a memory array.</p><p>Rows and columns reduce the number of wires.</p><p>Sense Amplifiers detect tiny voltage changes.</p><p>Row Buffers make repeated accesses faster.</p><p>It almost sounds perfect.</p><p>Almost.</p><p>Because there’s one problem.</p><p>The CPU is getting impatient.</p><h4>Imagine You’re a Chef</h4><p>Imagine you’re cooking.</p><p>Every few seconds you need a knife.</p><p>The knife is in another room.</p><p>So every time you need it, you:</p><ul><li>Walk to the cupboard.</li><li>Open the door.</li><li>Pick up the knife.</li><li>Walk back.</li><li>Continue cooking.</li></ul><p>Nothing is wrong with the cupboard.</p><p>It’s simply too far away.</p><p>Eventually…</p><p>You spend more time walking than cooking.</p><p>That’s exactly what happens inside a computer.</p><h4>CPUs Are Incredibly Fast</h4><p>Modern processors execute billions of instructions every second.</p><p>They can perform arithmetic in just a few clock cycles.</p><p>DRAM, on the other hand, needs time to:</p><ul><li>Open a row.</li><li>Share charge.</li><li>Detect the voltage.</li><li>Restore the data.</li><li>Close the row.</li></ul><p>That’s a lot of work.</p><p>If the CPU had to wait for DRAM after every instruction…</p><p>Most of its time would be spent waiting.</p><p>Engineers even gave this problem a name.</p><blockquote><strong><em>The Memory Wall.</em></strong></blockquote><p>As processors became faster…</p><p>Memory couldn’t keep up.</p><h4>🤔 Think Like an Engineer</h4><p>You have two choices.</p><p>Option 1.</p><p>Make DRAM dramatically faster.</p><p>Option 2.</p><p>Move frequently used data closer to the CPU.</p><p>Which sounds easier?</p><p>Engineers chose the second option.</p><h4>Keep the Important Things Nearby</h4><p>Let’s return to our kitchen example.</p><p>Instead of walking to the cupboard every time…</p><p>You place the knife on the kitchen counter.</p><p>Now the cupboard still exists.</p><p>It still stores everything.</p><p>But the items you use most often stay close to you.</p><p>Computers do exactly the same thing.</p><p>Instead of reading everything from DRAM…</p><p>The CPU keeps a tiny copy of frequently used data inside itself.</p><p>That tiny memory is called the <strong>CPU Cache</strong>.</p><h4>Why Not Build the Cache Using DRAM?</h4><p>At first, this sounds obvious.</p><p>Why not put a tiny DRAM chip inside the processor?</p><p>We already know DRAM works.</p><p>The answer lies in what we learned in the previous part.</p><p>Reading DRAM isn’t simple.</p><p>Every access requires:</p><ul><li>Activating a row.</li><li>Charge sharing.</li><li>Sense amplification.</li><li>Restoring the original value.</li></ul><p>The CPU doesn’t want to perform all of that for every read.</p><p>It wants memory that behaves more like this.</p><pre>Read =&gt; Done</pre><p>No refresh.</p><p>No restore.</p><p>No destructive reads.</p><p>That means DRAM isn’t the right technology.</p><p>We need another kind of memory.</p><h4>Forget the Bucket</h4><p>In Part 2, we used a bucket to store electrical charge.</p><p>That bucket was our capacitor.</p><p>This time…</p><p>Imagine someone takes the bucket away.</p><p>You are no longer allowed to store charge.</p><p>Can you still build memory?</p><p>Surprisingly…</p><p>Yes.</p><p>Instead of storing electricity…</p><p>We’re going to build a circuit that remembers its own state.</p><p>In the previous parts, we discovered something important.</p><p>A capacitor can hold electrical charge.</p><p>A wire cannot.</p><p>A wire is like a road.</p><p>It allows electrical charge to travel from one place to another.</p><p>But the moment you stop driving charge into it, there’s nothing left to remember.</p><p>So simply replacing the capacitor with a wire doesn’t solve our problem.</p><p>We still need something that can remember a 0 or a 1.</p><p>But what if…</p><p>Instead of <strong>storing</strong> charge,</p><p>we never stopped <strong>driving</strong> it?</p><h4>Let’s Build the Simplest Circuit</h4><p>Forget memory for a moment.</p><p>Let’s build one of the simplest digital circuits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*KRT1IDZRFpoV5ODBHtMrNg.png" /></figure><p>An <strong>inverter</strong>.</p><p>Its entire job is to flip the input.</p><p>If the input is 1, the output becomes 0.</p><p>If the input is 0, the output becomes 1.</p><pre>Input → Inverter → Output<br>  1 ─────────────► 0<br>  0 ─────────────► 1</pre><p>Simple enough.</p><p>Now let’s build another one.</p><h4>Now Let’s Do Something Strange</h4><p>Take two inverters.</p><p>Connect the output of the first to the input of the second.</p><p>Then connect the output of the second back into the input of the first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ux2cA8M57lu2O94FyR9Fgw.png" /></figure><p>At first glance, this seems like a terrible idea.</p><p>Wouldn’t they keep changing forever?</p><p>Let’s try it.</p><p>Suppose the first inverter somehow starts by outputting 1.</p><p>That forces the second inverter to output 0.</p><p>Now that 0 goes back into the first inverter.</p><p>Which tells the first inverter to keep outputting 1.</p><p>Nothing changes.</p><p>The circuit has settled into a stable state.</p><p>The opposite state works just as well.</p><pre>Q = 1      Q̅ = 0<br><br>OR<br><br>Q = 0      Q̅ = 1</pre><h4>Wait… Did We Just Build Memory?</h4><p>Here’s the clever part.</p><p>Nothing is being stored inside a capacitor any more.</p><p>Nothing is slowly leaking away.</p><p>Instead, the two inverters continuously reinforce each other’s outputs.</p><p>As long as power is available, each inverter keeps driving the other into the same state.</p><p>The value doesn’t fade.</p><p>It doesn’t need refreshing.</p><p>Reading it won’t destroy it.</p><p>Without realizing it…</p><p>We’ve built a tiny memory cell.</p><p>Engineers call this arrangement a <strong>bistable latch</strong>, and it’s the heart of every SRAM cell.</p><h4>But We Still Need to Read It</h4><p>Our latch remembers perfectly.</p><p>Now the CPU wants to read it.</p><p>How do we connect the latch to the outside world without permanently attaching wires?</p><p>The answer should sound familiar.</p><p>We add switches.</p><p>Two additional MOSFETs connect the latch to two Bit Lines.</p><p>Normally…</p><p>Those switches remain OFF.</p><p>When the CPU activates the Word Line…</p><p>The switches open.</p><p>Now the CPU can communicate with the latch.</p><p>During a write…</p><p>The Bit Lines force the latch into a new state.</p><p>During a read…</p><p>The latch drives the Bit Lines.</p><p>Notice something remarkable.</p><p>The latch keeps remembering the value throughout the entire operation.</p><p>Reading doesn’t destroy anything.</p><h4>Turning This Idea into an SRAM Cell</h4><p>A real SRAM cell doesn’t use the simple logic-gate symbols shown above.</p><p>Instead, engineers build the same feedback loop using <strong>six MOSFETs</strong>.</p><p>Four transistors form the two cross-coupled CMOS inverters.</p><p>Two additional transistors act as switches, connecting the latch to the Bit Lines whenever the Word Line becomes HIGH.</p><p>This design is known as a <strong>6T SRAM Cell</strong>.</p><p>The idea, however, is exactly the same.</p><p>The two inverters keep reinforcing each other, allowing the circuit to remember one bit for as long as power is available.</p><h4>Why SRAM Is So Fast</h4><p>Think about everything DRAM had to do.</p><ul><li>Store charge.</li><li>Fight leakage.</li><li>Share charge.</li><li>Detect tiny voltages.</li><li>Restore the data.</li><li>Refresh periodically.</li></ul><p>Now compare that with SRAM.</p><p>The latch already knows its state.</p><p>Reading simply observes it.</p><p>No refresh.</p><p>No restore.</p><p>No charge sharing.</p><p>That’s why SRAM is dramatically faster.</p><h4>Then Why Doesn’t Everything Use SRAM?</h4><p>This seems like an easy decision.</p><p>SRAM is faster.</p><p>It doesn’t refresh.</p><p>Reading is non-destructive.</p><p>Problem solved.</p><p>Except…</p><p>There’s a cost.</p><p>Remember our tiny DRAM cell?</p><pre>1 MOSFET + 1 Capacitor</pre><p>An SRAM cell needs approximately six MOSFETs.</p><p>Much larger.</p><p>Much more silicon.</p><p>Much more expensive.</p><p>Now imagine building <strong>32 GB</strong> of SRAM.</p><p>The chip would become enormous.</p><p>That’s why engineers compromised.</p><p>A tiny amount of SRAM sits inside the CPU.</p><p>A much larger amount of DRAM sits outside it.</p><p>Each technology solves a different problem.</p><h4>💡 Why This Matters</h4><p>Every time your application accesses a variable…</p><p>The CPU first checks:</p><ol><li>Registers: Registers are tiny memory cells built from flip-flops (special latch circuits) that continuously hold their state while power is available</li><li>L1 Cache</li><li>L2 Cache</li><li>L3 Cache</li><li>DRAM</li></ol><p>Only if the data isn’t found, it travel to the next level.</p><p>That’s why terms like <strong>Cache Hit</strong> and <strong>Cache Miss</strong> matter so much.</p><p>They’re describing real hardware decisions happening billions of times every second.</p><h4>We’ve Built the Memory Hierarchy</h4><p>At this point, our computer looks like this.</p><pre>CPU Registers<br>   ↓<br>CPU Cache (SRAM)<br>   ↓<br>System RAM (DRAM)</pre><p>Every layer trades one thing for another.</p><p>Registers are tiny but incredibly fast.</p><p>CPU Cache is larger but slightly slower.</p><p>DRAM is much larger but slower again.</p><p>Together they allow modern computers to balance speed and capacity.</p><p>But there’s still one problem.</p><p>Turn the power off…</p><p>And every layer we’ve built so far forgets everything.</p><p>How does your operating system survive a reboot?</p><p>How does your database still exist tomorrow morning?</p><p>That’s where our <a href="https://shiviraj.medium.com/how-can-a-computer-remember-without-power-11904425c53d">next chapter</a> begins.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c12254ba72de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Does RAM Read an Entire Row?]]></title>
            <link>https://shiviraj.medium.com/why-does-ram-read-an-entire-row-0f5459d81c90?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f5459d81c90</guid>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[memories]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[rams]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 04:41:23 GMT</pubDate>
            <atom:updated>2026-07-19T04:45:02.818Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 3 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><p><a href="https://shiviraj.medium.com/how-does-a-computer-remember-a-single-bit-2767a3a2af76?sharedUserId=shiviraj"><strong><em>Missed Part 2</em></strong></a><strong><em>? </em></strong><em>In the previous chapter, we built the smallest DRAM memory cell using one capacitor and one MOSFET. Today, we’re going to answer another question.</em></p><p><strong><em>How do billions of those tiny cells become the RAM inside your computer?</em></strong></p><h4>📚 How Computers Actually Work — Series</h4><ul><li>✅ Part 1 — We Need to Talk About RAM</li><li>✅ Part 2 — How Does a Computer Remember a Single Bit?</li><li><strong>👉 Part 3 — Why Does RAM Read an Entire Row?</strong> <em>(You’re reading)</em></li><li>Part 4 — We Need to Talk About CPU Cache</li><li>Part 5 — How Can a Computer Remember Without Power?</li><li>Part 6 — How Can a Computer Remember Without a Disk?</li></ul><h4>One Bit Isn’t Very Useful</h4><p>In the previous chapter, we successfully built a memory cell.</p><p>It could remember exactly one bit.</p><pre>1</pre><p>That’s an incredible engineering achievement.</p><p>Unfortunately…</p><p>Your laptop doesn’t need one bit.</p><p>A typical laptop with <strong>16 GB of RAM</strong> contains more than <strong>137 billion bits</strong>.</p><p>That means we’d need more than <strong>137 billion copies</strong> of the tiny circuit we built.</p><p>Now a new problem appears.</p><p>How do we connect all of them?</p><h4>Attempt #1 — Give Every Cell Its Own Wire</h4><p>Imagine we build one billion memory cells.</p><p>The simplest idea is obvious.</p><p>Give every cell its own control wire.</p><p>Its own data wire.</p><p>Like this.</p><pre>CPU<br>│<br>├──────── Cell 1<br>├──────── Cell 2<br>├──────── Cell 3<br>├──────── ...</pre><p>Simple.</p><p>Easy to understand.</p><p>Completely impossible.</p><p>Imagine routing billions of individual wires across a tiny memory chip.</p><p>The chip would become enormous.</p><p>Most of it would be wires instead of memory.</p><p>Clearly…</p><p>We need a better idea.</p><h4>🤔 Think Like an Engineer</h4><p>When engineers need to connect millions of things, they rarely create millions of independent connections.</p><p>Instead…</p><p>They look for something that can be shared.</p><p>Roads.</p><p>Railways.</p><p>Power lines.</p><p>Internet cables.</p><p>Everything is shared.</p><p>Can memory do the same?</p><h4>Borrowing an Idea From a Spreadsheet</h4><p>Think about a spreadsheet.</p><pre>     A   B   C   D<br>1    □   □   □   □<br>2    □   □   □   □<br>3    □   □   □   □<br>4    □   □   □   □</pre><p>You don’t identify a cell using a unique wire.</p><p>You simply say,</p><blockquote><em>Row 3 Column B</em></blockquote><p>Two numbers.</p><p>That’s enough.</p><p>Memory engineers had exactly the same idea.</p><p>Instead of arranging memory cells randomly…</p><p>They organized them into rows and columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*GZVpzq6ae0lyA6aEgapvNQ.png" /></figure><h4>Sharing Wires</h4><p>Suppose every cell in the same row shares one control wire.</p><p>Instead of having thousands of individual control wires…</p><p>We now have just one.</p><p>Engineers call this wire the <strong>Word Line</strong>.</p><pre>WL0 ─────────────────────────<br>WL1 ─────────────────────────<br>WL2 ─────────────────────────<br>WL3 ─────────────────────────</pre><p>Remember the MOSFET from the previous chapter?</p><p>The gate of every MOSFET in the same row connects to the same Word Line.</p><p>Raise that line to a high voltage…</p><p>Every switch in that row opens together.</p><h4>Sharing Another Wire</h4><p>Now let’s solve the second problem.</p><p>How do we move data?</p><p>Instead of giving every memory cell its own data wire…</p><p>Every column shares one.</p><p>Engineers call it the <strong>Bit Line</strong>.</p><pre>BL0<br>│<br>□<br>│<br>□<br>│<br>□<br>│<br>□</pre><p>Now our memory starts looking like this.</p><pre>         BL0  BL1  BL2  BL3<br>WL0       □    □    □    □<br>WL1       □    □    □    □<br>WL2       □    □    □    □<br>WL3       □    □    □    □</pre><p>Congratulations.</p><p>We’ve just built the basic layout used inside every DRAM chip.</p><h4>Reading One Bit… Or Are We?</h4><p>Imagine the CPU wants the bit stored here.</p><pre>         BL0  BL1  BL2  BL3<br>WL2       □   [■]   □    □</pre><p>Your first thought might be,</p><blockquote><em>“Open that one MOSFET.”</em></blockquote><p>But look carefully.</p><p>Every MOSFET in the same row shares the same Word Line.</p><p>If we activate <strong>WL2</strong>…</p><p>We don’t open one transistor.</p><p>We open every transistor in that row.</p><pre>         BL0  BL1  BL2  BL3<br>WL2      [■]  [■]  [■]  [■]</pre><p>This is one of the biggest surprises in computer architecture.</p><p><strong>DRAM doesn’t read one cell.</strong></p><p>It reads an entire row.</p><h4>That Sounds Wasteful</h4><p>Imagine asking for one word from a book.</p><p>Instead of opening just that word…</p><p>Someone opens the entire page.</p><p>At first…</p><p>That sounds inefficient.</p><p>Until you realize something.</p><p>The next word you read is probably on the same page.</p><p>Computers behave the same way.</p><p>If the CPU asks for one byte…</p><p>There’s a good chance it’ll soon ask for the next byte as well.</p><p>Reading the entire row once is often cheaper than repeatedly opening individual cells.</p><h4>There’s One More Clever Trick</h4><p>In the previous chapter, we met the <strong>Sense Amplifier</strong>.</p><p>We said it detects tiny voltage changes and restores the original value.</p><p>But engineers realized something.</p><p>Once the Sense Amplifier has already read the entire row…</p><p>Why throw that information away?</p><p>Instead…</p><p>It keeps holding the values.</p><p>That temporary storage is called the <strong>Row Buffer</strong>.</p><p>Think of it as an open page in a book.</p><p>As long as you’re reading from that page…</p><p>Everything is fast.</p><h4>Row Hit</h4><p>Suppose the CPU requests another value from the same row.</p><p>Good news.</p><p>The row is already open.</p><p>The Sense Amplifiers already know every value.</p><p>The Row Buffer already contains the data.</p><p>The controller simply selects the required bits.</p><p>This is called a <strong>Row Hit</strong>.</p><p>And it’s very fast.</p><h4>Row Miss</h4><p>Now imagine the CPU suddenly requests data from another row.</p><p>The current Row Buffer belongs to the old row.</p><p>Before opening the new one, the controller must:</p><ul><li>Restore the old row.</li><li>Close it.</li><li>Precharge the Bit Lines.</li><li>Open the new row.</li><li>Read every capacitor.</li><li>Refill the Row Buffer.</li></ul><p>Only then can it return the requested data.</p><p>This is called a <strong>Row Miss</strong>.</p><p>It’s significantly slower.</p><h4>💡 Why This Matters</h4><p>You’ve probably heard advice like:</p><ul><li>“Sequential access is faster than random access.”</li><li>“Cache locality improves performance.”</li><li>“Database pages should be read sequentially.”</li></ul><p>This is one of the reasons.</p><p>Hardware prefers nearby data.</p><p>Not because software says so.</p><p>Because that’s how memory is physically built.</p><h4>We’ve Built Real Memory</h4><p>In the previous chapter, we built one memory cell.</p><p>Today, we connected billions of them into a usable memory array.</p><p>We discovered that RAM doesn’t think in terms of individual bits.</p><p>It thinks in rows.</p><p>And that explains one of the most surprising facts about modern computers.</p><p>When your CPU asks for a single byte…</p><p>Your RAM quietly wakes up thousands of bits behind the scenes.</p><p>In the next chapter, we’ll answer another question.</p><p>If DRAM is already this clever…</p><p><a href="https://shiviraj.medium.com/we-need-to-talk-about-cpu-cache-c12254ba72de">Why does the CPU still need another type of memory</a>?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f5459d81c90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s build and Analyze a 1T1C DRAM Cell]]></title>
            <link>https://shiviraj.medium.com/building-and-analyzing-a-1t1c-dram-cell-6cbad1104b26?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cbad1104b26</guid>
            <category><![CDATA[digital-electronics]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[hardware-engineering]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 19:28:38 GMT</pubDate>
            <atom:updated>2026-07-22T13:57:42.909Z</atom:updated>
            <content:encoded><![CDATA[<p>Companion article to <a href="https://shiviraj.medium.com/how-does-a-computer-remember-a-single-bit-2767a3a2af76?sharedUserId=shiviraj">How Does a Computer Remember a Single Bit</a>? <em>This article assumes you’re comfortable with basic electronics, MOSFETs, capacitors, voltage, and current.</em></p><p><em>Instead of explaining </em>what<em> DRAM does, we’ll explain </em><strong><em>how</em></strong><em> it works electrically.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*BqcUT4UY3dFbagW8xD1EnA.png" /></figure><h3>Introduction</h3><p>In the main article, we learned that a DRAM cell stores one bit using only two components:</p><ul><li>One MOSFET</li><li>One Capacitor</li></ul><p>That explanation was intentionally simplified.</p><p>In this article we’ll ignore software completely.</p><p>We’ll analyze the DRAM cell exactly as an electronics engineer would.</p><p>We’ll discuss:</p><ul><li>1T1C cell architecture</li><li>MOSFET operation</li><li>Capacitor charging</li><li>Read cycle</li><li>Charge sharing</li><li>Sense amplifier requirements</li><li>Restoration</li><li>Refresh</li><li>Cell sizing</li></ul><h4>The Simplest DRAM Cell</h4><p>The circuit consists of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Fz64yUn3TkFeB6szFqGU7Q.png" /></figure><p>Where</p><ul><li>WL controls the MOSFET.</li><li>BL transfers data.</li><li>Ccell (Capacitor cell) stores electrical charge.</li></ul><h4>The Three Operating Modes</h4><p>The cell has only three operating states.</p><h4>1. Idle</h4><p>WL = LOW</p><p>MOSFET OFF.</p><p>The storage capacitor is electrically isolated.</p><p>No current flows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*avgMXRc2WABo32ghhLYKWA.png" /></figure><h4>2. Write</h4><pre>WL = HIGH</pre><p>MOSFET ON.</p><p>Bit Line drives the capacitor.</p><h4>3. Read</h4><pre>WL = HIGH</pre><p>MOSFET ON.</p><p>Capacitor shares charge with the Bit Line.</p><h4>Writing a Logic 1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*VisG33fuLookmXetJSbseQ.png" /></figure><p>Suppose</p><p>VDD = 1.2V</p><p>Initial capacitor voltage</p><p>Vc = 0V</p><p>Bit Line</p><p>BL = 1.2V</p><p>WL becomes HIGH.</p><p>MOSFET enters the linear region.</p><p>Current begins flowing</p><p>Bit Line =&gt; MOSFET =&gt; Capacitor</p><p>The capacitor voltage follows the familiar RC charging equation.</p><pre>Vc(t)=VDD(1-e^{-t/RC})</pre><p>Initially</p><p>Vc = 0V</p><p>After one time constant</p><p>Vc ≈ 0.76V</p><p>After approximately five time constants</p><p>Vc ≈ 1.19V</p><p>The controller waits long enough to guarantee a complete write.</p><p>WL then returns LOW.</p><p>The capacitor is isolated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*UZlEi0c6A0VbZoGnVLmQzg.png" /></figure><h4>Writing a Logic 0</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*HFF1vG_YqGarCk6Zdr0Iug.png" /></figure><p>The sequence is identical.</p><p>Except</p><p>BL = 0V</p><p>Current now flows in the opposite direction.</p><p>The capacitor discharges according to</p><pre>Vc(t)=Vinitial e^{-t/RC}</pre><p>Again,</p><p>WL returns LOW after sufficient settling time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*iqE-4aeW6BcQA5pDl8rVKQ.png" /></figure><h4>Why Reading Is Difficult</h4><p>Reading cannot simply measure the capacitor.</p><p>Connecting a measuring circuit changes the stored charge.</p><p>This is the fundamental problem of DRAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*sh_UWTxj0ThOdiEinHZceA.png" /></figure><p>Suppose</p><p>Cell Capacitance = 30 fF</p><p>Bit Line Capacitance = 300 fF</p><p>Notice CBL &gt;&gt; Ccell</p><p>The Bit Line is roughly ten times larger.</p><h4>Bit Line Precharge</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*0nbAH-juqL9Ky7CxBhoaPg.png" /></figure><p>Before every read,</p><p>the memory controller precharges the Bit Line.</p><p>Typically</p><p>BL = VDD/2</p><p>For VDD = 1.2V</p><p>BL = 0.6V</p><p>This allows detection of either a positive or negative voltage change.</p><h4>Charge Sharing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*Dh_lUhaxBinrdTS2eWUEfQ.png" /></figure><p>Assume</p><p>Vc = 1.2V</p><p>BL = 0.6V</p><p>Initially,</p><p>the capacitor and Bit Line are isolated.</p><p>MOSFET OFF</p><p>The controller asserts</p><p>WL = HIGH</p><p>Now both capacitors become electrically connected.</p><p>Charge redistributes until both nodes reach a common voltage.</p><p>Using charge conservation,</p><p>Qbefore = Qafter</p><pre>(Ccell * Vc) + (CBL * VBL) = (Ccell+CBL) * Vfinal</pre><p>Substitute</p><pre>30fF × 1.2 + 300fF × 0.6 = 330fF × Vfinal<br>36 + 180 = 330V<br>216 = 330V<br>Vfinal ≈ 0.655V</pre><p>Notice something interesting.</p><p>The Bit Line moved</p><pre>0.600V <br>  ↓<br>0.655V</pre><p>Only</p><pre>55mV</pre><p>Yet that’s enough.</p><h4>Why Doesn’t It Become 0.9V?</h4><p>A common misunderstanding is assuming both nodes average equally.</p><p>That would only happen if both capacitances were equal.</p><p>They aren’t.</p><p>The Bit Line intentionally has much larger capacitance.</p><p>Therefore</p><pre>CBL &gt;&gt; Ccell</pre><p>The final voltage remains much closer to the Bit Line’s original voltage.</p><h4>Sense Amplifier</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryplQt8WZdGJ1JTRNdccUw.png" /></figure><p>A voltage change of only</p><pre>50–100mV</pre><p>is too small for normal digital logic.</p><p>Instead,</p><p>each Bit Line connects to a differential sense amplifier.</p><p>Its job is to amplify</p><pre>0.655V =&gt; 1.2V</pre><p>or</p><pre>0.545V =&gt; 0V</pre><p>The amplifier rapidly regenerates the full logic level.</p><h4>Why Reading Is Destructive</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*from85dvkN5N7bCUu-b_Ow.png" /></figure><p>During charge sharing,</p><p>part of the capacitor’s charge leaves the storage node.</p><p>The original voltage no longer exists.</p><p>Without intervention,</p><p>the stored data would gradually disappear.</p><p>Therefore,</p><p>every read operation immediately becomes</p><pre>Read =&gt; Amplify =&gt; Rewrite</pre><p>The sense amplifier not only detects the value,</p><p>it restores it.</p><h4>Leakage Current</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*Xv455JzhDsPv5zWkCxJa4Q.png" /></figure><p>Even when WL remains LOW,</p><p>the capacitor slowly loses charge through:</p><ul><li>Junction leakage</li><li>Gate leakage</li><li>Subthreshold leakage</li><li>Dielectric leakage</li></ul><p>Typical retention time is around</p><pre>64 ms</pre><p>After that,</p><p>the stored voltage may no longer be distinguishable.</p><h4>Refresh</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*E5-mBOZSai3_P5HdZ1bTwg.png" /></figure><p>Every row is periodically refreshed.</p><p>The refresh sequence is identical to a normal read.</p><pre>Activate Row =&gt; Charge Sharing =&gt; Sense Amplifier =&gt; Restore =&gt; Precharge</pre><p>No CPU involvement is required.</p><p>The DRAM controller performs this automatically.</p><h4>Timing Overview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*Jsw2wQRXEG15CDgRdGSnWg.png" /></figure><p>A complete access looks like:</p><pre>Precharge =&gt; WL HIGH =&gt; Charge Sharing =&gt; Sense =&gt; Restore =&gt; WL LOW =&gt; Precharge</pre><p>Every DRAM access follows this sequence.</p><p>Only the timing values change.</p><h4>Key Takeaways</h4><p>A DRAM cell is electrically simple but architecturally elegant.</p><p>Using only one MOSFET and one capacitor, it achieves extremely high density while relying on carefully controlled analog behavior.</p><p>The digital 0 and 1 that software sees are, in reality, tiny differences in stored electrical charge measured in femtofarads and millivolts.</p><p>Understanding this cell provides the foundation for understanding every modern DRAM device, from DDR4 and DDR5 memory modules to LPDDR used in smartphones.</p><p>Next part <a href="https://shiviraj.medium.com/why-does-ram-read-an-entire-row-0f5459d81c90">Why does RAM read an entire row</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cbad1104b26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Does a Computer Remember a Single Bit?]]></title>
            <link>https://shiviraj.medium.com/how-does-a-computer-remember-a-single-bit-2767a3a2af76?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/2767a3a2af76</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[memories]]></category>
            <category><![CDATA[electronics]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 18:22:12 GMT</pubDate>
            <atom:updated>2026-07-19T04:42:11.615Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 2 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><p><strong><em>Missed Part 1? </em></strong><em>Before reading this chapter, I recommend starting with </em><a href="https://shiviraj.medium.com/we-need-to-talk-about-ram-3822d3543b62"><strong><em>Part 1 — We Need to Talk About RAM</em></strong></a><em>. In the previous chapter, we discovered the real problem: </em><strong><em>Electricity doesn’t naturally remember anything.</em></strong></p><p><em>Today, we’re going to solve that problem.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*wJbn62t3LhKVn8WoV_67jg.png" /></figure><h4>📚 How Computers Actually Work — Series</h4><ul><li>✅ Part 1 — We Need to Talk About RAM</li><li><strong>👉 Part 2 — How Does a Computer Remember a Single Bit?</strong> <em>(You’re reading)</em></li><li>Part 3 — Why Does RAM Read an Entire Row?</li><li>Part 4 — We Need to Talk About CPU Cache</li><li>Part 5 — How Can a Computer Remember Without Power?</li><li>Part 6 — How Can a Computer Remember Without a Disk?</li></ul><h4>Let’s Build the World’s Smallest Memory</h4><p>Forget 16 GB of RAM.</p><p>Forget your laptop.</p><p>Forget servers with hundreds of gigabytes of memory.</p><p>Imagine you’re one of the engineers building the world’s first computer.</p><p>Your manager walks over and says,</p><blockquote><em>“I don’t need gigabytes. I don’t even need one byte.”</em></blockquote><blockquote><strong><em>“I only need one bit.”</em></strong></blockquote><p>Just this.</p><pre>1</pre><p>That’s it.</p><p>How difficult could it be?</p><p>At first glance…</p><p>It sounds almost trivial.</p><p>It isn’t.</p><h4>Attempt #1 — Use a Wire</h4><p>Every computer uses electricity.</p><p>So our first idea seems obvious.</p><p>Let’s store electricity inside a wire.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*dsmDE3NjeFeb59N7jziE-A.png" /></figure><p>Connect the battery.</p><p>Electricity flows.</p><p>Disconnect the battery.</p><p>Everything disappears.</p><p>The wire remembers nothing.</p><p>Maybe the wire is too short.</p><p>Let’s make it longer.</p><p>Still nothing.</p><p>Use thicker wires?</p><p>Still nothing.</p><p>Use copper instead of another metal?</p><p>Nothing changes.</p><p>We’ve just learned something important.</p><blockquote><em>A wire can </em><strong><em>carry</em></strong><em> electricity.</em></blockquote><blockquote><em>It cannot </em><strong><em>store</em></strong><em> electricity.</em></blockquote><h4>🤔 Think Like an Engineer</h4><p>When engineers fail, they usually don’t ask,</p><blockquote><em>“What component should I use?”</em></blockquote><p>Instead they ask,</p><blockquote><strong><em>“Have I solved a similar problem somewhere else?”</em></strong></blockquote><p>Let’s do exactly that.</p><h4>How Do Humans Store Things?</h4><p>Suppose I hand you a glass of water.</p><p>Where would you keep it?</p><p>Probably in a bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*RW6ptalrcMnxDXAHrrOMOg.png" /></figure><p>Why not pour it onto the floor?</p><p>Because the floor isn’t designed to store water.</p><p>A bucket is.</p><p>That simple idea changes everything.</p><p>Maybe electricity also needs a bucket.</p><h4>Meet the Electrical Bucket</h4><p>Engineers already had one.</p><p>It’s called a <strong>capacitor</strong>.</p><p>Forget the textbook definition for now.</p><p>Think of it as one thing.</p><blockquote><strong><em>A tiny bucket for electrical charge.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Dw23WlYVkZS-ymlO1nsOZg.png" /></figure><p>Unlike a wire, a capacitor can temporarily hold electrical charge.</p><p>Finally…</p><p>We have something capable of remembering.</p><p>Or do we?</p><h4>Can a Capacitor Store a Bit?</h4><p>Let’s invent a simple rule.</p><p>If the capacitor contains enough charge…</p><pre>1</pre><p>If it doesn’t…</p><pre>0</pre><p>Notice something interesting.</p><p>The computer doesn’t care about every possible voltage.</p><p>It only needs two meaningful states.</p><p>Exactly like a light switch.</p><pre>ON  → 1<br>OFF → 0</pre><p>Computers love binary because the hardware becomes much simpler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*K64HqbiMuwskbU5jJ0KPRA.png" /></figure><h4>Looks Like We Solved It…</h4><p>Let’s celebrate.</p><p>We wanted memory.</p><p>We built a tiny electrical bucket.</p><p>Mission accomplished.</p><p>Right?</p><p>Not quite.</p><p>I have another question.</p><p>How do we put charge into the capacitor?</p><p>How do we remove it?</p><p>And more importantly…</p><p>How do we stop electricity from flowing whenever it wants?</p><p>Imagine filling a bucket that has no tap.</p><p>Water would keep flowing forever.</p><p>We need a valve.</p><h4>An Electrical Valve</h4><p>For water, we use a tap.</p><p>For electricity, engineers use a <strong>MOSFET</strong>.</p><p>For this chapter, forget all the complicated electronics.</p><p>Think of it as nothing more than an electronic switch.</p><pre>Switch OFF</pre><pre>Bit Line   X   Capacitor</pre><p>Nothing flows.</p><p>Turn the switch on.</p><pre>Switch ON</pre><pre>Bit Line ───── Capacitor</pre><p>Charge can now move freely.</p><p>Simple.</p><p>Exactly what we needed.</p><h4>We Accidentally Built a DRAM Cell</h4><p>Let’s combine our two inventions.</p><ul><li>A capacitor that stores charge.</li><li>A MOSFET that controls when charge can move.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*Fz64yUn3TkFeB6szFqGU7Q.png" /></figure><p>Congratulations.</p><p>You’ve just built the smallest memory cell used inside modern DRAM.</p><p>Engineers call it a <strong>1T1C Cell</strong>.</p><ul><li><strong>1 Transistor</strong></li><li><strong>1 Capacitor</strong></li></ul><p>One bit.</p><h4>Writing a One</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGJXtBLjqTiKYQ85R4tvBQ.png" /></figure><p>Suppose we want to store a 1.</p><p>The controller closes the switch.</p><p>The data wire is driven to a high voltage.</p><p>Charge flows into the capacitor.</p><p>The controller opens the switch again.</p><p>The capacitor is now isolated.</p><p>The stored charge remains trapped.</p><h4>Writing a Zero</h4><p>Now suppose we want to erase it.</p><p>The controller closes the switch again.</p><p>This time, the data wire is driven to zero volts.</p><p>The charge leaves the capacitor.</p><p>The switch opens.</p><pre>Empty Capacitor -&gt; 0</pre><p>Easy.</p><p>Or at least…</p><p>It looks easy.</p><h4>Reading Creates a New Problem</h4><p>Now the CPU asks,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*_z6GBnhgTHKjwsAmE9Zeeg.png" /></figure><blockquote><em>“What value is stored?”</em></blockquote><p>Simple.</p><p>Connect the capacitor back to the wire.</p><p>Right?</p><p>Something unexpected happens.</p><p>The moment we reconnect them…</p><p>At that moment, the capacitor and the Bit Line are no longer isolated.</p><p>They’re electrically connected.</p><p>Whenever two conductors with different voltages are connected together, they naturally move toward a common voltage by sharing charge.</p><p>This phenomenon is called <strong>charge sharing</strong>.Both containers end up sharing the water.</p><p>For example, if:</p><ul><li>The capacitor is at <strong>1.2 V</strong></li><li>The Bit Line is precharged to <strong>0.6 V</strong></li></ul><p>Capacitor and bit line ended up shared voltage around <strong>0.62 V</strong></p><p>The moment we read the memory…</p><p>We accidentally disturb it.</p><h4>Wait… Did We Just Damage the Data?</h4><p>Yes.</p><p>And that’s what makes DRAM fascinating.</p><p>Reading isn’t passive.</p><p>Reading changes the circuit.</p><p>At first glance, this sounds like terrible engineering.</p><p>Who would build memory that gets disturbed every time you read it?</p><p>Engineers did.</p><p>Because they had another clever trick.</p><h4>Meet the Sense Amplifier</h4><p>The voltage on the wire changes only slightly.</p><p>Far too little for the CPU to notice.</p><p>So engineers built a tiny detective.</p><p>Its only job is to answer one question.</p><blockquote><em>Did the voltage become slightly higher?</em></blockquote><blockquote><em>Or slightly lower?</em></blockquote><p>That circuit is called the <strong>Sense Amplifier</strong>.</p><p>Once it decides whether the answer was 0 or 1, it immediately rewrites the original value back into the capacitor.</p><p>Every DRAM read is secretly two operations.</p><ol><li>Read the value.</li><li>Restore the value.</li></ol><p>It happens so quickly that software never notices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mat0yFA9ZRVdhq_TvtvvfA.png" /></figure><h4>Fighting Physics</h4><p>There’s one final problem.</p><p>Even if nobody reads the capacitor…</p><p>It slowly leaks charge.</p><p>Think of a bucket with a tiny hole.</p><p>Leave it alone long enough…</p><p>And it eventually becomes empty.</p><p>That’s exactly what happens inside DRAM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*ic19ZeRjjQGDi15LZwnZTA.png" /></figure><p>To prevent data loss, the memory controller periodically refreshes every row before the charge disappears.</p><p>RAM isn’t forgetting because it’s broken.</p><p>It’s forgetting because physics never stops.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*9-7qeC8UnA731BMm7uzKyA.png" /></figure><h4>We’ve Solved One Bit</h4><p>Today we built the smallest memory cell inside a computer.</p><p>Not with software.</p><p>Not with magic.</p><p>Just two tiny electronic components working together.</p><p>Modern RAM simply repeats this idea billions of times.</p><p>But that creates another question.</p><p>If every cell stores only <strong>one bit</strong>…</p><p>How does a computer read an entire byte?</p><p>Or an integer?</p><p>Surely it doesn’t visit billions of cells one at a time.</p><p>Do you really want to understand how <a href="https://medium.com/@shiviraj/building-and-analyzing-a-1t1c-dram-cell-6cbad1104b26">it works electrically</a>?.</p><p>That’s exactly what we’ll discover in the <a href="https://shiviraj.medium.com/why-does-ram-read-an-entire-row-0f5459d81c90">next chapter</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtURnhb99NzGiJl1Pt2_Wg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2767a3a2af76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Need to Talk About RAM]]></title>
            <link>https://shiviraj.medium.com/we-need-to-talk-about-ram-3822d3543b62?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3822d3543b62</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[rams]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 15:58:33 GMT</pubDate>
            <atom:updated>2026-07-17T18:23:12.790Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 1 of the </em><strong><em>How Computers Actually Work</em></strong><em> series</em></p><blockquote>“Every complex system starts with a surprisingly simple problem.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SwZHp_4r0jGL_Wkcl0iDg.jpeg" /></figure><h4>📚 How Computers Actually Work — Series</h4><ul><li><strong>👉 Part 1 — We Need to Talk About RAM</strong> <em>(You’re reading)</em></li><li>Part 2 — How Does a Computer Remember a Single Bit?</li><li>Part 3 — Why Does RAM Read an Entire Row?</li><li>Part 4 — We Need to Talk About CPU Cache</li><li>Part 5 — How Can a Computer Remember Without Power?</li><li>Part 6 — How Can a Computer Remember Without a Disk?</li></ul><p>A few years ago, if someone had asked me,</p><blockquote><strong><em>“What is RAM?”</em></strong></blockquote><p>I would’ve answered without hesitation.</p><blockquote><em>“RAM is the computer’s memory.”</em></blockquote><p>Technically…</p><p>that’s correct.</p><p>But if they had asked one more question…</p><blockquote><strong><em>“What exactly is memory?”</em></strong></blockquote><p>I wouldn’t have had a good answer.</p><p>Not because I wasn’t writing software.</p><p>At the time, I had already built applications using Java, Spring Boot, React, Redis, Kafka, MySQL, and MongoDB.</p><p>I knew how to use memory.</p><p>I had never stopped to ask how memory actually works.</p><p>And I have a feeling many developers are in the same position.</p><h4>Let’s Start With One Line of Code</h4><p>Imagine this simple statement.</p><pre>int age = 25;</pre><p>Nothing unusual.</p><p>We’ve all written code like this thousands of times.</p><p>Now let me ask you something.</p><p><strong>Where is </strong>25<strong>?</strong></p><p>Not inside Java.</p><p>Not inside the JVM.</p><p>Not conceptually.</p><p>Physically.</p><p>Where does this number actually exist inside your computer?</p><p>Most developers would answer,</p><blockquote><em>“It’s stored in RAM.”</em></blockquote><p>Fair enough.</p><p>But that only moves the mystery one step further.</p><p>What exactly is RAM?</p><p>If I opened my laptop right now, I wouldn’t find tiny shelves labelled:</p><pre>age = 25<br>username = &quot;Alice&quot;<br>loggedIn = true</pre><p>So where are these values actually hiding?</p><h4>A Strange Experiment</h4><p>Imagine you’re editing an important document.</p><p>You’ve written several pages.</p><p>But before pressing <strong>Save</strong>, your laptop suddenly loses power.</p><p>Everything disappears.</p><p>The document.</p><p>The browser tabs.</p><p>The running applications.</p><p>Even our tiny variable.</p><pre>int age = 25;</pre><p>Gone.</p><p>Almost as if it never existed.</p><p>Now perform the same experiment after saving the document.</p><p>Turn the laptop off.</p><p>Turn it back on.</p><p>Your file is still there.</p><p>So are your photos.</p><p>Your operating system.</p><p>Your music.</p><p>Some information disappears the moment power is removed.</p><p>Other information survives for years.</p><p>Why?</p><h4>Computers Have More Than One Kind of Memory</h4><p>Without realizing it, we’ve already discovered something important.</p><p>A computer doesn’t have a single place where it stores information.</p><p>Instead, it has multiple kinds of memory.</p><p>Each one is designed for a different purpose.</p><p>Some are incredibly fast.</p><p>Some are incredibly large.</p><p>Some remember forever.</p><p>Others forget almost instantly.</p><p>This series is about understanding why.</p><h4>The Real Problem</h4><p>Before we learn how RAM works…</p><p>Before we talk about SSDs…</p><p>Before we explore CPU Cache…</p><p>We need to answer one simple question.</p><blockquote><strong><em>How can a machine remember anything at all?</em></strong></blockquote><p>Because computers don’t have magic.</p><p>They only have physics.</p><p>And physics presents us with a problem.</p><p>Electricity has a terrible memory.</p><h4>A Tiny Experiment</h4><p>Imagine the simplest electrical circuit possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*RRhuBLJXuBucger8JEdu0A.png" /></figure><p>Close the switch.</p><p>The bulb lights up.</p><p>Open the switch.</p><p>The light disappears immediately.</p><p>The wire doesn’t remember that electricity flowed through it a second ago.</p><p>It simply returns to its normal state.</p><p>Electricity can move.</p><p>It can power things.</p><p>But it doesn’t naturally remember where it has been.</p><h4>🤔 Think Like an Engineer</h4><p>Imagine you’re one of the engineers building the world’s first computer.</p><p>Your manager walks over and says,</p><blockquote><em>“Build me something that can remember.”</em></blockquote><p>You already know electricity can perform calculations.</p><p>You already know it can travel through wires.</p><p>But how do you make it remember?</p><p>Where would you even begin?</p><h4>Back to Our Variable</h4><p>Let’s return to our Java code.</p><pre>int age = 25;</pre><p>Eventually, the number <strong>25</strong> becomes binary.</p><pre>00011001</pre><p>Eight bits.</p><p>That’s all.</p><p>Eight tiny zeros and ones.</p><p>Now forget about Java.</p><p>Forget about the JVM.</p><p>Forget about programming languages.</p><p>Imagine you’re responsible for storing just one of those bits.</p><p>Not eight.</p><p>Not billions.</p><p>Just one.</p><pre>1</pre><p>Can you build a circuit that remembers whether that value is 0 or 1?</p><p>That tiny challenge became one of the most important engineering problems in computer history.</p><p>And the solution is surprisingly elegant.</p><h4>What’s Next?</h4><p>In the next chapter, we’re going to build the smallest memory cell inside a computer.</p><p>We’ll start with a failed idea.</p><p>Then another.</p><p>And another.</p><p>Until we finally discover the tiny circuit that became the foundation of every DRAM chip ever built.</p><p>We’ll only build one bit.</p><p>Because once we understand one bit…</p><p>Everything else is just repetition.</p><p>Next part: <a href="https://shiviraj.medium.com/how-does-a-computer-remember-a-single-bit-2767a3a2af76">How Does a Computer Remember a Single Bit?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3822d3543b62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Computers Actually Work]]></title>
            <link>https://shiviraj.medium.com/how-computers-actually-work-9c4266b8d0f7?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c4266b8d0f7</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[computer-architecture]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 15:57:05 GMT</pubDate>
            <atom:updated>2026-07-16T16:00:14.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzyW7WHumRqbVmeV6pGPUw.jpeg" /></figure><p>I still remember the first time I wrote something like this:</p><pre>int age = 25;</pre><p>At the time, it was just another variable.</p><p>I knew what it meant.<br>I knew how to compile it.<br>I knew how to debug it.</p><p>As my career progressed, I learned frameworks, databases, distributed systems, cloud platforms, caching, messaging systems, and countless design patterns.</p><p>Like many software engineers, I became comfortable working with layers of abstraction.</p><p>Then one day, a simple question stopped me.</p><blockquote><strong><em>Where does this value actually exist?</em></strong></blockquote><p>The obvious answer was:</p><blockquote><em>“It’s stored in RAM.”</em></blockquote><p>But that answer immediately raised more questions.</p><p>What exactly is RAM?</p><p>How can electricity remember anything?</p><p>How is a single bit stored?</p><p>Why does RAM forget everything when the power is removed?</p><p>Why does the CPU need another type of memory called Cache?</p><p>How can an SSD remember my files without continuously receiving power?</p><p>I started searching for answers.</p><p>Some articles stayed at a very high level.</p><p>Others jumped directly into semiconductor physics and transistor design.</p><p>There were excellent resources for software engineers.</p><p>There were excellent resources for electronics engineers.</p><p>But I struggled to find something that connected the two.</p><p>Something that started with software and slowly peeled away the layers until the hardware underneath finally made sense.</p><p>That’s why I decided to write this series.</p><p>Not as an academic textbook.</p><p>Not as a collection of definitions.</p><p>But as a story.</p><p>A story where every new technology exists because the previous one had a limitation.</p><p>We’ll begin with one simple question:</p><blockquote><strong><em>How does a computer remember a single bit?</em></strong></blockquote><p>From there, we’ll slowly build our understanding.</p><p>We’ll discover why DRAM uses capacitors.</p><p>Why SRAM is built differently.</p><p>Why CPUs need cache.</p><p>How hard disks remember data without power.</p><p>And finally, how SSDs manage to remember your files without using a spinning disk at all.</p><p>You don’t need an electronics background.</p><p>You don’t need to know digital design.</p><p>You only need one thing.</p><p>Curiosity.</p><p>If you’ve ever looked at a line of code and wondered what really happens beneath it…</p><p>I think you’ll enjoy this journey.</p><p>Let’s begin.</p><p><a href="https://shiviraj.medium.com/we-need-to-talk-about-ram-3822d3543b62">We Need to Talk About RAM</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c4266b8d0f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Apache Kafka: A Complete Guide to Distributed Event Streaming]]></title>
            <link>https://shiviraj.medium.com/mastering-apache-kafka-a-complete-guide-to-distributed-event-streaming-c36f3f3f4688?source=rss-d5f7ca4c89ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/c36f3f3f4688</guid>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <dc:creator><![CDATA[Shivam Rajput]]></dc:creator>
            <pubDate>Sat, 09 May 2026 03:30:43 GMT</pubDate>
            <atom:updated>2026-05-09T03:30:43.022Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern applications generate enormous amounts of data every second.<br>E-commerce platforms process orders continuously, banking systems handle transactions in real time, IoT devices stream sensor data, and social media platforms generate billions of events daily.</p><p>Traditional synchronous communication patterns often struggle under such scale.</p><p>This is where Apache Kafka becomes one of the most important technologies in modern distributed systems.</p><p>Kafka powers systems at companies like:</p><ul><li>Netflix</li><li>Uber</li><li>LinkedIn</li><li>Amazon</li><li>Airbnb</li><li>Spotify</li></ul><p>It is widely used for:</p><ul><li>event-driven architectures</li><li>microservices communication</li><li>real-time analytics</li><li>logging pipelines</li><li>streaming systems</li><li>asynchronous processing</li></ul><p>In this blog, we will deeply understand Kafka from beginner to advanced concepts, including architecture, scaling, partitions, consumer groups, replication, lag handling, retention, monitoring, real-world production strategies, and best practices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ViWF7EtaZ9JiNwlpN503A.png" /></figure><h3>1. What is Kafka?</h3><p>Apache Kafka is a distributed event streaming platform designed for:</p><ul><li>High throughput</li><li>Scalability</li><li>Durability</li><li>Fault tolerance</li><li>Real-time event processing</li></ul><p>At its core, Kafka acts like a highly scalable distributed log system.</p><p>Applications can:</p><ul><li>publish events</li><li>store events</li><li>consume events</li><li>replay events</li></ul><p>Kafka is not just a messaging queue.<br>It is an event streaming platform.</p><h3>2. Why Kafka Was Created</h3><p>Before Kafka, systems commonly used:</p><ul><li>traditional message queues</li><li>synchronous REST APIs</li><li>database polling</li></ul><p>These approaches caused problems:</p><ul><li>tight coupling</li><li>scalability bottlenecks</li><li>slow processing</li><li>poor fault tolerance</li><li>data loss risks</li></ul><p>Kafka was originally developed at LinkedIn to handle huge volumes of event data efficiently.</p><p>The goal was:</p><ul><li>decouple systems</li><li>enable asynchronous communication</li><li>support replayability</li><li>handle massive throughput</li></ul><h3>3. Kafka Core Concepts</h3><p>Before diving deeper, let us understand the building blocks.</p><h3>Producer</h3><p>A Producer publishes messages to Kafka.</p><p>Examples:</p><ul><li>Order service sends order-created event</li><li>Payment service sends payment-success event</li></ul><h3>Consumer</h3><p>A Consumer reads messages from Kafka.</p><p>Examples:</p><ul><li>Notification service sends emails</li><li>Analytics service processes user events</li></ul><h3>Topic</h3><p>A Topic is a logical stream/category of messages.</p><p>Examples:</p><ul><li>orders</li><li>payments</li><li>notifications</li></ul><h3>Partition</h3><p>Topics are divided into partitions for:</p><ul><li>parallelism</li><li>scalability</li><li>throughput</li></ul><h3>Consumer Group</h3><p>A group of consumers working together.</p><p>Important rule:</p><blockquote>One partition can be consumed by only one consumer inside the same consumer group.</blockquote><h3>Offset</h3><p>Each message inside a partition has a sequential ID called an offset.</p><p>Example:</p><p>Offset 0<br>Offset 1<br>Offset 2</p><p>Offsets help Kafka track consumption progress.</p><h3>4. Kafka Architecture</h3><p>A Kafka cluster consists of multiple components.</p><h3>Brokers</h3><p>Kafka servers are called brokers.<br>Example:<br>Broker 1<br>Broker 2<br>Broker 3</p><p>Together they form a Kafka cluster.</p><h3>Producers Send Messages</h3><p>Producers send data to Kafka brokers.</p><h3>Consumers Read Messages</h3><p>Consumers fetch data from brokers.</p><h3>Topics Stored Across Brokers</h3><p>Partitions and replicas are distributed across brokers.</p><h3>5. Producers</h3><p>A Producer is responsible for:</p><ul><li>creating messages</li><li>deciding partition</li><li>sending data to Kafka</li></ul><p>Producer Example:</p><pre>ProducerRecord&lt;String, String&gt; record =<br>    new ProducerRecord&lt;&gt;(&quot;orders&quot;, &quot;user-1&quot;, &quot;Order Created&quot;);</pre><h3>6. How Kafka Decides Partitions</h3><p>Partition assignment is usually handled by the producer.</p><h3>Explicit Partition</h3><p>Producer directly specifies partition.</p><h3>Key-Based Partitioning (Most Common)</h3><p>Kafka calculates:<br>hash(key) % partition_count</p><p>Example:<br>hash(user-123) % 4 = Partition 2</p><p>This ensures:</p><ul><li>same key always goes to same partition</li><li>ordering preserved</li></ul><h3>No Key</h3><p>Kafka distributes messages automatically:</p><ul><li>round robin</li><li>sticky partitioning</li></ul><h3>7. Topics and Partitions</h3><p>Topics are split into partitions.</p><p>Example:<br>Topic: orders<br>Partition 0<br>Partition 1<br>Partition 2</p><p>Partitions enable parallel processing.</p><h3>8. Why Partitions Matter</h3><p>Partitions determine:</p><ul><li>scalability</li><li>throughput</li><li>consumer parallelism</li><li>ordering</li></ul><h3>More Partitions = More Parallelism</h3><p>Example:<br>1 partition → 1 active consumer<br>10 partitions → up to 10 parallel consumers</p><h3>But Too Many Partitions Are Dangerous</h3><p>Excessive partitions create:</p><ul><li>metadata overhead</li><li>memory pressure</li><li>slow rebalances</li><li>controller stress</li></ul><p>Partition count should be carefully planned.</p><h3>9. Consumer Groups</h3><p>Consumer groups provide scalability.</p><p>Suppose:</p><ul><li>Topic has 3 partitions</li><li>Consumer group has 3 consumers</li></ul><p>Assignment:<br>Consumer 1 → Partition 0<br>Consumer 2 → Partition 1<br>Consumer 3 → Partition 2</p><h3>Important Rule</h3><p>Inside same group:<br>1 partition → only 1 active consumer</p><h3>Multiple Groups Can Read Same Topic</h3><p>Example:<br>Group A → notifications<br>Group B → analytics<br>Group C → auditing</p><p>All independently consume same messages.</p><h3>10. Offsets</h3><p>Kafka tracks message positions using offsets.</p><p>Example:<br>Offset 100<br>Offset 101<br>Offset 102</p><p>Consumers commit offsets after processing.</p><p>Kafka stores consumer offsets internally.</p><h3>11. Replication Factor</h3><p>Replication factor determines how many copies of partition exist.</p><p>Example:<br>Replication Factor = 3</p><p>Meaning:</p><ul><li>3 copies of every partition exist</li></ul><h3>Why Replication Matters</h3><p>If one broker fails:</p><ul><li>data remains safe</li><li>another replica becomes leader</li></ul><h3>12. Leader and Follower Replicas</h3><p>Each partition has:</p><ul><li>one leader</li><li>multiple followers</li></ul><h3>Leader</h3><p>Handles:</p><ul><li>reads</li><li>writes</li><li>producer requests</li><li>consumer requests</li></ul><h3>Followers</h3><p>Replicate leader data continuously.</p><h3>13. Message Ordering</h3><p>Kafka guarantees ordering only within a partition.</p><p>This is why keys are important.</p><p>Example:</p><p>All events for:<br>order-123</p><p>should go to same partition.</p><h3>14. Retention Policies</h3><p>Kafka stores messages only for configured duration.</p><p>Example:<br>retention.ms = 604800000 = 7 days.</p><p>After retention expires:</p><ul><li>old messages deleted automatically</li></ul><h3>Important Clarification</h3><p>earliest means: Earliest available retained message<br>NOT: Earliest message ever produced</p><h3>15. Consumer Lag</h3><p>Consumer lag occurs when:<br>Producer speed &gt; Consumer speed</p><p>Lag formula:<br>Lag = Latest Offset - Consumer Offset</p><p>Example:<br>Latest Offset = 10000<br>Consumer Offset = 8500<br>Lag = 1500</p><p>Meaning:</p><ul><li>1500 messages pending</li></ul><h3>16. Handling Large Consumer Lag</h3><p>Strategies include:</p><ul><li>increasing consumers</li><li>increasing partitions</li><li>optimizing processing</li><li>batching</li><li>autoscaling</li></ul><h3>17. Monitoring Kafka</h3><p>Production systems continuously monitor Kafka.</p><p>Common tools:</p><ul><li>Prometheus</li><li>Grafana</li><li>Datadog</li><li>Burrow</li></ul><h3>Important Metrics</h3><p>Teams monitor:</p><ul><li>consumer lag</li><li>throughput</li><li>disk usage</li><li>broker health</li><li>replication status</li><li>rebalance count</li></ul><h3>18. Automatic Alerts</h3><p>Example:<br>IF lag &gt; 50,000<br>FOR 5 minutes<br>THEN send alert</p><p>Notifications:</p><ul><li>Slack</li><li>Email</li><li>PagerDuty</li></ul><h3>19. Auto Scaling Consumers</h3><p>Tools like:</p><ul><li>KEDA</li><li>Kubernetes HPA</li></ul><p>can automatically scale consumers.</p><h3>20. Multiple Brokers</h3><p>Production Kafka clusters usually run on multiple machines.</p><p>Example:<br>Broker 1<br>Broker 2<br>Broker 3</p><p>Kafka distributes:</p><ul><li>partitions</li><li>leaders</li><li>replicas</li></ul><p>across brokers automatically.</p><h3>21. Broker Failure Recovery</h3><p>Suppose: Broker 1 crashes</p><p>Kafka automatically:</p><ul><li>elects new leader</li><li>reroutes traffic</li><li>continues processing</li></ul><p>This provides high availability.</p><h3>22. ZooKeeper</h3><p>Older Kafka versions used ZooKeeper for:</p><ul><li>broker coordination</li><li>leader election</li><li>metadata storage</li></ul><h3>23. Modern Kafka: KRaft Mode</h3><p>New Kafka versions use: KRaft</p><p>Benefits:</p><ul><li>no ZooKeeper dependency</li><li>simpler architecture</li><li>better scalability</li></ul><h3>24. Kafka Storage Internals</h3><p>Kafka stores data on disk using append-only logs.</p><p>Benefits:</p><ul><li>sequential disk writes</li><li>high throughput</li><li>efficient storage</li></ul><p>Kafka relies heavily on:</p><ul><li>OS page cache</li><li>zero-copy transfer</li><li>batching</li></ul><h3>25. Kafka Delivery Guarantees</h3><p>Kafka supports:<br>At Most Once: Possible message loss.<br>At Least Once: No message loss, possible duplicates.<br>Exactly Once: No duplicates and no data loss.</p><p>More complex but powerful.</p><h3>26. Producer Acknowledgements</h3><p>Producer reliability controlled using:<br>acks=0<br>acks=1<br>acks=all (Safest option.)</p><p>Producer waits for all replicas.</p><p>Widely used in critical systems.</p><h3>27. OOM and Disk Usage</h3><p>Kafka mainly stores data on disk.</p><p>More common issue: Disk full</p><p>rather than broker OOM.</p><p>OOM usually happens in:</p><ul><li>consumers</li><li>producers</li><li>bad configurations</li></ul><h3>28. Topic Creation</h3><p>Topics can be created:</p><ul><li>manually</li><li>automatically</li><li>programmatically</li></ul><p>Production systems usually manage topics centrally.</p><h3>29. Real Production Kafka Workflow</h3><p>Typical enterprise architecture:</p><pre>Microservices<br>    ↓<br>Kafka Cluster<br>    ↓<br>Consumer Groups<br>    ↓<br>Databases / Analytics / Notifications</pre><p>Monitoring runs continuously.</p><h3>30. Kafka Use Cases</h3><p>Kafka is widely used for:</p><ul><li>event-driven systems</li><li>log aggregation</li><li>analytics</li><li>clickstream processing</li><li>IoT pipelines</li><li>CDC (Change Data Capture)</li><li>stream processing</li></ul><h3>31. When Kafka Is NOT Ideal</h3><p>Kafka may not be best choice for:</p><ul><li>simple CRUD applications</li><li>low-scale systems</li><li>request-response communication</li><li>transactional relational workloads</li></ul><p>Kafka introduces operational complexity.</p><h3>32. Common Kafka Problems</h3><p>Hot Partitions: Bad partition key causing uneven load.<br>Excessive Partitions: Too much metadata and rebalancing overhead.<br>Large Messages: Huge payloads reduce performance.</p><p>Best practice:</p><ul><li>store large files elsewhere</li><li>send references in Kafka</li></ul><h3>Consumer Lag Explosion</h3><p>Slow downstream systems create backlog.</p><h3>33. Kafka Best Practices</h3><p>Use Keys Carefully: Good partitioning strategy matters.<br>Monitor Lag: Lag is one of the most important production metrics.<br>Use Replication Factor 3: Common production standard.<br>Avoid Huge Messages: Keep messages lightweight.</p><h3>Plan Partitions Carefully:</h3><p>Too few → bottleneck.<br>Too many → operational overhead.</p><h3>Enable Monitoring Early</h3><p>Never run Kafka blindly in production.</p><h3>34. Why Kafka Became So Popular</h3><p>Kafka solves critical modern distributed system problems:</p><ul><li>asynchronous processing</li><li>scalability</li><li>fault tolerance</li><li>event replay</li><li>decoupled architectures</li></ul><p>It allows systems to:</p><ul><li>absorb traffic spikes</li><li>process events independently</li><li>recover from failures gracefully</li></ul><h3>Final Thoughts</h3><p>Kafka is one of the most powerful technologies in distributed systems engineering.</p><p>Understanding Kafka deeply requires understanding:</p><ul><li>distributed systems</li><li>scalability</li><li>fault tolerance</li><li>storage</li><li>networking</li><li>asynchronous architectures</li></ul><p>At first Kafka concepts may seem overwhelming:</p><ul><li>partitions</li><li>offsets</li><li>replication</li><li>lag</li><li>consumer groups</li><li>brokers</li></ul><p>But once the mental model becomes clear, Kafka becomes an incredibly elegant system.</p><p>The key idea is simple:</p><blockquote><em>Kafka is a durable distributed log that enables scalable, fault-tolerant, asynchronous event streaming between systems.</em></blockquote><p>Mastering Kafka opens the door to designing highly scalable modern backend architectures used by some of the largest technology companies in the world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c36f3f3f4688" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>