September 1st, 2024

Set Up a $4/Mo Hetzner VM to Skip the Serverless Tax

The article outlines a beginner-friendly guide to setting up a Hetzner virtual machine for $4/month, covering SSL installation, DNS configuration, and web application deployment using GitHub and PM2.

Read original articleLink Icon
FrustrationConfusionSkepticism
Set Up a $4/Mo Hetzner VM to Skip the Serverless Tax

This article provides a step-by-step guide on setting up a virtual machine (VM) on Hetzner for $4 per month, allowing users to avoid the costs associated with serverless architectures. The tutorial is aimed at beginners and covers the installation of Caddy for SSL, configuration of Cloudflare for DNS, and deployment of a web application using GitHub. Key prerequisites include purchasing a domain and generating an SSH key for secure access. The setup process involves registering on Hetzner, configuring Cloudflare, and installing Caddy to manage SSL certificates automatically. Additionally, the guide explains how to integrate a GitHub repository for manual deployment and includes instructions for setting up a simple Node.js application that restarts automatically using PM2. The article emphasizes the simplicity of the process and encourages users to explore further options like Docker for easier management and automatic deployments.

- Setting up a Hetzner VM can save costs compared to serverless architectures.

- The tutorial is beginner-friendly and avoids complex tools like Docker initially.

- Caddy is used for automatic SSL management, enhancing website security.

- Users can manually deploy applications from GitHub after setting up SSH keys.

- PM2 is recommended for managing Node.js applications and ensuring they restart automatically.

AI: What people are saying
The comments on the article reflect a mix of opinions regarding the setup of a Hetzner virtual machine and its comparison to other services.
  • Concerns about security and best practices in the installation process, particularly regarding the use of npm and PM2.
  • Debate over the title's accuracy, with some suggesting it is misleading and not representative of the content.
  • Discussion on the advantages of Hetzner's pricing and performance compared to cloud services like DigitalOcean and serverless options.
  • Comments on the latency issues for users in the USA when using European servers.
  • Suggestions for expanding the tutorial to include more advanced topics, such as automated deployments.
Link Icon 15 comments
By @fabian2k - 4 months
The title is clickbait or maybe simply misguided in my opinion. A cheap VM and Serverless services are very different things and not directly comparable.

But I do sometimes get the impression that the simple approaches are discarded too easily today. You can rent a lot of hardware pretty cheap from Hetzner and the raw power you get is much higher than what you get with cloud services for the same amount of money. Of course the cloud also provides more stuff, but you really pay a hefty price for some of the things you get there (cough traffic).

The difference gets even larger when you look at the Hetzner root servers, that's a lot of CPU, RAM and storage for little money. And renting actual servers does seem to be overlooked a bit at times, often the comparison is between the cloud and actually buying servers and doing everything yourself.

By @cedws - 4 months
I’m so disillusioned with cloud/serverless/Kubernetes these days. If I were building a startup I’d just build a monolithic service, plonk it on a Hetzner VM, boom done. You can start making money.

So many startups are bleeding cash because they’ve been convinced by AWS and others they need auto scaling and self healing from day one. Just build the thing, get it running, make it good later.

By @kamikazeturtles - 4 months
How does Hetzner compare to Digitalocean?

I always hear great things about Hetzner. I don't know if those comments are just patriotic Europeans or if Hetzner is really that much better than the alternatives.

By @uaas - 4 months
Going with a title like “How to set up Hello World on a Hetzner VM” would be less misleading.
By @etaioinshrdlu - 4 months
I would use Hetzner more but most of my user base is in the USA, and there is a lot of added latency to having your servers in Europe. I sort of think of Hetzner like a Costco for servers - does anyone know the closest equivalent in the USA?

Update: Hetzer does have USA servers, but apparently not dedicated bare metal servers in USA (only shared/VM).

By @aitchnyu - 4 months
What if I'm nervous about my SQL db? I pay 12$ onwards to RDS so I can do one click backups and restores to any point in time. With a VPS, I have to make a script to cron to generate backups and test that the VPS backup has backed up the file and the file is useful. Is there a "set and forget" solution?
By @hypeatei - 4 months
Serverless is nice for running low traffic services for free. Azure Functions for example don't start charging until 1M+ executions IIRC.

Transitioning to micro services also makes serverless more appealing since you're getting a separate web server (resiliency) and scaling for free if you need it.

By @thelastparadise - 4 months
When he says "serverless tax," a term I haven't heard before, is he talking about the development overhead?

If so, the code/test/deploy loop is certainly much faster with this method than any serverless I've messed with.

By @dark-star - 4 months
This, sadly, stops right where it gets interesting. Setting up a VM/VServer with Cloudflare and Let's Encrypt is pretty well-covered already.

Why not explain the "serverless" part a bit more? Say, automatically deploy on a new GitHub commit or something.

By @bernadus_edwin - 4 months
Coolify is really save my time
By @popalchemist - 4 months
This is an insufficient replacement for serverless. No scaling capabilities.
By @micw - 4 months
That feels so wrong to me:

1st to install node, an arbitrary script is downloaded and executed without having a look into it. Could do anything with the system.

Then `sudo npm install -g pm2` is called. That means the stuff is installed as root "somewhere" in the system - bypassing debians package management.

Then a "process manager" is installed to start/stop/manage a service - on a system that already has systemd doing the same job.

Is that really the way things should be done? Waiting for the day when the tutorial starts with modifying grub.cfg to directly boot into node.

By @joshbetz - 4 months
There are some things I host this way as well. On the other hand, I find that having autoscaling and automated deploys makes a big difference in speed I can iterate on some side projects.
By @insane_dreamer - 4 months
what's the "serverless tax"?
By @iAkashPaul - 4 months
Scaling/cold-boot time is the real concern IMO no the cost