Hi,
Am trying to find a solution to saving IoT meter data in an effective way.
I found two challanges:
- Avoid duplicates from meter that sends redundant updates
- Limit number of DB interactions for each meter update to get good performance.
One solution I found is to use a unique combined index that covers the following
MeterID, MetricID, TimeStamp
And then make a bulk insert (insertMany) with the option ordered: false so that MongoDB will insert only new metrics that is not already in the DB (based on the combined index).
When doing inserts I can by this send any update and be sure that there will be no duplicates per meter. For each meter update I only need one MongoDB request.
My question about this solutionis:
Is this a good solution?
Will I get good performance with single updateMany according to the above?
Is there any other solution that solves the same requirements?