Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 55 ยท Inside the Machine

Storage: HDD, SSD and Beyond

Compare hard disks and SSDs, learn latency versus throughput, how RAID protects data, why flash wears out, and where cloud storage fits, with runnable models.

RAM forgets everything when the power goes off, so a computer needs somewhere permanent to keep programs, photos and documents. That job belongs to storage. Storage is slower than memory but far larger, cheaper per gigabyte and non-volatile. Choosing between a hard disk, an SSD or a cloud service affects how fast a laptop boots, how long a backup takes and how safe your data is.

This lesson explains how the main kinds of storage work inside, the difference between how long a read takes and how much can be read per second, how RAID combines drives, and why flash memory wears out. It follows Memory: RAM, Cache and the Memory Hierarchy and leads into Motherboard, Buses, GPU and Power.

Hard disk drives: magnetism and moving parts

A hard disk drive (HDD) stores bits as tiny magnetized regions on one or more spinning metal platters. A read/write head on a moving arm floats a hair's width above the surface and senses or changes the magnetization. Data lives in concentric circles called tracks, divided into sectors.

To read a byte, the drive must do mechanical work:

  1. Seek: move the arm to the correct track.
  2. Rotational delay: wait until the right sector spins under the head. At 7,200 revolutions per minute, one turn takes about 8.3 ms, so the average wait is about half of that.
  3. Transfer: read the data as the platter turns.

The first two steps are measured in milliseconds, which is an eternity for a processor. But once the head is in position, the drive reads a long run of data efficiently. HDDs are cheap per terabyte and can reach very large capacities, but they are sensitive to shocks while running, and they make noise and heat.

Solid-state drives: flash and no moving parts

An SSD (solid-state drive) stores bits as electric charge in flash memory cells, organized in pages and blocks, managed by a controller chip. There is no arm to move and nothing to wait for, so any location can be reached in tens of microseconds. SSDs are silent, shock-resistant and much faster for everyday work, which is why replacing an HDD with an SSD is the most noticeable upgrade for an older computer.

SSDs come in several shapes and connect in different ways:

Type Connection Typical use
SATA SSD (2.5-inch) SATA cable, up to about 550 MB/s upgrading older PCs and laptops
NVMe SSD (M.2 stick) PCI Express lanes, 3,000 MB/s and far more modern laptops, desktops, servers
eMMC / UFS soldered to the board phones, tablets, cheap laptops
USB flash drive, SD card USB or card slot portable files, cameras

Speeds in the table are rough orders of magnitude, not guarantees. Real drives vary by model, by how full they are and by the kind of access (see below).

Latency versus throughput

Two numbers describe how quickly a device serves data, and they are different things.

  • Latency is the delay before the first byte arrives, such as the 12 ms of an HDD seek. It matters when many small, scattered reads are needed (starting an operating system, opening a program, searching a database).
  • Throughput (bandwidth) is how many bytes per second flow once things are going, such as 150 MB/s. It matters for large, continuous transfers (copying a video, a backup).

A highway offers an analogy. Throughput is the number of cars that can pass per hour; latency is how long it takes the first car to arrive. A device can have good throughput and poor latency, which is exactly the situation of a hard disk: it is reasonable at reading one long file but terrible at reading thousands of small pieces in different places.

flowchart LR
  subgraph HDD["Hard disk"]
    H1["Seek<br/>~ms"] --> H2["Rotate<br/>~ms"] --> H3["Transfer<br/>fast once positioned"]
  end
  subgraph SSD["SSD"]
    S1["Controller lookup<br/>~tens of ยตs"] --> S2["Transfer<br/>fast"]
  end

An HDD pays mechanical delays on each scattered access; an SSD pays only a small electronic lookup.

The model below uses typical, rounded numbers (they are illustrative, not benchmarks of real products). It reads 10,000 chunks of 4 KB, first as one continuous stream and then as separate scattered reads that each pay the access delay. The effect on the hard disk is dramatic.

