S4 · Lesson 44 · Storage and I/O
Disks and SSDs, access time and IOPS, Little's law and the M/M/1 queue
Storage is where computers wait longest: a random read from a hard disk takes about ten million cycles, and even a flash SSD takes tens of thousands. Its performance is measured in operations per second and in response time, and response time depends on far more than the device's speed: as requests arrive faster, they queue, and the wait grows without bound as the device approaches full utilization. Queueing theory, starting from Little's law and the M/M/1 model, explains why storage and network systems are run well below 100% busy, and why averages hide the latency users actually feel.
- Mean response time of an M/M/1 queue (random arrivals, one server with random service times) in units of the service time S, against utilization ρ: .
- At 50% utilization a request takes twice its service time; at 90%, ten times; near 100%, the queue grows without bound.
- The dashed curve is the average number of requests in the system, (Little's law: arrival rate × response time).
Predict
A disk serves a request in 10 ms on average, and requests arrive at random, 90 a second. What's the average response time?
The disk is busy 90 × 10 ms = 90% of the time, so by the M/M/1 model the response time is 10 ms / (1 − 0.9) = 100 ms, ten times the service time, and on average 9 requests are waiting or in service. At 50 requests a second (50% busy) it would be 20 ms. Pushing utilization up buys a little throughput at a steep cost in latency.
Name it
Devices
- Hard disk: access time = seek + rotational latency + transfer + controller overhead. Average rotational latency is half a revolution, s. Random small reads are dominated by seek and rotation (about a hundred per second); sequential transfers run at hundreds of MB/s.
- Flash SSD: reads in tens of microseconds; writes go to erased pages, and erasure works on whole blocks, so the drive remaps writes and garbage-collects. Write amplification (physical writes ÷ host writes) wears the cells, each good for a limited number of program/erase cycles. Lifetime ≈ capacity × P/E cycles ÷ (daily host writes × write amplification).
- IOPS = 1 / access time for a device serving one request at a time; parallel devices (SSDs, arrays) serve several.
Queueing
- Little's law (any stable system): , the average number in the system equals arrival rate × average time in it.
- Utilization for arrival rate λ and mean service time S.
- M/M/1 (Poisson arrivals, exponential service, one server):
- To keep the mean response time below a target T: .
Worked example
A 7200 RPM disk has an 8 ms average seek and transfers at 200 MB/s. How long does a random 4 KB read take, and how many can it do per second?
Show the solution
- Rotation. Half a revolution at 7200 RPM takes 4.17 ms.
- Transfer.
- Access time. so about 82 random reads per second.
- Compare with streaming. Sequentially it could stream 200 MB/s, 50,000 4 KB blocks a second. Disk performance depends almost entirely on the access pattern.
Answer a random 4 KB read takes about 12.2 ms, so the disk does about 82 per second.
Worked example
An SSD holds 1 TB, its cells tolerate 600 program/erase cycles, write amplification is 3, and the host writes 100 GB a day. How long does it last? And for the 10 ms disk, what arrival rate keeps the mean response under 25 ms?
Show the solution
- SSD lifetime. about 5.5 years.
- Disk arrival rate. which is 60% utilization.
Answer the SSD lasts about 2000 days (5.5 years), and the disk must see at most 60 requests a second.
Worked example
A disk serves requests in 10 ms each. What response time does an M/M/1 model predict at 60 and at 90 requests a second?
Show the solution
- At 60 a second. Here : with 1.5 requests in the system on average.
- At 90 a second. Here :
- The lesson. Adding 50% more load quadrupled the response time, which is why storage systems are run well below full utilization.
Answer 25 ms at 60 requests a second and 100 ms at 90.
Check
What's the average rotational latency of a 7200 RPM disk?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A disk has an 8 ms average seek, spins at 7200 RPM and transfers 250 MB/s. How long does a random 64 KB read take, ignoring controller overhead?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
Requests arrive at random, 20 per second, at a device whose mean service time is 5 ms. What's the mean response time by the M/M/1 model?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
Requests arrive at 200 per second and each spends 5 ms in the system on average. How many are in the system on average?
Check
A device's mean service time is 4 ms. What's the highest arrival rate, per second, that keeps the M/M/1 mean response time at 10 ms?
Check
An SSD of 2 TB has cells rated for 600 program/erase cycles and a write amplification of 4. The host writes 200 GB a day. How many years does it last?
Check
A disk spins at 7200 RPM, seeks in 4 ms on average and transfers at 250 MB/s.
(a)
How long does a random 4 KB read take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
How many can it do per second?
Check
A server takes 5 ms per request, and requests arrive at 20 per second (M/M/1).
(a)
What is its utilization?
(b)
What is the mean response time?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(c)
How many requests are in the system on average?
Check
An SSD of C GB endures P program/erase cycles with write amplification w; the host writes h GB a day.
Step 1
How many gigabytes can be written to the flash in its life?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
How many days does it last?
Explain why
Why do storage systems run far below full utilization, when a busier device does more work?
When requests arrive at random, they sometimes bunch up, and while the device works through a bunch, later arrivals wait. The busier the device, the more likely each arrival finds others ahead of it, and the queue's average length grows as ρ/(1 − ρ), so the waiting time grows without bound as utilization approaches 100%. Going from 50% to 90% utilization raises throughput by 80% but multiplies the mean response time by five, and the slowest requests, the ones users notice, get worse still. Systems that need predictable latency are therefore sized to stay at moderate utilization, and buy the throughput they need with more devices instead of busier ones.
Practice
Keep practicing
11 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.