MongoDB.live, free & fully virtual. June 9th - 10th. Register Now MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Question regarding design and replica sets

Hi all,

First time posting a question here and a noob with mongo. Apologies if question = stupid.

I have an application that needs to be able to run on a local computer, even if that computer loses connection to the local network. The application will be used in a very small organisation … and in the event they have issues with their local network (switch failure eg.), the application still needs to work. The application uses a local mongo database. On the other hand, the application is designed to be able to being used in much larger organisations as well, with multiple clients, even in different sites connecting to the same database. Even in this situation, the requirement is still that the application must be able to run without network connection in case of serious network problems. So every client needs at least a working (read-write) local replica.

To add some redundancy, easy backup and scale up the app, I started testing with replica sets. As long as the client computer is connected to the network, this works great. I can add more nodes, make backups, datadumps, have some offsite replica’s etc. But the problem is that as soon as the client computer loses network connection, the local database (primary) goes into read-only (secondary). I can add as many nodes as I want … from what I understand, in this situation, the local database will always become readonly, even if that member was primary before the connection was lost.

My question is … is there a solution for this problem? Is there maybe another way to accomplish what I need, besides replica sets?

Thanks for the infomation

T

So all the client must connect to the same database / share the same datas, but the database must be stored in local for each client too in case of network failure.

You can achieve that with a primary node accessible through network and a secondary node on each computer.

But this imply that in case of network failure the local database will be only on readonly mode.
Otherwise, if client A and client B modifiy the same data on their local database, you will have a database inconsistency, the primary will not able to know which value used for update.

Thank you for your response.
That confirms what I was thinking. We’ll have to find a solution for this. :slight_smile:

I never tried this and maybe someone will able to confirm this,

You can probably use a shard cluster to achieve this, each shard will be a replica set.

One shard accessible through network containing commons datas, this shard is a replicaset and each client contains a secondary of this shard, in case of network failure they will be able to readonly the common datas.

One shard one each client containing his user datas, the primary run on the client and one secondary is running on each other client, in case of network failure, the client will be able to read/write his user datas, and readonly other user datas

I even don’t know if it’s working, but i think you can dig into this, it will more flexible than just using a replicaset

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