JS Sequential versus scattered reads

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Two lessons stand out. Scattered access on a hard disk is hundreds of times slower than continuous access, which is why a defragmented drive could feel faster and why operating systems try to place related data together. And although SSDs also prefer large sequential reads, their penalty for scattering is much smaller, which is why a computer with an SSD feels responsive when it opens many small files at once.

Wear: flash cells do not last forever

Each flash cell can be erased and rewritten only a limited number of times, because every write slightly degrades the insulating layer around the stored charge. SSD makers rate this as TBW (terabytes written) or as drive writes per day over a warranty period. A drive rated at 600 TBW can absorb 600 terabytes of writes before the manufacturer no longer guarantees the cells.

Two techniques make this a minor worry for ordinary use:

  • Wear leveling: the controller spreads writes evenly across all cells, instead of letting a frequently rewritten file burn out one spot.
  • Over-provisioning: the drive holds spare capacity, and bad cells are retired and replaced silently.
JS Wear leveling and drive life

Press Run (or Ctrl + Enter) to see the console output here.

No output.

A typical home user writes a few tens of gigabytes a day at most, so the rated lifetime is far longer than the likely life of the computer. Heavy write workloads (servers, video editing, databases) are where endurance ratings matter. Note too that the rated life is a guarantee, not a countdown timer: drives can also fail from controller faults, power loss or manufacturing defects, so a good backup is always needed (see Backups and Data Recovery).

RAID: several drives acting as one

RAID (redundant array of independent disks) combines drives to gain speed, safety or both. It is a feature of servers, network storage boxes and some workstations. Common levels:

Level How it works Survives Usable space (4 drives of 4 TB)
RAID 0 stripes data across drives nothing: one failure loses everything 16 TB
RAID 1 mirrors the same data on two drives one drive failure 4 TB (2 drives used)
RAID 5 stripes data plus one drive's worth of parity one drive failure 12 TB
RAID 6 stripes plus two parities two drive failures 8 TB
RAID 10 mirrored pairs, striped together one failure per pair 8 TB

Parity is the clever part. If you store, for each position, the XOR of the bytes on the data drives, then any single lost drive can be rebuilt from the remaining drives and the parity. The stand-in below does this on a few bytes.

JS Rebuilding a lost drive with parity

Press Run (or Ctrl + Enter) to see the console output here.

No output.

RAID is not a backup. It protects against a drive failing, but not against deleting a file by mistake, a virus encrypting everything, a fire or a power surge that hits all the drives. Mirrored deletions are mirrored too.

Storage in the cloud

Cloud storage keeps your files on servers in data centers run by a provider, reached over the network. Services for personal use sync folders between devices; services for companies offer object storage and virtual disks that can grow as needed. The data is typically spread over many drives and several machines, using ideas similar to RAID but at a larger scale.

The trade-offs are different from a local drive:

  • Convenience: access from anywhere, shared folders, no hardware to maintain.
  • Latency: every read goes through the network, so it is slower than a local SSD, and it stops working offline unless files are cached locally.
  • Cost and control: you pay a recurring fee and rely on the provider's terms, location of the data centers and security practices.

More on this appears in Email, the Cloud and Everyday Online Services.

Choosing storage

  • Operating system and programs: an SSD, preferably NVMe if the machine supports it.
  • Large, rarely used files (archives, media libraries): a hard disk gives the most capacity per dollar.
  • Backups: a separate drive or cloud copy, not just another folder on the same disk.
  • Servers and shared data: SSD or HDD arrays with RAID, plus real backups.

Optical and magnetic media: CD, DVD, Blu-ray, floppy and tape

Hard disks and SSDs are not the only storage that has mattered. Other removable media are still found in archives, libraries, studios and older equipment, and they appear in exam questions. They fall into two physical families.

Optical discs

An optical disc stores data as a spiral track of tiny pits (dents) and lands (flat areas) in a reflective layer. A laser shines on the track and a sensor reads the difference in reflection: no magnetism is involved. Different generations use shorter laser wavelengths, which allow smaller pits and more data on the same size of disc.

