0

I'm just starting to learn more about the Node.js paradigm and finding it hard to grasp basic concepts. I'm familiar with front-end tools (HTML, CSS, JS) and have been using PHP with Apache server and mySQL db to deploy websites until now. It seems to be that node is it's own server, and I would then need a SaaS platform like Heroku, or AWS (I'm not even sure if i'm understanding the purpose of these) if someone could explain the difference? Is the database managed inside this service? Is the website being hosted there? In steps how would you get the node app to be served onto your domain name?

For Scalability purposes I understand how having dedicated big infrastructure can help, but if building a low traffic website with small number of members is there even a point in using node? normal hosting services cost between $4-20 usd. per month and AWS or Heroku seem to start at a MUCH higher price. Is Node only to be used for large scale scaling business model?

Thank you for any answers or good recent external resources (websites or books) you could point me to.

DrSocket
  • 135
  • 1
  • 11
  • I use A2 Hosting, which gives me an empty VM, where I install a version of CentOS (Linux). From there, I install what I want (Node, MariaDB, etc.) and configure it how I want and am good to go. I've had that for awhile and I'm sure there are many other options, which may work differently, and may be better or worse. – Dave Feb 27 '18 at 03:19
  • Thanks Dave! That sounds more reasonable price wise. Do you know if it's possible to install VM in any hosting? It looks like the standard hosting company, you just upload the linux installer and other files through ftp? – DrSocket Feb 27 '18 at 03:25
  • It's not quite correct to say "node is it's own server". It's more accurate to say "node can be used to launch servers". Think of it as a Javascript engine with some goodies added on, such as a collection of built-in modules for some common useful utilities, and a mechanism to load other external modules. There are simple servers in there that you can launch and use (e.g. the http and https modules for HTTP and HTTPS respectively), which you can use to launch one or more servers. For HTTP and HTTPS, it is more common to load an external module like `express`, but there are other options. – Dave Feb 27 '18 at 03:28
  • I think you have to check with specific hosting providers to see what you can do on them. At A2 with their virtual hosting, I get a VM, and can select a CentOS Linux version to install. Then I have a root user and configure it over SSH. – Dave Feb 27 '18 at 03:32
  • @Dave so express gets installed onto your VM Linux installation and that serves your domain? and can you serve a few different websites from that virtual hosting? sorry I really feel a bit thrown in the deep end with node, nosql... – DrSocket Feb 27 '18 at 03:52

2 Answers2

2

You could easily host a low traffic website built with node.js absolutely for free on Heroku. To see how easy that is, just go through the Getting Started With Node.js Heroku tutorial, in which you will do just that.

When you build your website with node.js, your own code that your write is the web server. You have no separate web server to configure and interact with (such as Apache). So what you see (or code...) is exactly what you get. You will probably want to use a framework such as Express to build your web server functionality in your node.js app.

As for NoSQL databases, the way to do this on Heroku is to use an appropriate "add-on" from the Heroku Elements Marketplace. For example, you could easily add Heroku Redis or MongoLab. These are just some of the NoSQL "Database as a Service" options. That means that the Database is itself hosted somewhere in the cloud, and your app simply interacts with it. You don't need to worry about database maintenance, security upgrades etc. You just need to concentrate on your app's interaction with the DB.

Almost all add-ons in the Heroku Elements Marketplace feature a free-tier, that may suffice for your needs, at least initially. So you might be able to get your low-traffic website (including the DB) up and running completely for free, at least initially.

One thing you will need to understand is how Heroku free dyno hours work. If you need your website to be continuously available 24/7, you may need to verify your Heroku account with a credit card (even though no charges would be incurred as long as you deploy only 1 free web dyno and are on a free-tier plan of your NoSQL DB as a Service). For further details, see this answer.

You also need to consider whether you can tolerate dyno sleeping in your low-traffic app. If not, you would need to prevent your web app from sleeping, which can also be done completely for free. For tips on how to do that see here.

As for serving your Heroku node.js app website from your own domain name, see here. Note that for this too you will need to verify your Heroku account with a credit card, although this too does not incur any charges.

Yoni Rabinovitch
  • 5,171
  • 1
  • 23
  • 34
-1

Node.js is supported by many web hosting already, especially for those who use Plesk or cPanel as their web hosting control panel. Here is guide about how to setup a Node.js website via Plesk control, https://www.bisend.com/blog/how-to-set-up-a-node-js-site-in-plesk. As you said, it's very easy to host your website with a cheap shared web hosting.

Ray
  • 11