Update I updated my question to reflect the fact I'm working with a database. I need to process user actions:
- The actions for each user change the user's balance which is then persisted to a database.
- A user's action must be processed sequentially. Otherwise, we might corrupt the balance in the database.
- Some actions are associated with 2 users in which case they can't run in parallel with either user's actions.
- The volume of actions per user varies considerably during the day.
- Update The processes are going to be distributed over several machines.
I am trying to find a way to distribute the actions between processes so that the above requirements are met.
Is there a known paradigm, architecture or algorithm that solves such a problem?
I'm looking for a solution that does not involve processes talking to each other except through a message queue or some other scalable mediator.