Dual‑write vs rolling upgrade for zero‑downtime NATS consumer migration
29K reputation · 19 Apr 2023, 14:24 UTC
Goal: achieve zero‑downtime migration of a small application that publishes to a JetStream stream, moving consumers from an existing stream to a new stream while preserving exactly‑once delivery.
Constraints: must keep ack wait and max pending compatible with both streams, avoid message loss or duplication, and rely on documented NATS features (dual‑write or rolling server upgrade) without introducing custom logic that is not verified.
Uncertainty: the NATS documentation does not define a precise checkpoint or signal (e.g., lag, pending acks, quiescent period) for safely rebinding a durable consumer from the old to the new stream, leaving the switchover timing to implementer‑defined logic.
What observable metric (such as consumer lag, pending acknowledgments, or a period of zero publish activity) can be used as a safe trigger to rebind the consumer exclusively to the new stream?
How can we verify that no messages are missed or duplicated during the instant when the consumer binding switches from the old stream to the new stream?
Is there a recommended minimum quiescent interval after publishers pause before performing the rebind, and how should it be determined based on message rate and ack wait?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.