Can you suggest an architecture for a Node.js application with reverse proxy, MongoDB and static client app?

I need to host a production application for a relatively small number of users (say about 100 initially, but maybe increasing to 1000-5000 over the next years).

At the moment, I am trying to decide between hosting it all on PaaS providers like Google Cloud and mLab, or taking the do-it-yourself approach with Digital Ocean, to save some money.

If I were to host this application myself on Digital Ocean, what architecture would you recommend to use? And how many droplets?

My current thinking is to setup a Nginx web server to host the static client files and to act as a reverse proxy for the Node.js Express app and possibly a load balancer in the future. In addition, I will need a MongoDB database server as well.

There will be no need for a mail server, as I will be using Sendgrid to send emails.

Should I dump this all on one droplet or split it up in multiple? I want to avoid having to pay too much (e.g. have too many droplets) at this initial stage, so can I for example have 1 droplet for the Nginx web server and 1 droplet for the Node.js app + MongoDB database? Or should I run the MongoDB on a separate server?

And as a bonus question: what if I wanted to host a couple of static sites in addition to this application, could I safely do so on the same Nginx droplet? We’re talking minimal traffic for those small sites, and on a separate domain.

What are your thoughts? Are there any other considerations I need to think of?

What about scaling, security, load balancing?

Any feedback would be greatly appreciated!

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

With low traffic to start off you could choose to go with a single droplet though it may be easier later on if you use one droplet for nginx and a second for node + mongo. That way when you are ready to scale up you could add more web workers or separate your db onto a separate server. We have a variety of tutorials here on various load balancing methods. Not too long ago we released floating IPs which along with a server to monitor your active services would allow you easily fail-over as needed. For smaller deployments I also recommend CloudFlare. Their free tier provides a worldwide CDN and reverse proxy service which in many cases will reduce the load on your servers substantially as well as providing some basic protection against DDoS attacks.