Are Serverless functions the right thing for me?

Hi there I want to build a small website that tests keyboards. Only I will test those keyboards and add them to the website. There will be no way for a viewer to comment etc. so my idea was to create a object inside a worker/function and use the worker as a database and "serverless backend" to retrieve the data, to keep the cost to free tier. If it becomes bigger then there is a reason to get a database etc because people are interested in my website, so it's an investment. So is that a good idea? I was thinking about CF Workers.
19 Replies
DomsoN
DomsoN2w ago
For me it seems reasonable to use normal database right away. Even if you will only store minimal amount of data, database is used for that. If you wanna use Next.js you could simply use Vercel as hosting provider. You should be able to get one postgres instance for free (included in free tier). Overall usage of Next.js and Vercel should fit your need. This will be serverless, both with database. You could nicely utilize caching. Also you will be prepared for an app to become more popular. And at the beggining you will get that all for free with free tier. Hope it helps ✌️
I'm Not An Engineer
Do i need to use next.js?
steakfisher
steakfisher2w ago
not necessarily? but if ur gonna build ur frontend out in react.. NextJS would be ur best (easiest) bet
DomsoN
DomsoN2w ago
I agree with that. You could use whatever you want
I'm Not An Engineer
But how does it look in terms of accessibility? Im actually from the EU and there is also Asia, Africa USA and I would like to have servers there too.
luis_llanes
luis_llanes2w ago
As far as I know, Vercel takes care of the infrastructure no matter what Tool you use on the front end. It provides a CDN worldwide. It happens to fit better with Next.js since they built it
I'm Not An Engineer
Cloudflare has also Pages and it's also world wide CDN with no limits or bandwidth restrictions. I can deploy my own VPS without using docker, bare metal. I could put all the data into a json file and that would be it, but that wouldn't be fun at all... to give all my hard work in a json file for everyone to access... That's why I was thinking about serverless workers on CF
steakfisher
steakfisher2w ago
u could host ur database in EU, and then cache the response for like a ridiculously long time, so the FIRST request would have to come all the way to EU but subsequent requests would be served from not too far replicating servers into multiple regions is not a good idea in general.. that was the thought behind Vercel Edge servers.. but that has a lotta problems u initially dont realize https://www.youtube.com/watch?v=yOP5-3_WFus&pp=ygUNZmlyZXNoaXAgZWRnZQ%3D%3D Fireship explains it really well in this vid u ideally should have 1 central server, 1 database as close as possible to that server, and then aggressively cache the responses from there
I'm Not An Engineer
But why a database? I mean the whole data assuming I test like 200 keyboards... will be like 1MB at most... Do I pay for the 1MB when a CF worker is invoked?
steakfisher
steakfisher2w ago
whats the alternative to a Database? a JSON file? honestly valid for such a use case.. the only problem would be.. you'd need to redeploy everytime u make a change to the JSON file.. other than that ur good
I'm Not An Engineer
I mean it's just a git push command or not?
steakfisher
steakfisher2w ago
ok we make a lotta assumptions about ur tech stack here We're assuming ur using react SINCE ur using react we're gonna assume ur using NextJS cuz its the "best" meta framework for React SINCE ur using NextJS we assume ur using Vercel cuz it's objectively the best way to deploy a NextJS application NOW u could go down the JSON route.. which is PERFECTLY valid for such a use case cuz ur the only one who is writing data, so u just rebuild the entire website whenever u wanna add a new keyboard (yes its just a git push cmd) OR U could go down the db route.. which might not be necessary.. at least not at ur scale now IF you go down the JSON route.. u could use Vercel Edge Servers... Vercel edge servers is basically just ur code spun up at a million different locations.. and since u dont have a database call, NOR will ur code require tm complicated libraries.. edge servers would be easy to setup AND really performant
I'm Not An Engineer
I don't use React or have learned it. Wanted to use Astro or something like that. Are the CF KC databases just caches or persistent stores?
Zokr
Zokr2w ago
as you are using astro which as far i know by default just generates static sites at build time, meaning it couldnt even use a json/db at runtime nor would it need one, based on that couldn't you just deploy it as a cloudflare page?
I'm Not An Engineer
I want to do it on CF but idk about the KC store.
steveyash
steveyash6d ago
@I'm Not An Engineer Weird idea - why not run everything locally and build to static files? Moreover, if you are the only one adding content, you might be able to get by with Jekyll or smtn and host on GH pages :).
I'm Not An Engineer
My opinion is that no production website unless it's a doc or project website should be hosted on GH pages.
steveyash
steveyash6d ago
GH pages is just a static host. Use S3 or literally anything else - even your own hard drive.
I'm Not An Engineer
I chose CF Pages, I think I might use workers because if I create a table with filters then it's better to have a worker to handle it and not send the whole thing at once.

Did you find this page helpful?