Skip to content
We areTOP 1%

Design a pastebin service

MediumConceptWeb Services
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Requirements: users upload a block of text and receive a unique link; pastes may be public or unlisted, can expire, and are read far more often than written. A paste can be up to a few megabytes.

  • Write path: generate a unique key as in a URL shortener, store the content in object storage, and store metadata (key, owner, size, expiry time, storage location) in a database.
  • Read path: look up the metadata, then serve the content from object storage through a CDN or cache, since popular pastes are read heavily.
  • Expiry: a background job deletes expired pastes in batches, and every read checks the expiry time so that expired links never serve content.
  • Trade-off: keeping content in object storage rather than the database costs an extra lookup, but keeps the database small and cheap to scale.

More in Web Services

Web Services questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Design a URL shortener
MediumConcept
ConceptMedium Read the answer to Design a URL shortener
2Design a pastebin service
MediumConcept
ConceptMedium Read the answer to Design a pastebin service
3Design a rate limiter
MediumConcept
ConceptMedium Read the answer to Design a rate limiter
4Design a notification system
HardConcept
ConceptHard Read the answer to Design a notification system

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account