Pastebin Service 00:00:01 One shared link for a new document A programmer shares a four-line example; a teammate shares a much larger log. Design a Pastebin-style service that returns the same simple link while choosing an appropriate storage path behind it. The author submits text with optional title, language, visibility and expiration settings. 40 KB becomes about 8 KB. The rule looks at the original size, so it is predictable. Key, owner, expiry, visibility and the path. The insert works only if the key is free. The author can share it now. Create the metadata only when it points at valid content. Keep visibility and expiry alongside the owner so every future read has a reliable authority to consult. 00:00:49 A link is opened at the edge The first reader opens the link. The service may have a public cached representation, or it may need to authorize and retrieve the authoritative text. Personal and one-time documents require different read rules. The browser asks for the address. First visit, or its life has ended. Compressed. The highlighted copy is fetched in the same way if it exists. Escaped and coloured. The next reader nearby gets it from the edge. Treat submitted content as untrusted text when displaying it. Syntax highlighting and caching must preserve the original visibility policy instead of turning a private document into a shared public response. 00:01:32 Two writers pick the same short key A random key is convenient, but the size of the keyspace does not make collisions impossible. Compare allocating keys ahead of time with generating one when the author presses Save. Both ways start here, 12 times a second. The pool marks one row used, skipping rows others hold. The random way draws characters. A unique key decides in both. The pool needs a worker, an alarm and an emergency path that draws at random. In either approach, a conditional unique insert determines who wins and a losing writer retries. For private data, possession of a short identifier must not substitute for required authorization. 00:02:14 Expire now and reclaim space later The product promises that an expired paste stops being readable at its deadline. A periodic sweeper can lag, and cached copies may still exist if their validity extends too far. Every 5 minutes. About 3,100 pastes are due. Usually gone already, because their life was bounded by the expiry. One request removes up to 1,000. The example needs several bounded deletion batches to drain this window of expired items. Restartable progress lets the sweeper resume after interruption. Check expiry when serving and cap the lifetime of shared copies. Use bounded, repeat-safe batches for physical cleanup. Logical expiry and freeing the last stored byte have separate clocks. 00:03:02 Two people open one burn-after-reading note Both readers see a button at the same time. A preview request should reveal nothing. The actual consume action must atomically establish which reader can access the single-use contents. GET reveals nothing, so a chat preview is harmless. Two POSTs arrive together. Set deleted where it is not yet deleted. The database lets one through. A reads the note. B is told it is gone. The winner may still lose the network response, so define what one-time consumption means under a lost reply. A database decision can guarantee at most one winner without guaranteeing that the winner actually read the text.