# CPU, RAM & Storage, Explained

> The three components that decide whether a computer feels fast - the CPU, the RAM, and the storage - each properly explained, plus the one idea (the memory hierarchy) that ties them together.


---

# CPU, RAM & Storage, Explained

When a computer feels fast or feels slow, it almost always comes down to three parts: the **CPU**, the **RAM**, and the **storage**. You've seen these words on every laptop ad - "8-core CPU, 16 GB RAM, 512 GB SSD" - and they were probably handed to you as numbers to compare, never as *things you understand*. That's the gap this guide closes.

By the end, "more GHz," "more cores," and "more RAM" will stop being shopping noise and start being decisions you can reason about. We'll do it one part at a time, then snap them together with a single idea - the **memory hierarchy** - that explains why they're arranged the way they are.

> ⏭️ Brand new to the parts inside a computer? Read [How a Computer Actually Works](/guides/how-a-computer-works) first - it names the whole cast. This guide zooms in on the three parts that decide speed and explains each one properly.

## How to read this

- **Trying to decode a spec sheet right now?** Each phase ends with a plain-language "what this number buys you." Jump to the part you're staring at - [the CPU](01-the-cpu-the-worker.md), [the RAM](02-ram-the-workspace.md), or [the storage](03-storage-the-filing-cabinet.md).
- **Want it to finally make sense?** Read in order. Each phase builds one part of the picture, and the last phase ties all three together.

## The phases

1. **[The CPU - the Worker](01-the-cpu-the-worker.md)** - what the processor actually does (it runs instructions in a tight fetch-and-execute loop), and what its specs mean: clock speed (GHz), cores, and a gentle look at cache. Why "more GHz/cores" helps, and where it doesn't.
2. **[RAM - the Workspace](02-ram-the-workspace.md)** - your computer's working memory: fast, but wiped the instant the power goes off. Why having *enough* matters so much, what happens when it runs out, and what "16 GB of RAM" actually buys you.
3. **[Storage - the Filing Cabinet](03-storage-the-filing-cabinet.md)** - where your stuff lives when the power's off, capacity versus speed, and the unifying idea: the **memory hierarchy** - cache, then RAM, then storage, each one bigger but slower as you step away from the CPU.

> This guide leaves the *insides* of storage - how a hard drive, an SSD, and an NVMe drive actually differ - to a dedicated follow-up: [Storage: HDD vs SSD vs NVMe](/guides/storage-hdd-ssd-nvme). And if you want to see how the CPU and RAM cooperate while a program runs, [Processes, Memory & the CPU](/guides/processes-memory-and-cpu) picks up the software side.


---

# The CPU - the Worker

The CPU is where the work actually happens - everything else in your computer exists to feed it or remember things for it. People call it a brain, but a brain sounds clever and intuitive. The CPU is the opposite: staggeringly *simple* and staggeringly *fast*. It does tiny, dull steps, one at a time, billions of times a second. The speed is the whole trick.

## What the CPU actually does: one loop, repeated

The CPU (Central Processing Unit, also just called the **processor**) is a chip that does one thing in a loop: grab the next instruction, carry it out, grab the next one. That loop is the **fetch-execute cycle**, and it never stops while the computer is on.

📝 **Terminology.** An *instruction* is one tiny step the CPU knows how to do: "add these two numbers," "copy this value over here," "if that number is zero, jump to a different instruction." Programs are long lists of these steps, and the CPU follows them like a recipe, one line at a time.

```mermaid
flowchart LR
    F["FETCH<br/>get the next step"] --> D["DECODE<br/>figure out what it means"]
    D --> E["EXECUTE<br/>do it (add, copy, jump)"]
    E -->|"…then fetch the next step"| F
```

One trip around the loop is tiny - "add 3 and 5" - but the CPU makes an enormous number of trips every second, so those steps add up to a video playing, a game running, a page loading.

This picture dissolves a lot of mysteries. "Why is my fan loud and my laptop hot?" - something is keeping the CPU running its loop hard, and that burns energy as heat. "Why did the app freeze?" - the CPU is grinding through a list of steps taking far longer than expected. Not temperamental; just busy.

