Managing Content

Choose your own adventure

Summary

In this video, I explain two approaches for storing blog articles: embedding files in the binary or using S3-compatible storage with a CDN. I break down how each option works and their pros and cons. For the S3 approach, I show how it involves multiple steps like creating buckets, setting up CDNs, and automating file uploads. While this is more scalable, I explain why it's complex for a simple blog. I then demonstrate why I chose the embedded approach for this tutorial - it's simpler, with fewer moving parts, and better suited for a developer blog. This leads into our next steps of implementing the embedded storage solution.

Transcript

Welcome to module four. Before we start building the functionality to start showing real articles on the blog, I want to provide you with two paths forward. Essentially, we need to store our articles as files somewhere that we can then pull out, process and then serve them to our users. We already have one way of doing this because we have the way that we embed our static files into the binary of our application, but we could also opt for another approach, which would be to use something like S3 compatible storage, put it in front of a CDN and that will technically be more scalable, but it also adds some overhead in terms of steps required to fulfill this workflow and maintaining this whole setup, right? And if you're not familiar with what S3 compatible storage is, it's literally just file storage in the cloud and a CDN is short for content delivery network. And that will simply be that some provider has a lot of data centers or servers around the world, and then they will serve the files from whatever server or data center that is closest to the user. But for now, let's just quickly go over the pros and cons of these two options and why we are going to be using the embedded approach or embedding our article files directly into the binary of the application. So let's begin by looking at the external file storage option. And we just need the bucket and the CDN service, and you can get those from AWS or DigitalOcean, Cloudflare, there's lots of options out there. A very basic setup is that we create the bucket, we point the CDN to the bucket, upload all of our articles as files, and then we serve the content through the CDN, through our URL that we get provided through the CDN, right? However, in a more realistic scenario, you would have something like what you see here, that a user requests something through the browser, the app then needs to process that request as the CDN or caching layer, and if the CDN or caching layer has the file on hand, it will return it and reprocess and return it back to the browser. If not, it will pull out of the bucket and then go through the flow one more time. And while we could technically upload all of these files manually, we would probably like to automate a little bit more. So we would add article to the code base, push to GitHub repository and then trigger an upload action. If we didn't do like this, we will need to either manually add the files to the bucket and then update the app about this new file or path that is available. You could also create like an upload flow in the app dashboard, admin, whatever, right? But as you can see, this setup quickly becomes complex. There's a lot of moving parts that are additional running costs to these services, and if you're just going to be you as the only developer, the only writer, this starts to look like a little bit of an over-engineered option. But if you're going to go down having thousands of articles and many different offers, then maybe you want something like this, right? Because it will scale more and it will also be able to handle a ton more of a ton, a ton more, a ton, ton more amount of articles. Compare this to our option that we're going to be going with here is that we, we embed the articles in the binary and now it's literally just a browser calling the app, the app processes, the request, you know, pulls out the file from the binary process and form it, and then return it to the browser and our release flow here is again, we just, you know, we add the article to the code base. We push the code to GitHub repository, and then we release a new version. And if you want to remove the article, we will just remove it from the code base again, push and release. So, so for a one-man blog, for a developer blog, this is a much simpler version and it's going to be much more easy to maintain, fewer moving parts. So, so we are going to be doing this, this approach by embedding the articles into the binary, and then you can always use the external file storage option. If you want to try out a bit more complex setup.

Early Access

$95 $65 USD

Get access

Invoices and receipts available for easy company reimbursement