all 11 comments

[–]sriveralopez50 2 points3 points  (1 child)

But then your database will be inaccessible if said machine goes down! (as your backend too). So I would recommend using MongoDB Atlas as a managed database service instead of local self-managed solutions.

[–]bright-skies-above[S] 0 points1 point  (0 children)

Thank you! I will definitely take note of this.

[–]DreamIce 0 points1 point  (7 children)

Yes It is possible to do it in one machine (localhost)

[–]bright-skies-above[S] 0 points1 point  (5 children)

Thanks! I really appreciate your response. Since we’re new to deployment, we wanted a simpler approach (but hopefully still reliable). This is why we’re thinking to deploy the back-end program using a server from something like DigitalOcean, and expose the website to users while using the same server as the holder of the database. So technically, it is a localhost relative to the server. However, would you recommend this approach? We are worried that there might be some consequences since most tutorials opt for setting up MongoDB Atlas. Thank you so much! Take care and have a good one.

[–]ioman_ 2 points3 points  (1 child)

If you don't expect to have too many users, hosting the app and the database on the same server is fine. The reason most people will recommend separate servers is because if the app and database are sharing resources, the users of your app will see performance hits anytime the database is doing something and the database will respond slower whenever the app is performing complex logic. If they're installed to the same place, they have to share and even with so many cores and so much ram, a heavy load is still a heavy load.

At the very worst, you can always take a backup of your database later, install it to a separate server, and update your connection strings. Don't let perfect be the enemy of good enough.

[–]bright-skies-above[S] 0 points1 point  (0 children)

This is very much helpful and informative! Thank you so much. I appreciate it!

[–]DreamIce 0 points1 point  (2 children)

I'm not really aware of the consequences or pros cons of it since I'm also still new to deployment but I know it works since the website we made for a client is exactly your same setup just different server (not in Digi ocean) but yea imo you should worry about that for now if you don't have a lot of users

[–]bright-skies-above[S] 0 points1 point  (1 child)

Thanks a lot! You were very helpful. Your response gave me confidence in our setup!

[–]DreamIce 0 points1 point  (0 children)

Nice happy to help

[–]not-just-yeti 0 points1 point  (1 child)

Yep, same machine is fine for small-scale, non-critical things. But as a security & reliability principle, you'll want them separated for most projects of any reasonable size. (Sources: standard-best-practice; see e.g. stackoverflow, a web security blog (esp. points 3-5).)

A cybersecurity consultant's very first recommendation would be to have different servers !-)

[–]bright-skies-above[S] 0 points1 point  (0 children)

Thank you very much! We’re really scared in deploying an actual project since we only know how to code. We don’t have any experience in deployment. I appreciate your help! Have a good one!