September 14, 2018

Hosting NodeJS + postgres

I'm looking for the best place to host my NodeJS application and a Postgres database, preferably low maintenance and fairly secure. Is Digital Ocean + Docker images a good option? Or should I go for something like Google Cloud who has ready to go Postgres?

  1. 6

    Heroku plus their Postgres add-on is a hassle-free choice.

    1. 2

      I ended up going with Heroku, Dockerized my Node app as well while I was setting it up. Got a basic instance up and running now. Works great!

      1. 1

        Awesome 👍

      2. 1

        By the way, I didn't know that you can use Docker on Heroku 😲

        1. 1

          It’s really easy:

          • docker build -t web .

          • heroku container:push web

          • heroku container:release web

          That’s it, your app is now running :)

          “Web” is a reserved name and the type of app you wish to deploy, i think there’s also “worker”and something else.

      3. 1

        This comment was deleted 4 months ago.

    2. 1

      +1 for Heroku

    3. 1

      I tried a few options and have to say Heroku was the easiest by a long long way. plus you can use the free option while you 'hack' I think it might cost a bit more once you scale it up tho

    4. 1

      That's definitely an option too, I'm already familiar with Heroku, so shouldn't be any hassle.

  2. 2

    So for anyone following this; I first gave AWS a try, was pretty easy to spin up a new RDS instance, but the security groups kinda gave me a headache.

    Decided to give Heroku a try too, again, easy enough to set up a new instance. I then spend some time on Dockerizing my Node application, which was easy enough. Took me a while to figure out how to get it up and running correctly. Basically Heroku gives you two environment variables: $PORT and $DATABASE_URL, which you should be using in your code.

    Once that was done, I pushed my Docker image and had everything up and running.

  3. 2

    I haven't used DO or GCP so can't comment on those. On AWS you could use RDS for Postgres (you can use micro instance for free). You can then use ECS/EKS to host your dockerized node app. I currently use ECS for my Node-based SaaS app. I think you might also be able to get one micro EC2 instance on the free tier too.

    One recommendation no matter what provider you go with is to go for a managed database service, rather than running your own database container instances on VM instances that you have to manage. Having your backups and patches all handled for you is great.

    1. 1

      That was my fear with DO, I have no interest in trying to manage a database, it's way too much hassle. I'll need to look into RDS, would be great if it's free (at first). Managing a node app is fine. I already have my SPA hosted on Google buckets. But I assume AWS services will work better together.

      1. 1

        If you decide to go the AWS route and find that your usage exceeds the free tiers, be sure to apply for the AWS Activate credits

      2. 1

        Yea, you would probably want to stick to the same cloud provider as it's best that your database is in the same data center as your app server (for both performance and security reasons). I use RDS for MySql which works fine, and I suspect the Postgres version of it is very similar.

        It doesn't really matter technically if the front-end content (your SPA) is on a different provider, although I guess it's nice to just keep all your deployed code (client and server-side) in the same place. Just in case you're not familiar with AWS services, their equivalent of Google Buckets is S3 (for storage) and CloudFront (for CDN).

        1. 1

          Makes total sense to keep everything together. I've been playing around with GCP more lately, so that's the only reason why I choose to use it. But I can easily put it on S3. Just wanted to get my database and app running first.

          Just created a new instance on RDS for free, seems to work good enough for what I need right now.

          1. 1

            Cool, good luck 👍

  4. 1

    I would suggest DO for both nodejs and postgres. 5$ postgres instance will scale enough for remarkable customer base.

    1. 1

      I'm a bit worried about doing self-hosted postgres to be honest, I rather pay slightly more and have it managed for me.

  5. 1


  6. 1

    I usually do a remote PSQL instance on AWS, and host on Lightsail with AWS - it works, and it’s reasonably affordable

  7. 1


  8. 1

    My suggestion is avoid cloud platform lock-in and use

    Then you can deploy to Digital Ocean, AWS, Azure or even Google and switch whenever you please.

    1. 2

      Looks good, but strange that the Nanobox pricing page makes you contact them to discuss.

      1. 2

        Yeah, I'm not a big fan of services who do that. Not looking forward to receiving their sales pitch.

        1. 2

          I avoid sites like that like the plague. Always makes me fee like I'm about to walk into a garage to have my car fixed.

      2. 1

        I've never paid them anything. It's totally free for teams of one, or at least it was when I signed up.

        Does it not let you sign up without contacting them now? (register still seems to be there)