NodeJS Managed Hostings vs VPS

前端 未结 2 504
逝去的感伤
逝去的感伤 2020-12-12 19:23

There are a bunch of managed cloud based hosting services for nodejs out there which seem relatively new and some still in Beta.

Yet another path to host a nodejs ap

2条回答
  •  攒了一身酷
    2020-12-12 20:22

    Using one of the services is for the most part hands off - you write your code and let them worry about managing the box, keep your process up, creating the publishing channel, patching the OS, etc...

    In contrast having your own VM gives you more control but with more up front and ongoing time investment.

    Another consideration is some hosters and cloud providers offer proprietary or distinct variations on technologies. They have reasons for them and they offer value but it does mean that if you want to switch cloud providers, it might mean you have to rewrite code, deployment scripts etc... On the other hand using VMs with standard OS as the baseline is pretty generic. If you automate/script/document the configuration of your VMs and your code stays generic, then your options stay open. If you do take a dependency on a proprietary cloud technology then it would be good to abstract it away behind an interface so it's a decoupled component and not sprinkled throughout your code.

    I've done both. I did the VM path recently mostly because I wanted the learning experience. I had to:

    • get the VM from the cloud provider
    • I had to update and patch the OS
    • I had to install and configure git as a publishing channel
    • I had to write some scripts and use things like forever to keep it running
    • I had to configure the reverse http-proxy to get it to run multiple sites.
    • I had to configure DNS with the cloud provider, open ports for git etc...

    The list goes on. In the end, it cost me more up front time not coding but I learned about a lot more things. If those are important to you, then give it a shot. If you want to focus on writing your code, then a node hosting provider may be for you.

    At the end of it, I had also had more options - I wanted to add a second site. I added an entry to my reverse proxy, append my script to start up another app with forever, voila, another site. More control. After that, I wanted to try out MongoDB - simple - installed it.

    Cost wise they're about the same but if you start hosting multiple sites with many other packages like databases etc..., then the VM can start getting cheaper.

    Nodejitsu open sourced their tools which also makes it easier if you do your own.

    If you do it yourself, here's some links that may help you:

    Keeping the server up:

    https://github.com/nodejitsu/forever/

    http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever

    https://github.com/bryanmacfarlane/svchost

    Upstart and Monit generic auto start and restart through monitoring

    http://howtonode.org/deploying-node-upstart-monit

    Cluster Node Runs one process per core

    http://nodejs.org/docs/latest/api/cluster.html

    Reverse Proxy

    https://github.com/nodejitsu/node-http-proxy

    https://github.com/nodejitsu/node-http-proxy/issues/232

    http://blog.nodejitsu.com/http-proxy-middlewares

    https://github.com/nodejitsu/node-http-proxy/issues/168#issuecomment-3289492

    http://blog.argteam.com/coding/hardening-node-js-for-production-part-2-using-nginx-to-avoid-node-js-load/

    Script the install

    https://github.com/bryanmacfarlane/svcinstall

    Exit Shell Script Based on Process Exit Code

    Publish Site

    Using git to publish to a website

提交回复
热议问题