Big Brother

We always know who the Boss is.

Now we need to upload our DB to S3 bucket, but if we allow each device to upload their database regardless of which device has all the changes (or most of), we will end up overwriting data every time each device uploads new DB.

We do now want a device which is sitting ideal, overwrite its data with a device which has larger data set.

So, how can we solve this? If we can know which device has most amount of data, it would be great and if we can determine that without maintaining that on server, that would amazing.

How can we find device with largest data?

Here is he approach:

  1. Keep track of all the data being download and locally created in table called BigBrother.

  2. We keep count of all the data that was created by our device as well as other devices by reading updatedBy device installation id.

  3. You can also decide, which collection/table has higher priority, than you can compare count of that only collection and decide if you are Big Brother or not.

  1. Now, while uploading, you check if your local device installation ID is matching with max(count) of installationId.

  2. You can also remove older entries you do not need (like a week old data)

Last updated