oci
System Design
beginner
Text sharing and code snippets

Pastebin System

System Design Classic

Pastebin is a text-sharing service where users paste content and receive a unique short URL for sharing. Despite its simplicity, it covers fundamental system design concepts: unique key generation, read-heavy traffic patterns (5:1 read/write), content storage strategies (inline for small pastes, object storage for large ones), and TTL-based expiration. Perfect for developers building lightweight text-sharing tools that need fast key-value lookups, auto-expiry, and syntax highlighting.

Data Flow

Load Balancer
Paste API
Paste Handler
Hot Paste Cache
Paste Metadata
Large Paste Storage

Share this architecture with your network

Service Breakdown (6 services)

Other6 services
Load Balancer
  • Distributes traffic across backend targets
  • Health-checks services and routes around failures
  • Scales automatically with traffic spikes
Paste API
  • Routes API traffic and enforces policies
  • Manages authentication and rate limiting
  • Provides a unified API endpoint
Paste Handler
  • Runs event-driven code without servers
  • Scales instantly from zero to peak load
  • Cost-effective for sporadic workloads
Paste Metadata
  • Handles flexible schema data at scale
  • Provides low-latency reads and writes
  • Scales horizontally with partitioning
Large Paste Storage
  • Stores unstructured data with high durability
  • Supports lifecycle rules for cost management
  • Serves as a data lake foundation
Hot Paste Cache
  • Caches frequently accessed data in-memory
  • Reduces database round-trips and latency
  • Supports TTL-based expiration policies

Scaling Strategy

Small pastes (< 256KB) are stored inline in OCI NoSQL Database for fast access. Large pastes go to Object Storage with NoSQL storing the pointer. OCI Cache handles the hot-path for recently created and popular pastes. NoSQL Database TTL automatically cleans up expired pastes without a separate cleanup job. OCI Functions handles both read and write paths with automatic scaling.

Related Architectures