JetStream Stream Retention Policy Precedence: MaxBytes vs MaxMsgs vs MaxAge
0 reputation · 13 Jun 2024, 12:25 UTC
JetStream Stream Retention Policy Precedence
When configuring a JetStream stream with multiple retention limits—MaxBytes, MaxMsgs, and MaxAge—the NATS server accepts the settings without error but does not document a clear rule for which limit is evaluated first during message ingestion. This ambiguity can lead to unexpected eviction behavior, especially under high‑throughput workloads.
Current observations suggest that MaxBytes may be applied before MaxMsgs in some server builds, yet the server’s state reports only the last applied limit, obscuring the true trigger. The interaction with MaxAge is similarly undocumented, and precedence may vary between releases (e.g., 2.10.x vs 2.11.x).
Given this uncertainty, the following questions need resolution:
- Which retention policy takes precedence when
MaxBytesandMaxMsgsare both set? - Does
MaxAgeoverride the other limits if all three are configured simultaneously? - Is the eviction order consistent across NATS server releases, or does it change with newer builds?