Preserve order when events split across workers
More workers increase throughput only when the integration also defines which events must remain together.
- Published
- Updated
- Reading time
- 8 min read
Tested environment Synthetic event streams partitioned by patient-safe surrogate keys with delayed workers and retries.
Name the ordering boundary
Global order is expensive and often unnecessary. Decide whether order belongs to one device, one order or another stable business key. Keep that key free of patient data when it appears in operational metadata.
Send one boundary to one lane
Hash the ordering key into a stable partition. Workers can process different partitions in parallel while one partition remains serial. Resharding needs a controlled handoff so two owners do not race.
Hold the gap
When an earlier event is retrying, do not let a later dependent event silently pass it. Park the ordering lane, continue unrelated lanes and make the blocked reason visible.