![]() ![]() Let’s dive a little bit deeper into what it does.Īt present, CAP Theorem is often used to model distributed data stores. With 1 GB of maximum storage size, that means that our Pastebin clone can only store up to 100,000 pastesĭo take note that the limits are applied on a per-account basis.įor this POC, we are going to use KV as our database of choice.Assuming on average, a single paste (file) can consist of about 200 lines of code (text), that would mean that the size of each paste would be about 10 KB.1 character is 1 byte (using this byte counter).Here are the assumptions that we are going to make: Unlike storing a URL, storing text blocks can consume much more space (relatively speaking). In this section, we are going to do estimation on how many pastes can our Pastebin clone possibly store, given the limitations above. 1 GB of stored data (key size of 512 bytes value size of 25 MiB).That being said, we will be using Cloudflare KV (KV in the following), a low-latency key-value store for this project.Īt the time of writing, the free tier of KV comes with the following limits: Similar to a URL shortener, our application is expected to undergo a high read-to-write ratio. With Cloudflare Worker’s pricing and platform limits in mind, our constraints are: Like our previous attempt, the goal here is to host this service for free. The length of our UUID should be 8 characters.The UUID should only contain alphanumeric characters ( Base62).The link to the paste should expire after 24 hours.Whenever a user visits the generated URL, the user should be redirected to view the original paste content, i.e.Whenever a user enters a block of text (or code), our web service should generate a URL with a random key (UUID), e.g.Let’s start by clarifying the use cases and constraints of our project. To follow through this article, check out Steps 1 to 3 of this Get Started Guide. Rather, this is a proof of concept (POC) of how to build a simple paste tool using serverless computing with Cloudflare Worker. Building a commercial grade paste tool like Pastebin or GitHub Gist.How to tackle an actual system design interview.The design of this Pastebin clone would be very similar to building a TinyURL clone, except we need to store the paste content instead of the original unshortened URL.īefore we begin, this is NOT a tutorial or guide on: Paste URL UUID generation logic with key generation service (KGS).Project requirements and limitations planning.Building a Pastebin clone using Cloudflare Worker and KV.Well, sending >50 lines long block of text (or code) through a chat app ( looking at you, IRC) isn’t exactly the best way to communicate. If you are not familiar with Pastebin, I’d highly recommend you to give it a try before reading on. What follows is my journey of how I create a Pastebin clone using serverless functions through Cloudflare Worker. Today, we will be building a Pastebin clone - a web service that allows users to upload and share text through links known as ‘pastes’.
0 Comments
Leave a Reply. |