Delicious: Hardware, Database, and the 1 GB Rule
Why personal laptops make terrible servers, the storage math behind a million bookmarks, and the engineering lesson from YouTube's Gangnam Style overflow.
At this point, Joshua has Delicious online and it is starting to go viral. Millions of bookmarks are arriving, and he is hitting his first real walls: Hardware and Storage.
2003 Hardware: A Different Reality
To appreciate the scale, I had to look back at what "power" actually meant in the early 2000s. Even in 2007, a mid-range PC came with:
- 128 MB of RAM: That is megabytes, not gigabytes.
- 40 GB Hard Disk: I remember shopkeepers warning that this was "too much" and you'd never fill it in your life.
- Core 2 Duo CPU: Having two cores was a massive luxury.
Joshua's 2003 laptop was likely even weaker than that.
Rule #1: Dedicated Servers Only
Joshua's first scaling bottleneck wasn't actually his code - it was his lifestyle. Because he was serving the site from his personal laptop:
- Nightly Shutdowns: When Joshua went to sleep and closed his laptop, Delicious went down for the whole world.
- Resource Contention: If he tried to play a game, the website slowed to a crawl for everyone else.
The lesson here is simple: For a system to scale, it must run on Dedicated Servers - machines that stay on 24/7 and do nothing but serve requests.
The MVP Database Schema
To support the basic features (Login, Add Bookmark, View List), we only need two simple tables:
- Users:
id,username,password. - User_Bookmarks:
user_id,url.
ExpandDelicious MVP Database Schema
The Engineering of Data Types
One thing I realized is that your choice of data types sets your ultimate ceiling.
Why use an 8-byte Integer (BigInt) for user_id?
A standard 4-byte integer can store up to 4.2 billion values. That sounds like a lot, but there are over 5 billion internet users. If you use a 4-byte integer, your system will literally break when the 4,294,967,296th user tries to sign up.
The Gangnam Style Bug: In 2014, the Gangnam Style video became the first to cross 2.1 billion views. YouTube was using a 4-byte signed integer to store views. When it crossed the limit, the number "overflowed" and became negative. They had to rewrite their entire infrastructure to use 8-byte integers.
The Storage Math: The 1 GB per Day Rule
Joshua is now receiving 1 million new bookmarks every single day. Here is the math that started the countdown:
- Row Size:
user_id(8 bytes)url(averaging ~1,000 bytes for long URLs)- Total: ~1 Kilobyte (KB) per bookmark.
- Daily Growth:
- 1,000,000 bookmarks x 1 KB = 1 Gigabyte (GB) per day.
At this rate, Joshua's 40 GB hard drive - the one that was supposed to "last a lifetime" - will be 100% full in just 40 days.
He is on a clock. In the next part, I will show you the two choices he had: making his machine stronger or adding more of them.
The Essentials
- Production systems must run on Dedicated Servers that are on 24/7 - running a live service from a personal laptop is the first bottleneck most new developers overlook.
- Data type choices are architectural decisions - using a 4-byte integer for a user ID that will eventually exceed 4.2 billion is a system-breaking mistake, as YouTube's Gangnam Style overflow proved.
- Simple storage math reveals real deadlines: 1 million bookmarks per day at ~1 KB each = 1 GB/day, meaning a 40 GB disk fills up in 40 days - this is how engineers think about capacity planning.
Further Reading and Watching
- Hussein Nasser - Database Indexing, Storage, and I/O - A practical deep dive into how databases store rows on disk and why data type choices have physical consequences.
- PostgreSQL Documentation - Data Types - The official reference for integer sizes, storage requirements, and the exact limits that caused bugs like the Gangnam Style overflow.
Keep reading