AI Hints
Home›System Design Tutorial›Practice and Next Steps
System Design · Lesson 118 of 120

Practice: Design a Pastebin

Your turn.

⏱ 2 min read▶ Video at 2:23:30🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Your turn. Design a pastebin, a site where people paste text, and get a link to share it. Like a URL shortener, but storing the text itself. Pause the video, and work through the four steps on your own.

Practice: Design a Pastebin
From the video: Practice: Design a Pastebin
  • Paste text, get a link
  • Like a shortener
  • Pause and try

Requirements and estimates

Here's one answer. Users paste up to one megabyte of text, get a short link, and pastes can expire. Reads are fast and highly available. Estimates, one million new pastes a day, ten reads each, and an average paste of ten kilobytes. That's about ten gigabytes a day, and under four terabytes a year.

keyvalue
Pasteup to 1 MB, optional expiry
Traffic1M writes, 10M reads a day
Average paste10 KB
Storage~10 GB a day

One possible design

The design reuses what we know. The API server makes a short code from a unique ID. The text goes into object storage, because it can be large. A small database row stores the code, the storage key, and the expiry date. Reads check a cache first, and popular pastes are served from a CDN. A daily job deletes expired pastes.

  1. Short code
  2. Text to storage
  3. Metadata row
  4. Cache + CDN reads
  5. Expiry job
One possible design
From the video: One possible design

Summary

A pastebin combines short codes, object storage, metadata in a database, caching, and a cleanup job. If you got close, you're thinking like a system designer. Next, the whole course on one page.

Key takeaways
  • Short codes
  • Text in object storage
  • Cache, CDN, cleanup
Next up: The Cheat Sheet — everything on one page