Disc Laser Typical capacity Common use
CD (compact disc) Infrared, 780 nm 700 MB of files (about 80 minutes of audio) Music, software in the 1990s
DVD Red, 650 nm 4.7 GB (single layer), 8.5 GB (dual layer) Films, software
Blu-ray Blue-violet, 405 nm 25 GB (single layer), 50 GB (dual layer) HD and 4K films, games

Each type comes in three flavours: ROM (read-only, pressed at the factory), R (recordable once, the laser burns the dye layer) and RW (rewritable, a phase-change layer can be rewritten about a thousand times). Optical discs are cheap, light and easy to mail, and they last a long time if kept clean and away from heat and sunlight, but they are slow, hold little by today's standards and are easily scratched. Many modern computers no longer have an optical drive.

Magnetic media

Magnetic media store bits as tiny areas magnetized in one of two directions on a coated surface.

  • Floppy disk: a thin flexible disk in a plastic shell, 1.44 MB for the common 3.5-inch type. Once the way to carry documents between computers, it is now obsolete: its capacity is smaller than a single photo. The "save" icon in many programs is still a picture of a floppy disk.
  • Hard disk: rigid spinning platters with read/write heads (see Storage Devices); capacity in terabytes.
  • Magnetic tape: a long strip of magnetic film wound in a cassette or cartridge. It is read sequentially: to reach data in the middle, the drive must wind through everything before it, so access is slow, but a cartridge holds many terabytes cheaply and keeps its data for decades. Data centres use tape for archives and backups, a role that suits it because archives are written once and rarely read.

Optical versus magnetic

Optical disc Magnetic disk / tape
How data is read Laser reflection from pits and lands Magnetic head senses the field
Writing Burned or changed by the laser; often write-once Rewritten freely by the head
Capacity today 0.7 to 100 GB per disc Terabytes per disk or tape
Speed Slow Fast (disk), slow to reach data (tape)
Affected by Scratches, heat, dirt Magnetic fields, shocks (disk), humidity and age (tape)
Typical use Distribution of films, music, software Everyday storage, backups, archives

For the storage types in current use (hard disks, SSDs, USB drives, cloud storage), see Storage Devices; for a comparison of access times, see the memory-hierarchy ideas in Memory, RAM and Cache.

Python How many discs does it take?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The last line shows that 80 minutes of uncompressed CD audio is about 847 MB: 44,100 samples per second x 2 channels x 2 bytes each. A disc holds more audio than files because file storage spends extra space on a stronger layer of error correction, which is why the same disc is quoted as 700 MB of data.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why is a hard disk slow at reading many small, scattered files?

    Each scattered read pays a seek and rotational delay measured in milliseconds, while the actual transfer of a small piece is tiny.
  2. 2. What is the difference between latency and throughput?

    Latency measures waiting time for a request; throughput measures how much data moves per unit of time once it is flowing.
  3. 3. Which RAID setup offers no protection against a single drive failure?

    RAID 0 only stripes data for speed; if any drive fails, the whole array is lost.
  4. 4. What does wear leveling do on an SSD?

    Spreading writes keeps any single block from reaching its write limit early, extending the life of the drive.
  5. 5. Which statement about RAID is true?

    RAID protects against drive hardware failure only. Deleted files, malware and disasters affect all drives, so separate backups are still required.

Summary

  • HDDs store data magnetically on spinning platters and are cheap per terabyte but slow to reach scattered data; SSDs store charge in flash, have no moving parts and respond much faster.
  • Latency is the wait before data arrives; throughput is the rate once it flows. Scattered small reads punish high-latency devices most.
  • Flash cells wear out with writes; wear leveling and spare capacity make this a minor concern for typical use.
  • RAID combines drives for speed or fault tolerance, using mirroring or parity, but it is not a backup.
  • Cloud storage trades some speed and control for convenience and capacity.

Next, see how everything connects in Motherboard, Buses, GPU and Power.