Loading...
1.POST /v1/comments
* Headers: `Idempotency-Key` (UUID) to handle duplicate retries.
* Body: `{ "parent_id": "optional", "content": "text" }`
2.GET /v1/comments/{post_id}?sort_by=popularity&page=1
3.PUT /v1/comments/{comment_id}
4.DELETE /v1/comments/{comment_id}
5.POST /v1/comments/{comment_id}/vote
* Headers: `Idempotency-Key` (UUID).
* Body: `{ "type": "upvote|downvote" }`
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.
SETNX. Only the first thread that acquires the lock is permitted to query the database and repopulate the cache. All other requests either wait briefly and retry the cache, or are served slightly stale data. We also add random "jitter" to cache TTLs so keys don't expire simultaneously.Idempotency-Key in the HTTP header. The API Gateway or the service itself checks this key against a fast Key-Value store (like Redis) containing recently processed requests. If a match is found, the system immediately returns the cached success response without reprocessing the write, ensuring data integrity.HTTP 429 Too Many Requests status, protecting downstream microservices and maintaining system stability.