I am matching the items from two lists, eg here the element c of A and c of B would match. I then do some processing and add the matched pair in another list.
- List A
- a
- b
- c
- List B
- c
- d
To do this I watch for addition on both list A and B, and check if a match exist when something is added.
This works well, but I have too many inserts for a single client.
So I need to run my matcher on multiple machines to speed things up.
But I want each match to happen only on one machine, ie if machine 1 finds a match there's no point for machine 2 to process it as well.
I tried using atomic commits but while this prevents multiple matches to mess with each other, the matching is still done twice.
How could I "lock" elements to make sure other machines don't consider them once the matching process started?