Design a Pastebin-like web service for storing and sharing text.
Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer
System Design Scenario:
1. Requirements:
* User uploads text, gets a unique URL.
* Text expires after a set time.
* Read-heavy system.
2. Back-of-Envelope:
* 1M new pastes/day. Average size 10KB. Storage: 10GB/day.
3. API Design:
* POST /api/paste (body: content, expiry) -> returns URL.
* GET /api/paste/:id -> returns content.
4. Database:
* NoSQL (DynamoDB/Cassandra) or Object Store (S3) for content.
* Metadata (ID, content_url, expiry) in SQL or key-value store.
5. Unique ID:
* Base62 encoding of a unique counter or hash.