v1/paste
inputs: text
returns: link
v1/view
input: unique ID
returns: text
PastedText
The main entry point is the API servers
Writting is made asynchronously using a queue system
Purging old pasted text is handled by a dedicated service
One key point is the generation of a unique ID for the link sharing
We should try to avoid a generating an ID that was already used in the past even if the associated text has been purged
One possible solution using a hash function on several concatenated data:
unique_id = hash(content + timestamp + serverid)
Lot of data is written each day so we need a high troughput
Strong consistency is not required in this context
A NoSQL database can be used so we can scale better
There can be peak activity where users tries to write a lot of data
We can handle the writting asynchronously to prevent this bottleneck (using a queue system like Kafka or another technology)
If any database node is not available, the text is not lost thanks to the queue
The api server could write the text synchronously as a fallback if the queue system isn't available
We can improve this design with analytics and logs
Some text could be pasted severial times so we could add a way to store them just once