How to sync local mongodb databases with atlas server databases?

We have a physical event project, and there are registration, purchase tickets, check-in, and check-out, etc. processes.

There is a problem with limited internet access connectivity, and we don’t rely on the internet.

Below is the rough architecture for understand the flow:

I have highlighted the red line box, the sync part in the above image, The question is how to sync local server MongoDB databases with atlas server databases?

I am not getting the exact way how to do this.

Thank you.

Hi @turivishal,

The first thing that comes to mind is change streams. You could build a small app leveraging change stream feature to sync data both ways. Of course, the source and destination would flip depending on which side of the network - limited or unlimited connectivity - you are on. However, there are few caveats to this approach.

First, how do you handle conflicting updates and deletes? Does the chronological order take precedence when deciding the source of truth?

Second, how big should the oplog window be? Definitely greater than the length of lost-connectivity window. But then, how do you handle inserts/updates/deletes bursts which has the potential to overflow oplog before connectivity is achieved?

Anyway, those are some of the things to think about if you go down change-streams path. Hope this helps!


1 Like

Thank you for your suggestion will look into it.

There will be always inserts or updates operations, so it should be executed on the basis of oplog date order,

But yes there will be conflict for some reason the internet is off and some transactions have been made online and some have been made on the local server.

So let me list down the possible queries/operations, I will try to handle there should not be any conflict.

We have minimised the syncing dependencies to 2/3 collections, so change stream will work perfectly in this situation.

Thank you.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.