High availablility - Pastes should always be readable.
Low read latency - Very high read compared to write.
Read/sec - 200
Write/min - 100
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
POST /pastebin/paste
returns URL and TTL
GET /pastebin/url={url}
DELETE /pastebin/url={url}
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Read Server and Write Server and Cleanup Server will handle there responsibility seperately.
We will have load balancer sit before the other servers and route the traffic and spins up read server as need arise
AWS S3 is used to store the content and its url is assigned to the DB accurately.
All read goes through Redis Cache first before hitting the DB.
Cleanup Service monitors TTL(from DB) and clean the redis cache as well one TTL expires
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
POST /pastebin/paste
returns URL and TTL
GET /pastebin/url={url}
DELETE /pastebin/url={url}
CleanUp Service monitors TTL and clean up the Redis Cache accordingly.
If two text hits the api at the same time, we will use hash(content+timestamp) to randomize the key.
If clients POST times out, then we use the content hash and ensure that no duplicates are created.