Estimate the scale of the system you are going to design...
Endpoint: /api/v1/pastes
Method: POST
Description: Create a new paste.
Request Body:
{ "content": "string", // Text content of the paste "expiration": "integer (optional)" // Expiration time in minutes (null or 0 for no expiration)}
Response:
{ "id": "string", // Unique ID of the paste "url": "string" // URL to access the paste}Endpoint: /api/v1/pastes/{id}
Method: GET
Description: Retrieve a paste by its unique ID.
Response:
{ "content": "string", // Content of the paste "created_at": "string", // Creation timestamp "expires_at": "string" // Expiration timestamp (null if no expiration)}Endpoint: /api/v1/pastes/{id}
Method: PUT
Description: Edit an existing paste. Only allowed for the creator of the paste.
Request Headers:
<token> (optional if using token-based auth)<session-cookie> (optional if using session management)Request Body:
{ "content": "string", // Updated text content of the paste "expiration": "integer (optional)" // Updated expiration time in minutes}
Response:
{ "id": "string", // Unique ID of the paste "url": "string" // Updated URL to access the paste}This API design provides a solid foundation for the Pastebin-like service, focusing on creating, reading, and editing pastes with appropriate security and validation measures.
We will go for the non-relational database which will be served across multiple region for speed, uid code and the text will be saved there. Non relational gives us flexibility to store random text very simply
.
client-http request -> api gateway ->load balancer nginx->backend service ->cache->db
client-http request -> api gateway ->load balancer nginx->backend service -> rate limiter -> uid generator -> redis cache -> db->replications -> kubernetes cluster
will go for the rails with the mongodb to make the development faster as we don't have too much concurrency or scalability here
network/server issue and db failure. db failure may send us to inconsistent data and we need to handle it separately. restricting user to a certain amount and preventing too much spam/fake data/ddos attack is a issue to consider
more server & cache server among region
improvement in resourses to data saving & consistency
improving cache size