can use one mongo database with multiple application servers and still maintain integrity of our data.?

Viewed 15
  1. I created a mongo db server on my local machine and a database and within a row we are targeting just one field "count" with default value of 0.

  2. Node_instance1 - node server having an increase_api to hit a url which targets a row's one field "count". and INCREASES(+) the "count" +100 times.

  3. Node_instance1 - node server having an decrease_api to hit a url which targets a row's one field "count". and DECREASES(-) the "count" -100 times.

Now every time we hit the both the apis once... one server increases the count while another server decreases the "count" and finally out database "count" value should be "0" at the end and we do receive 0 atleast everytime i tried.

but if i increase the repeat ion from 100 to 1000 the value at the end is not "0" it's any random integer. i tried many times and almost every time i get different random number and not "0".

i thought mongo is an ACID compliant database. i am not really sure where is the problem or what might be going wrong. any comments are welcome to point me in the right direction.

I JUST WANT TO KNOW IF WE CAN USE ONE DATABASE WITH MULTIPLE APPLICATION SERVERS OR I GUESS MY QUESTION IF WE SHOULD. i am newbie. so thank you very much for any help! Appreciated!.

0 Answers
Related