← Back to All Questions
Easy~35 minStorage Systems

Design Pastebin - Text Sharing Service

GoogleAmazonMicrosoftGitHub

📝 Problem Description

Design a web service like Pastebin that allows users to store and share plain text or code snippets. Users can paste text, get a unique URL, and share it. The service should support syntax highlighting, expiration, and access control.

👤 Use Cases

1.
User wants to paste text content so that they get a unique short URL to share
2.
User wants to visit a paste URL so that they see the text content with optional syntax highlighting
3.
User wants to set expiration time so that the paste auto-deletes after specified time
4.
User wants to make paste private so that only those with the link can access

✅ Functional Requirements

  • Create paste with unique URL
  • Read paste by URL
  • Set expiration (10 min, 1 hour, 1 day, 1 week, never)
  • Syntax highlighting for 50+ languages
  • Optional password protection
  • View count tracking
  • Raw text download

⚡ Non-Functional Requirements

  • Low latency reads (< 100ms)
  • High availability (99.9%)
  • Handle 1M pastes per day
  • Support pastes up to 10MB
  • Data durability (never lose pastes before expiry)

⚠️ Constraints & Assumptions

  • Maximum paste size: 10MB
  • Custom URLs limited to premium users
  • Rate limit: 10 pastes per minute per IP
  • Storage retention: Based on expiry settings

📊 Capacity Estimation

👥 Users
10M monthly active users
💾 Storage
~1TB/year (1M pastes/day × 2KB avg × 365)
⚡ QPS
Write: ~12/sec, Read: ~120/sec (10:1 ratio)
📐 Assumptions
  • 1M new pastes per day
  • Average paste size: 2KB
  • 10:1 read to write ratio
  • 80% of pastes expire within 1 week
  • 20% of pastes are "hot" (80% of reads)

💡 Key Concepts

MEDIUM
Content-Addressable Storage
Store content by hash to enable deduplication of identical pastes.
CRITICAL
Separation of Content and Metadata
Metadata in DB for queries, content in object storage for scale.
HIGH
TTL-based Expiration
Use database TTL or cleanup jobs to remove expired pastes.
HIGH
CDN Caching
Cache popular public pastes at edge for low latency.

💡 Interview Tips

  • 💡This is similar to URL shortener but with content storage
  • 💡Emphasize separation of metadata and content
  • 💡Discuss expiration handling early
  • 💡Mention CDN for read optimization