Original link: https://limboy.me/posts/vercel-cf-fly/
From time to time, I will write some web pages (such as Pinyin Guess Idioms ) or deploy some static pages (such as this blog), or host some resource files (such as podcast audio), which involves the choice of online services. So far Vercel , Cloudflare , and fly.io are pretty good for most of my needs.
DNS Management & CDN
This part is managed by Cloudflare (CF for short). After creating a new Site in the CF background, at the domain name registrar, set the Name Server to Cloudflare’s Name Server, which is the following two
leah.ns.cloudflare.com wesley.ns.cloudflare.com
CF also provides domain name registration services. If it is a new domain name, it can be registered directly in CF, which is more convenient to manage and inexpensive.
Because the main business of CF is still CDN, it provides a very convenient function: proxy website static resources, which is the orange cloud (Proxy Status).
After it is enabled, the resources (such as pictures, CSS, etc.) under the domain will be cached by CF to the CDN. When users access these resources, they will directly access the cache on the CDN instead of their own server, which can save a lot of traffic. And CF’s CDN traffic is free, so you don’t have to worry about the traffic costs caused by the sudden increase in site traffic.
PS: After turning on “Auto Proxy”, if direct access is OK, but there will be problems with CF access, you can set SSL/TLS
to “Flexible”.
CF does not cache HTML files by default. If you want to set a more flexible caching strategy, you can do it through Page Rules. Free users can set 3 rules, which is basically enough.
Another advantage is that you can see the access statistics of the page in the background of CF. Although it is relatively simple (you can see the number of visits, but cannot be accurate to the page or source), it does not require additional JS code and does not need to rely on a third party. Access to statistics services is also not bad.
CF can also host some files of storage services. Take Backblaze (also known as B2) as an example, do a mapping to the DNS CNAME (also set the Proxy to Proxied), such as mapping assets.example.com
to f002.backblazeb2.com
, after uploading a resource file (such as the audio of a podcast) through the background or API, you will get the URL of B2, just change the domain name. For example, replace https://f002.backblazeb2.com/a/b.mp3
with https://assets.example.com/a/b.mp3
, and you can use CF’s CDN service.
static page
Static resources such as blogs or documents generated by SSG (Static Content Generator) will be deployed to Vercel , and the experience is really good. For example, after Connect Github, do some simple configuration, you can easily Deploy. Push to a branch other than main, you can generate a Preview page, after confirming that the content is correct, push to the main branch, and go online. This is also the Develop, Preview, Ship process advocated by Vercel.
The monthly traffic of 100G (all Projects combined) may not be enough if you use Vercel, but combined with CF, you can fully hold it (the traffic is mainly some HTML pages).
If you want to write some complex pages or involve some back-end logic, you can also use Vercel’s open source Next.js. The API will run serverless (so don’t rely on some memory globals). Recently Middleware has also become GA , and you can do some processing before the request reaches a specific page (such as judging whether there is a specific cookie, and then redirecting to a specific page).
CF also provides a similar service Cloudflare Pages , but I am still satisfied with Vercel, so I have not considered switching.
dynamic data
If the database is involved, for personal projects, either deploy on a separate VPS, or connect to the Cloud Database Service through API in Serverless code. The former has certain maintenance costs, and the VPS, back-end service, and DB Service must be guaranteed. For normal operation, various operations and maintenance (network time, disk space, CPU, memory usage, etc.) must also be considered.
In fact, there is also a third option. I choose fly.io , which can be simply understood as deploying Docker to edge nodes so that users can access services nearby. The free version of fly provides a certain amount of storage space (3GB, first create a Volume, and then mount it to the App), some simple projects, a SQLite file can be done, and it is very convenient to back up. More Serious projects can use the Postgres database they provide (supports multi-node deployment, read-write separation).
In this way, it combines the flexibility of VPS, and saves a lot of operation and maintenance costs, and because the service can be deployed on various nodes around the world, the access speed is also relatively guaranteed (after the Volume is hung up, only a single area can be locked. , because Volume is bound to App and Region).
At present, only a small project has been deployed on it, and it has not been used in a serious manner. However, it is endorsed by Remix and Kent . From some other feedback , it is also OK, and it should be a good choice.
Another reason is that fly.io also feels cool to me, such as the job posting written by Rust , this is one of the paragraphs:
The premise of our hiring process is that we’re going to show you the kind of work we’re doing and then see if you enjoy actually doing it; “work-sample challenges”. Unlike a lot of places that assign “take- home problems”, our challenges are the backbone of our whole process; they’re not pre-screeners for an interview gauntlet.
These three service providers basically cover all my online needs, and can support enough traffic for a small (or free) fee (Cloudflare is a big part of it). If you have similar needs, maybe you can consider it.
This article is reprinted from: https://limboy.me/posts/vercel-cf-fly/
This site is for inclusion only, and the copyright belongs to the original author.