I've reached the portion of my studies for the Google interview where I'm covering scalability and systems design.
This well-known article, Numbers Everyone Should Know, was intriguing, but it was hard to mentally get a handle on the scale of the numbers.
Here are a few:
So I converted some of them into round trips, since data accesses are round trips in themselves. I started with an L1 cache access, at 0.5ns, or a 2 ft round trip. So 1ns = 4 feet (1.219 meters). Read on for the rationale.
L1 Cache Access
Imagine you're sitting at your desk, and need some information in a book or on a sheet of paper. The most convenient access of that data would be to have it handy right there on your desk, about a foot away. You reach over (1 foot or 0.3 meters) and grab it, and pull your arm back to where you can read, another 1 foot. That's a 2 ft (0.61 m) round trip. Thats equivalent to an L1 cache access. Was in L1, eh? Lucky you! You didn't even have to get out of your chair.
L2 Cache Access
So you have to get out of your chair and walk across the room (large room) to a bookshelf, 14 feet away, and return to your chair, so you'll have it handy next time.
L3 Cache Access
You may have to be in a library for this one, or perhaps this book is upstairs in a room at the other end of the house. Walk 50 feet, get the book, and walk it all the way back to down to your desk. No peeking at it on your way back.
Main Memory Reference
You're going to have to go outside this time. At 100ns, you're going to have to walk down the block to pick up the book at your friend's house. 200 feet there and back.
4K Random Read from SSD
This number was pulled from a talk by Chandler Carruth (Googler) at CppCon 2014: "Efficiency with Algorithms, Performance with Data Structures". I wanted a number that would demonstrate the difference between SSD and spinning disk.
Keep in mind you can't drive. That would be cheating. Put on your good walking shoes and grab a water bottle and some protein bars. You're walking 57 miles to get that book, and 57 miles back home. You must really need that book.
That's the distance from the New York Stock Exchange (lower Manhattan) all the way to Danbury, CT. You may get there in time to watch the colors change.
Zoomed out for scale:
Oh boy. For this journey, you're gonna wish the folks in the datacenter had upgraded to SSD. You thought the upgrade from 5400 RPM to 15000 RPM was going to really help. Not this time. You have to walk 3,788 miles, then walk 3,788 miles all the way back to your desk.
That's the distance from Anchorage, Alaska to Orlando, Florida.
Send a Packet from CA to Netherlands to CA
This was just an extra one for fun, to highlight the difference between disk and a long-distance network access. A packet exchange like this would only be 2/3 of the SYN/ACK handshake for TCP, or an entire round trip for UDP.
Put on your moon boots. You're walking (theoretically) almost halfway to the moon. And then walking back.
It's in Google Sheets, naturally.
This post originally appeared on my other blog: Data Access Times Translated to Distances (with Pictures)