identifier
), such as an auto-increment ID or a timestamp in milliseconds.P
must be a prime number strictly greater than 1.\text{Fragment} = \text{identifier} \mod P
identifier
is a consistent numeric key (e.g., timestamp
, recordId
);P
is a prime number representing the number of logical fragments;Fragment
is the integer remainder in the interval [0, P−1]
.P
. If P
is non-prime, remainders become non-uniform and overlapping due to shared factors.mod 4
):0, 2, 0, 2...
— overlap on even-numbered identifiers.0
— over-concentration on a single fragment.mod 7
):0, 1, 2, 3, 4, 5, 6
P
for the fragmentation base.R ∈ [0, P−1]
, execute:
A dataset with 1 billion records is distributed to 97 workers using mod 97
.
P = 97
(a prime);R ∈ [0, 96]
;
Modulo Base | Prime? | Distribution | Collision Risk | Valid? |
---|---|---|---|---|
4 | ✗ | Biased | High | ✗ |
6 | ✗ | Colliding | High | ✗ |
7 | ✓ | Uniform | None | ✓ |
97 | ✓ | Uniform | None | ✓ |
P
for any arbitrary n
forms a complete and uniform residue system when P
is prime.n mod P
maps uniquely to one of the P
fragments.