Jason Turley's Website

The Memory Hierarchy Explained with Pizza

Computer science concepts are often abstract and can be difficult for me to understand. I often find it helpful to explain things with silly analogies that are easier to remember.

Below is my silly analogy for a computer’s memory hierarchy, from the perspective of someone eating pizza.

There are a lot of over simplifications here, but this is for newbies; the more advanced readers can check out this.

data in a register = pizza in hand

Registers are built into a CPU and therefore it can access them almost instantaneously. Similarly, hands are built into a person and can grab things quickly.

data in a cache = pizza on plate

Caches are secondary storage and hold data that cannot currently fit in a register. Likewise, plates are used to hold food when it cannot fit in your hands.

data in RAM = pizza in oven

RAM, aka main memory is where a program needs to be loaded before it can run. It is not too far from the CPU and can be accessed quickly. A pizza must be cooked in an oven before it can be eaten. If you’re at home, the oven is usually relatively close by.

data on hard drive = pizza at local restaurant

Accessing a hard drive is extremely slow for a CPU 1) because of the distance and 2) because hard drives are essentially mini record players. Getting off the couch, putting on shoes, and driving to a local restaurant is much slower than walking to the fridge, for example.  

data in cloud storage = pizza on another continent

If a CPU can take ages to access data on its own computer, then it must take forever to access data on another computer. That could be in a different country. Or continent. This is akin to driving to the airport, flying to another continent, getting lost along the way, buying the pizza, and finally returning home.

#misc