## Spec #1: Clock speed (GHz) - how fast the loop runs

The CPU steps in time with a steady internal heartbeat called the **clock**. Each tick is a moment the CPU can do a piece of work; **clock speed** is how many ticks happen per second, measured in **gigahertz (GHz)**.

📝 **Terminology.** "Hertz" means "times per second," and *giga* means *billion* - so **1 GHz = one billion ticks per second.** A CPU advertised at 3.5 GHz ticks about three and a half billion times a second. (Illustrative number to picture the scale, not a claim about any specific chip.)

The tempting belief - "higher GHz = faster computer, always" - is only *partly* true: for two otherwise-identical chips, the higher clock finishes the same work sooner. But GHz measures how fast the heartbeat ticks, not how much useful work gets done per tick - a newer 3.0 GHz design can outrun an older 3.5 GHz one. GHz compares fairly only within the same generation and family.

This also explains "turbo boost": under heavy work the chip ticks faster for a while (and runs hotter); when idle, it slows the heartbeat to save battery and stay cool.

## Spec #2: Cores - how many can work at once

A **core** is one complete worker - one fetch-execute loop. CPUs used to have exactly one; a modern chip packs several: "quad-core" means four workers, "8-core" means eight, all running genuinely at the same time.

Think one cashier versus four: one serves customers one at a time, very fast - but still one at a time. Four serve four people *simultaneously*. More cores means your computer can compress a video on one core while you browse on another while music decodes on a third.

```text
   One core (one worker):          Four cores (four workers):

   task A ─┐                        task A ─► [core 1]
   task B ─┼─► [core] one at        task B ─► [core 2]  all four
   task C ─┤    a time, very        task C ─► [core 3]  at the
   task D ─┘    fast                task D ─► [core 4]  same time
```

The other trap: "more cores = faster everything." Extra cores only help when the work splits into pieces that run side by side. Video editing, compiling code, and running many apps at once split beautifully. A single task that must happen in order - step 2 needs step 1's result - runs on one core no matter how many you have. ⚠️ This is the classic spec-sheet trap: a 16-core chip won't speed up a program that only knows how to use one core, and many everyday programs lean on just one or two.

> 💡 **Key point.** **GHz** is how fast *one* worker goes. **Cores** is how *many* workers you have. Fast single tasks want high GHz; lots-of-things-at-once and splittable jobs want more cores. Most real computers benefit from a sensible amount of both, not a giant pile of one.

So match the hardware to what you do: one heavy app that works in strict order wants raw per-core speed; thirty tabs plus a chat app, music, and a video call wants more cores so they don't step on each other.

## Spec #3: Cache - the sliver of ultra-fast memory on the chip

Rarely a headline spec, but it explains a lot. The CPU loops far faster than RAM (the main memory - next phase) can hand it data; waiting on RAM for every step would leave it mostly idle. So designers put a tiny amount of *extremely* fast memory right on the chip: the **cache**. It holds what the CPU is using right now and will likely need again in a moment.

Before reaching out to RAM, the CPU checks its cache first. Already there - a "cache hit" - and it gets it almost instantly. Not there - a "cache miss" - and the CPU waits while the data is fetched from slower RAM. Good caching is why a CPU stays busy instead of constantly waiting.

```mermaid
flowchart LR
    CPU["CPU core<br/>'I need that value.'"] --> Cache["CACHE<br/>tiny, super fast"]
    Cache -->|"hit (in cache)"| Hit["got it, almost instantly"]
    Cache -->|"miss (not in cache)"| RAM["wait… fetch from RAM<br/>much slower, much bigger"]
```

Cache is your first glimpse of the idea this whole guide builds toward: keep the data the CPU needs *close*, in small fast memory, and the rest *further away* in bigger, slower memory. Cache is the closest, fastest rung; RAM is the next; storage is further still. We'll draw the full ladder - the **memory hierarchy** - in [Phase 3](03-storage-the-filing-cabinet.md). For now: *closer to the CPU = faster but smaller; further away = bigger but slower.*

