It was asked to me in Amazon interview for SDE-2 position.

What is Pastebin?
Pastebin web service enable users to store plain text over the network and generate unique URLs to access the uploaded data. It is also used to share data over the network quickly, as users would just need to pass the URL to let other users see it.

Functional Requirements:

  1. Users should be able to upload plain text called as "Pastes".
  2. Upon uploading the paste user should be provided unique url to access it.
  3. Users should only be able to upload text.
  4. Url's should be expired after certain period of time, if expiration time not provided by the user.

Non-Functional Requirements:

  1. System should be highly reliable i.e no data loss.
  2. System should be highly available i.e user should be able to access their paste most of the time.
  3. Minimum latency to fetch user pastes.

Database Design:

  1. User table
    a. name
    b. email
    c. created_date
    d. last_login
    e. userId - PK

  2. Paste
    a. paste_name
    b. url
    c. content
    d. expiration_time
    e. created_date
    f. userId - FK
    g. pasteId - PK

System APIs

Can be implemented as Restful Webservices as -

  1. createPaste
  2. updatePaste
  3. getPaste
  4. deletePaste

High Level Design

At a high level, the system needs an application server that can serve read and write request. Application server will store paste data on block storage. All the metadata related to paste and user will be stored into a database. At a high level, various cache servers and load balancer can be configured to improve performance and scalabilty of the system.

0_1517558987394_High Level Design.PNG

Comments (18)