Hosting Node.js and MongoDB

After digging into web development with Node.js the last couple of months, I had to choose where to host this blog, which I had decided to rewrite and run with Node as a result of my research.

Published on Tue, January 13, 2015

To be honest, I’ve been surprised there is no real ecosystem of (shared) hosting providers offering Node.js and MongoDB, which often is the obvious choice when developing a node application, on the cheap.

So it seemed to be a Do-it-yourself-world. Challenge accepted! :-)

Requirements

My personal requirements were:

  1. Run Node.js and MongoDB (or any other database) side-by-side. I don’t want to host my data in a data center hundreds or thousands of kilometers away.
  2. Easy possibilities to back up files.
  3. Reasonable cost-effectiveness with predictable pricing.

Option 1: Run your own physical machine

I am running Windows servers for my clients and some personal projects for more than a decade. For all of these more or less small to medium-sized projects, it has been sufficient to run IIS and SQL Server as well as other stuff together on single machines.

I always trusted Hetzner as their dedicated servers are cheap and robust and reliable. And even if some hardware fails, their support is fast and competent – even on Sunday mornings ;-).

If you want a powerful physical machine on the cheap - go for Hetzner and set up your server according to your needs.

I’ve published the “Node.js Web Server Guide” which describes how to set up an Ubuntu server to run multiple Node.js applications side-by-side.

Hetzner also offers free 100 GB backup space for each dedicated server. The guide contains a description of how to use it, too.

Option 2: Run each site on its own Virtual Machine

The cheapest dedicated server offered by Hetzner is currently the EX40, which costs precisely 41.18 EUR a month (plus taxes depending on your country and if you’re a private person or a business). And even if you get 32 GB RAM, 2 TB HDD, and a quad-core CPU for that money, it may be a bit over-sized for a single website (like my blog).

If you are running more than one site, there are other disadvantages, too:

Obviously, there are so many disadvantages, it seems worthwhile to look for alternatives.

First reflex: Why not to go for Amazon Web Services, Microsoft Azure or Google Cloud?

I have been working with both AWS and Azure, and all of them, including Google’s offer, are viable options. But for my taste, all of them are a bit too much for my needs, again. I don’t need endless scalability, at least not for now. But I do need a predictable pricing model, which none of these candidates offers.

While learning how to set up all that Linux stuff that was new to me, I often stumbled over articles published on DigitalOcean. And their tactic of excellent content marketing worked – I got curious about their offerings and decided to give it a try.

Today this blog runs on a virtual server with 1 GB RAM, 30 GB SSD Disk, and 2 TB transfer volume – more than enough for little peaks. The server itself was up and running after less than a minute. Including a preinstalled version of Node.js, thanks to their tremendous and simple administration tool.

I bought backups on top for 20% of the server’s price a month, so it costs about $12. But as they “only” back up the complete machine every couple of days and I want to be able to backup relevant files (web, database, nginx configuration) more often and regularly, I also rented an additional small virtual server at Hetzner.

This one is now running with one single role: storing backups from all of my servers on DigitalOcean. I think it’s implausible to lose data there. Still, I am sleeping much better by knowing everything important is backed up each day to a server running in a completely different and independent data center.

I could have been setting up another DigitalOcean droplet in another data center, but it would still be DigitalOcean. So even if hell freezes, I will be able to access my data on the Hetzner server.

I’ve written another guide that provides a detailed explanation about how to run a node app on a single server. Which requires fewer security considerations than a shared environment: “Setting up Ubuntu Server for running a single Website with Node.js and MongoDB”.

Conclusion

After running all of my (ASP.NET) stuff on only a few physical servers over the years, I am now contented with the second option. I think I will go for it for everything that doesn’t need the full scalability possibilities of the “Big 3 cloud providers” for the next time.

What do you think?
Drop me a line and let me know!