## What the CPU spec line actually buys you

When an ad says "8-core, 3.5 GHz," you can translate:

- **GHz** - how fast each worker runs its loop. Higher helps *within the same chip generation*; it isn't a fair score across generations.
- **Cores** - how many workers run at once. More helps for many-things-at-once and parallel work; it does nothing for a single in-order task.
- **Cache** - the unadvertised sliver of fast memory that keeps the workers fed instead of stalled waiting on RAM.

## Recap

1. The **CPU** runs programs by repeating one tiny loop - **fetch, decode, execute** - billions of times a second. Simple and fast, not clever.
2. **Clock speed (GHz)** is how fast that loop ticks. Higher is faster *only* between similar chips - it measures heartbeat, not work-per-tick.
3. **Cores** are how many loops run at once. They help splittable and many-at-once work, not a single task that must run in order.
4. **Cache** is a tiny patch of ultra-fast on-chip memory that keeps the CPU fed instead of waiting on RAM - your first taste of the memory hierarchy.

The CPU is the worker. A worker needs a workspace to spread out what it's using right now - that's RAM, next.

## Watch the clock

Clock speed isn't just a spec-sheet number - it's a real, continuous signal ticking billions of times a second. Watch it, and see what an unstable clock looks like:

```explainer-clock
```

Watch it animated: [CPU cache](/explainers/CPUCache.dc.html) and [multicore processing](/explainers/Multicore.dc.html)


---

# RAM - the Workspace

If the CPU is the worker, RAM is the desk that worker spreads its papers across. Everything *currently in use* - the document you're editing, your open tabs, the running parts of programs - lives there, where the CPU can reach it quickly.

It's also the spec most often confused with storage - and the usual explanation for a sluggish machine.

## What RAM actually is

**RAM** (Random-Access Memory, usually just called *memory*) is fast, temporary working space. Open an app and the computer copies the parts it needs from storage *into* RAM, because RAM is far quicker for the CPU to work with.

📝 **Terminology.** "Random-access" means the CPU can grab any spot in RAM equally quickly - no reading through everything before it. That go-anywhere access is why it's the CPU's workspace.

**The detail that trips everyone up: RAM is volatile.** It holds its contents only while it has power. Shut down or pull the plug and RAM is wiped completely, instantly. Not a flaw - the trade: the build that makes RAM fast can't hold data without power. RAM is for *now*, never for *keeping*; keeping is storage's job ([Phase 3](03-storage-the-filing-cabinet.md)).

> ⚠️ **Gotcha - why "save your work" exists.** Until you hit save, your document lives only in RAM. If the power drops or the app crashes first, the unsaved version is *gone* - it never reached anywhere permanent. Every "you have unsaved changes" warning you've ever clicked past is this fact showing through.

## The desk and the filing cabinet

Here's the analogy worth carrying for the rest of your computing life:

```text
   ┌───────────────────────────┐        ┌───────────────────────────┐
   │           RAM             │         │         STORAGE           │
   │      = your DESK          │         │   = the FILING CABINET    │
   │                           │         │                           │
   │  • small                  │         │  • big                    │
   │  • fast to reach          │         │  • slower to reach        │
   │  • holds what you're      │         │  • holds everything you   │
   │    using RIGHT NOW        │         │    own, for keeps         │
   │  • cleared when you       │         │  • survives power off     │
   │    leave (power off)      │         │                           │
   └───────────────────────────┘        └───────────────────────────┘
        whatever's on the desk  ◄──── you pull files out of the
        is what you're working on       cabinet and onto the desk to
                                        work, then file them back
```

To work on something, you pull it from cabinet to desk, then file it back when done. Nobody works *inside* the filing cabinet, and nobody stores their whole life on a desk - different furniture, different jobs.

## What happens when the desk fills up

Open programs always want more RAM than exists, so the operating system rations it. As long as everything you're actively using fits on the desk, the computer feels snappy.

When RAM fills up, the computer doesn't crash - it gets clever, and the cleverness is exactly why it slows to a crawl. The OS takes data that's *in RAM but not being touched right now* and parks it on the much slower storage to free desk space.

📝 **Terminology.** *Swapping* (sometimes called *paging*) is the OS moving data between RAM and storage to make limited RAM stretch further. The chunk of storage set aside for this is called *swap* (or the *page file* on Windows).

The problem: storage is *dramatically* slower than RAM. Once the machine relies on swapping, the CPU keeps waiting while data shuffles back and forth. That's "everything got molasses-slow, the disk light is on, and switching apps takes seconds."

```text
   Enough RAM:                       RAM is full → swapping:

   CPU ──► [ RAM ] everything it      CPU ──► [ RAM ] full!
           needs is right here,                 │  ▲
           fast. Smooth.                        ▼  │  constantly shuffling
                                          [ STORAGE ] ← to/from SLOW storage
                                          → CPU waits → everything drags
```

> 💡 **Key point.** A computer that's *out of memory* doesn't stop - it gets *painfully slow*, because it starts leaning on slow storage to fake having more RAM. "Slow when I open lots of tabs/apps, fine when I close some" is the signature of not-enough-RAM, almost every time.

## So how much RAM do you actually want?

Enough that what you normally keep open fits on the desk at once, with a little room to spare - so the computer rarely swaps. That depends entirely on what you do, so no magic number: a browser + chat + music person needs a smaller desk than a video editor with twenty tabs and three apps alive. Read "16 GB of RAM" as **desk size** - how much can be active before the machine starts parking things on slow storage.

And RAM is *not* where your files live. "16 GB of RAM, 512 GB SSD" is a 16 GB *desk* and a 512 GB *filing cabinet*. More RAM doesn't fit more photos; more storage doesn't keep more apps running smoothly. ⚠️ Confusing the two is the single most common spec-sheet mistake, and now you won't make it.

## Recap

1. **RAM is the workspace** - fast, temporary memory holding whatever is actively in use, within quick reach of the CPU.
2. **RAM is volatile** - wiped the instant power goes off. That's why unsaved work is at risk and why "save" sends it to permanent storage.
3. **RAM is the desk; storage is the filing cabinet** - don't confuse the two numbers.
4. **When RAM runs out, the computer gets slow, not dead** - it starts *swapping* idle data to slow storage. "Slow with lots open" usually means not enough RAM.
5. **"How much RAM" is really "how big a desk"** - enough that what you keep open fits without constant swapping.

We've leaned on "slow storage" twice now. Time to give storage its own introduction - and to draw the ladder connecting cache, RAM, and storage.

Watch it animated: [how RAM works](/explainers/HowRAMWorks.dc.html)


---

# Storage - the Filing Cabinet

The CPU does the work. RAM is the desk it works on. But the desk gets wiped every time the power goes off - so where do your photos, documents, apps, and the operating system actually *live*? That permanent home is **storage**, the last of our three parts. We'll cover its two numbers, then assemble cache, RAM, and storage into the **memory hierarchy**.

## What storage actually is

**Storage** is where data is kept when nothing's using it - including when the power is off. The OS, every app, every file you've saved sit there waiting. Open something and the computer copies the needed parts *from* storage *into* RAM; save, and changes are written back.

📝 **Terminology.** Storage is *non-volatile* - the opposite of RAM. It keeps its contents without power: pull the plug, come back tomorrow, it's all still there. That permanence is storage's entire reason for existing. (You'll also hear "the disk" or "the drive," and on a spec sheet it's usually an "SSD" with a size like 512 GB.)

This is the other half of the "save your work" story: saving is the moment your work crosses from temporary RAM - the desk that gets wiped - into the cabinet that remembers. That's why a saved document survives a crash and an unsaved one doesn't.

## The two numbers: capacity vs speed

**Capacity - how much it holds.** The big advertised number: "512 GB," "1 TB," "2 TB." It tells you how many photos, videos, apps, and files fit - and *nothing* about how fast they come and go. A bigger cabinet holds more folders; it doesn't make you walk to it any faster.

📝 **Terminology.** Sizes climb in roughly thousand-fold steps: **GB** (gigabyte) → **TB** (terabyte, about a thousand GB). A "512 GB SSD" is a storage *capacity*.

