nats-server icon indicating copy to clipboard operation
nats-server copied to clipboard

[ADDED] Publish header "Nats-Expected-Last-Subject-Sequence-Subject"

Open cchamplin opened this issue 1 year ago • 4 comments
trafficstars

This change adds a new header "Nats-Expected-Last-Subject-Sequence-Subject" when when paired with "Nats-Expected-Last-Subject-Sequence" allows publishers to customize the subject used when the server enforces "Nats-Expected-Last-Subject-Sequence". Publishers can specify a alternative subject to be used that includes wildcards.

Resolves #5280

Signed-off-by: Caleb Champlin [email protected]

cchamplin avatar Apr 07 '24 16:04 cchamplin

Use case aside, the one concern I have is that LoadLastMsg is not nearly as optimized with a pattern as it is with a concrete subject. This is already known as a less optimized access pattern and it will be another use case to drive that improvement forward.

The question is whether this lands and the latency is not to folks expectations. @cchamplin Have you created a realistic app/test case against this to assess if the writes/second are sufficient for your needs?

I did some raw benchmarking against the filestore API to assess, but will want to try it out in a more practical test case.

bruth avatar Apr 11 '24 18:04 bruth

@bruth We have not created the type of test case you described. We aren't quite mature enough yet to know if this will negatively impact our performance in a way that matters, we suspect not, we don't have that many subjects that would be matched by our sequence subject pattern. Ultimately though we'd be willing to take a minor performance hit on publishing to unlock this functionality, especially if it's something that could be optimized in the future.

cchamplin avatar Apr 15 '24 21:04 cchamplin

@neilalexander @ripienaar I advocate for this coming into 2.11. There is no new risk. For those who use it, the performance profile would be equivalent to any other code path that hits LoadLastMsg with a wildcard which is generally known to need improvement in the extreme cases.

All that said, would like to hear your thoughts.

bruth avatar Jul 19 '24 02:07 bruth

Yeah seems like a useful feature, for sure 2.11 at the earliest

ripienaar avatar Jul 19 '24 11:07 ripienaar

@derekcollison this is ready for final review and merge for 2.11

bruth avatar Sep 04 '24 11:09 bruth