Question

Horizontal scaling with MongoDB and Nodejs

Hello,

I have a web application running on a single droplet, powered by Node.js + MongoDB + nginx on the same machine. Application traffic is increasing and I would like to scale my servers, so it will have 3 servers, one for MongoDB, second and third would be web servers.

My question is: how do I setup my mongodb server? Can I make it accessible only from my web servers, or it is possible to create some sort of “local network” on Digital Ocean, so only 1 IP (load balancer) could be seen from the Internet.

Also, any tips on making this setup are welcomed.

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 29, 2021
Accepted Answer

Hello,

In addition to what has already been mentioned, DigitalOcean now offers Managed MongoDB databases as well:

https://www.digitalocean.com/blog/introducing-digitalocean-managed-mongodb/

For more information on how to get started, make sure to check out this video here:

Regards, Bobby

Hi

Yes you can use the LB as your front facing IP. The LB can also use your internal network’s IP to connect. You’ll just need to be in the same DC and enable private network on all nodes.

Cheers

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.