**Speed - how fast it hands data over.** How quickly storage delivers data to RAM (and accepts it back). It's why one computer boots in seconds and another grinds for a minute, and why a big app opens instantly on one machine and crawls on another. Capacity and speed are independent: a drive can be huge and slow, or smaller and fast.

> ⚠️ **Gotcha - capacity is not speed.** People buy a 2 TB drive expecting a speed-up and are puzzled when nothing feels snappier - they bought *room*, not *pace*. What makes storage feel fast is the *type* of drive.

Whether your drive is an old-style spinning hard disk, a modern SSD, or a faster-still NVMe drive matters far more for speed than its capacity does.

> ⏭️ Want the insides - spinning platters vs flash chips, and why NVMe is so much faster? That's [Storage: HDD vs SSD vs NVMe](/guides/storage-hdd-ssd-nvme). This phase keeps storage at the "what it does and where it fits" level.

## The big idea: the memory hierarchy

A pattern kept surfacing across this guide: data the CPU needs *right now* lives somewhere small and fast (cache), data in active use somewhere bigger and a bit slower (RAM), everything else somewhere huge and slower still (storage). That arrangement is deliberate: the **memory hierarchy**.

Why it exists - the trade nobody can escape: fast memory is expensive and physically can't be made huge; huge memory is cheap but slow. No single memory is instantly fast, enormous, *and* permanent. So computers layer several kinds, each trading speed for size as you move away from the CPU.

```mermaid
flowchart TD
    Cache["CPU cache<br/>tiny · fastest"] --> RAM["RAM (working memory)<br/>bigger · fast · wiped on power off"]
    RAM --> Storage["STORAGE (your files, apps, the OS)<br/>huge · slowest · survives power off"]
```

Climb *up* toward the CPU: faster, but far less room. Slide *down*: vastly more room, slower access. The whole machine works to keep what the CPU needs *now* as high up as possible - storage into RAM, RAM into cache - so the worker rarely waits on the slow layers.

This picture explains everything the three phases built:

- **Cache misses** (Phase 1) - the CPU wanted something not in the fastest rung, so it reached down to RAM and waited.
- **Swapping** (Phase 2) - RAM filled, the OS pushed data *down* to the slow storage rung, and everything dragged.
- **Boot and load times** (this phase) - starting up or opening an app hauls data *up* from storage into RAM, which is why the bottom rung's *speed* shapes how fast the machine feels.

> 💡 **Key point.** Fast feeling = the data the CPU needs is high in the hierarchy (cache or RAM). Slow feeling = the CPU keeps reaching down to the slow bottom rung. "More GHz, more cores, more RAM, a faster SSD" are all, at heart, ways of keeping the worker fed from the fast layers.

## What the storage spec actually buys you

- **Capacity (GB / TB)** - how *much* you can keep. Pick it for how many photos, videos, apps, and files you own. Not a speed number.
- **Drive type (HDD / SSD / NVMe)** - how *fast* storage hands data over, shaping boot times and app opens. Matters more for speed than capacity - see the [storage deep-dive](/guides/storage-hdd-ssd-nvme).

## Recap

1. **Storage is the filing cabinet** - big, permanent, *non-volatile*. It keeps the OS, apps, and files even with the power off.
2. **Capacity and speed are different numbers.** Capacity (GB/TB) is how much fits; speed is how fast it delivers. More capacity does not mean a faster computer.
3. **The type of drive drives the speed** - far more than its size: [HDD vs SSD vs NVMe](/guides/storage-hdd-ssd-nvme).
4. **The memory hierarchy ties it together:** cache → RAM → storage, each bigger but slower, because no single memory can be fast, huge, and permanent at once.
5. **"Fast" means the CPU's data sits high in that hierarchy** - every spec you compare is really about keeping the worker fed from the fast layers.

That's the trio: CPU does the work, RAM is the workspace, storage is the permanent home - and the memory hierarchy is why they're arranged this way. When a computer feels fast or slow, you now know which part to look at.
