← Lessons

quiz vs the machine

Gold1340

System Design

The Pastebin Design

Storing and sharing text snippets with expiration, a cousin of the URL shortener.

4 min read · core · beat Gold to climb

What pastebin adds

A pastebin lets a user paste a block of text and get a short link others can open to read it. It looks like a URL shortener but stores content, not just a pointer to another site.

Storage split

  • A small metadata record holds the paste id, creation time, expiration, and a reference to the content.
  • The paste body can be large, so it lives in an object store or a blob column rather than inline in a hot index.

This split keeps lookups by id fast while the bulky text sits in cheaper storage.

Expiration

  • Many pastes are temporary, so each can carry a time to live.
  • A background job or a store level expiry removes expired pastes.
  • Reads check expiry and treat an expired paste as gone.

Read path

Like a shortener, reads dominate. A short id resolves to the content, which is cached for popular pastes so the object store is not hit on every view.

Key idea

A pastebin stores text behind a short id, splitting small metadata from a large body in blob storage, adding expiration, and serving read heavy lookups with caching.

Check yourself

Answer to earn rating on the learn ladder.

1. How does pastebin differ from a URL shortener?

2. Why split metadata from the paste body?

3. How are temporary pastes removed?