Question

Moving database (Mongo) to separate droplet.

Hi. I have a single Ubuntu droplet with Nodejs, nginx and mongodb running. I would like to move mongodb to seperate droplet to split the load. Please, give some advice regarding next questions:

  1. To allow app server connection to DB server, I can achieve it by enabling private networking for both droplets?
  2. After doing all manual setup (like in official guide: https://www.digitalocean.com/docs/networking/private-networking/quickstart/, should I add some sort of encryption to that connection? As I understand - no, because traffic between these droplets will only be visible to private network.
  3. Can I hide my database server from the public/Internet? If yes, then how I will connect to it via SSH for setup and administration?
  4. Should I use a DO Load Balancer, or I can just use nginx for that task as long as I have 1 application droplet?

Thanks in advance!


Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
June 15, 2023
Accepted Answer

Hi there,

Those are some very good questions. Let’s answer them one by one for anyone who comes across this in the future.

Private Networking: You can use a VPC for that. With the DigitalOcean VPCs, your Droplets are isolated at the network level, providing a secure and private environment for your resources. The traffic within a VPC is not visible to other Droplets outside the VPC.

Encryption: When using a VPC adding an extra layer of protection might be an overkill. However, this might depend on your security requirements, even with the enhanced privacy provided by a VPC, it might still a good idea to encrypt the communication between your application and database servers. Alternatively, you could use a Managed MongoDB cluster which already covers this:

https://docs.digitalocean.com/products/databases/mongodb/how-to/secure/

Hide Database Server: Yes, you can restrict public access to your MongoDB server by configuring the firewall to only accept connections on the MongoDB port (27017 by default) from the IP of your application server. However, for SSH access, you should allow connections on port 22 from your own IP. This way, you’ll still be able to connect to the server for setup and administration. DigitalOcean provides a cloud firewall service that you can use for this purpose.

Load Balancer: Using a DigitalOcean Load Balancer could be beneficial if you have more than one application server, as it can distribute incoming network load across multiple droplets to ensure better availability and reliability. However, if you only have a single application droplet, using Nginx as a reverse proxy should be sufficient for your needs.

I would personally go for a Managed MongoDB cluster which covers most of the things that were mentioned.

Hope that this helps!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel