shlogg · Early preview
Artem Gurtovoi @temich

Modulo Partitioning Algorithm For Distributed Systems

Modulo partitioning algorithm emits (index, replicas) every `interval` seconds using Redis key `{name}:{number}`. Index transitions require safe transition process to prevent task duplication or loss.

Problem

Modulo partitioning algorithm taks.id % replicas == index requires knowing the number of task processing instances running in the cluster and the own index of the current instance.

  
  
  Forces

Static configuration is not an option (due to dynamic scaling / failover).
In a distributed system, there is no concept of a global current time.

  
  
  Solution

An algorithm that emits (index, replicas) once per interval seconds, using a common Redis key and atomic increment.
Define the following parameters:

name: a name of the task processing (e.g. mail-sender)
interval: indexing inte...