Question

How to use the PostgreSQL droplet with NodeJS?

Hello dear DigitalOcean Community,

I want to use a database for my NginX + NodeJS project that I’m working on. I surely need a SQL and a NoSQL database for my project.

1. What’s the difference between getting a ProstgreSQL droplet vs creating a droplet and installing PostgreSQL myself? 1.1 Is the PostgreSQL droplet faster compared to the “DIY PostgreSQL” droplet?

2. How do I use/connect to my PostgreSQL droplet database using NodeJS? 2.1 Which NodeJS package do I need to use for PostgreSQL?

3 Is it better to install a noSQL Database on the same droplet or on a separate one? 3.1 Will a separate droplet be faster compared to the same droplet? Much faster? One one side we have “CPU usage” and on the other side we have the delay between droplets.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @damiantoczek,

1. This is really up to personal reference. If you don’t want to take much time on installing and configuring, I’ll recommend the first option. Having said that, I’ll recommend to check the following DO Articles - here and here. One of the articles is for Ubuntu however it’s pretty good and shows good implications.

1.1 On one hand the PostgreSQL droplet is specifically designed by DO to work with their systems. On the other, you can configure it the same way if not better for you application if you built it on your own. Having said that, I’ll again go with the first option.

2./ 2.1 You’ll need to allow connections on your PostgreSQL droplet from the droplet your applications is built on. As for the actual code and how to, I’ll recommend checking this Article

3 This really depends on the traffic you expect and the budget you have. If you expect a lot of traffic and have enough budget, it’s always better to separate your Web Service and SQL service to different load balancers.

3.1 The actual delay won’t even be noticed. If everything has been configured correctly, there will be no loss or delay to the connection. I’ll recommend going with that option!

Kind regards, Kalin