Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVED] JSAPI internal routing and reporting and Source and Mirror setup #4884

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

derekcollison
Copy link
Member

A customer had an issue with JS api requests backing up in the internal queue we use to avoid blocking non-clients. The reason for the buildup was known due to time spent in NumPending calculations for R1 consumers with wildcard filtered subjects and large subject/key space. These consumers were being created from a large fan in stream with many sources.

  1. We now properly track the queue depth of this internal queue, warn if we are getting backed up and make sure to properly report under JS API usage stats - Inflight.
  2. Use multiple Go routines in a pool to process this API queue vs 1.
  3. When we fail to create a consumer for a mIrror or a source, back off retries.
  4. When we fail do immediate cleanup, do not wait.
  5. Only create internal interest for the consumer once we get a response from the source stream.

Signed-off-by: Derek Collison derek@nats.io

…lowly back off retries til we hit maximum of 2m.

Signed-off-by: Derek Collison <derek@nats.io>
…uests.

This was due to the fact the the request was for an R1 consumer with a wildcard filter subject on a large subject space.
This will be properly handled in a subsequent PR with a replacement for PSIM and calculating NumPending on a stream.

For now, we are doing several changes in this CL.

1. Warn if the internal queue starts to back up past a limit (32 atm).
2. Use multiple Go routines in a pool to process on the other side.
3. Make sure to track inflight properly. We exposed it as an api usage stat for JetStream, but were not properly tracking.

Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
Signed-off-by: Derek Collison <derek@nats.io>
…rrors and sources after when we receive a response.

Also cancel on a timeout since the consumer, even if created after, is of no use to us at this point.

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison derekcollison requested a review from a team as a code owner December 14, 2023 00:47
Copy link
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekcollison derekcollison merged commit 6d8f226 into main Dec 14, 2023
4 checks passed
@derekcollison derekcollison deleted the jsapi-queue branch December 14, 2023 17:41
wallyqs added a commit that referenced this pull request Dec 15, 2023
Includes:

- Check all filterSubjects of consumers when purging a stream (#4873)
- Move tokenizing of subject after early returns (#4880)
- Move helper subjectInfo() to the file where it's used (#4881)
- JSAPI internal routing and reporting and Source and Mirror setup (#4884)
- Do not load all blocks for NumPending when delivery is LastPerSubject. (#4885)
- Detect corrupt psim subjects during recovery of index.db (#4890)
- Add 'certs' option to TLS block for multi-certs support (#4889)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants