Sunday, 4 June 2017

How to configure MongoDB and nodejs to use two different servers

I want to do the following structure for a website.

enter image description here

The idea is put web app on one server, and put MongoDB on another server. They are different machines.

In nodejs code, the only configuration for db is the following code:

var connectString = 'mongodb://localhost/myDataBase';

Replace 'localhost' with '111.222.111.2', the ip address of the machine where MongoDB is running on, then it should work. Is this correct?

Will this make data retrieval slower comparing with putting the on one physical machine?

How the two machines communicate with each other to get the data? Through what protocol?



via Nicolas S.Xu

No comments:

Post a Comment