Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

feat(naxum, veritech): limit naxum requests based on veritech pool availability - #8307

Merged
sprutton1 merged 2 commits into
mainfrom
feat/veritech/pool-admission-semaphore
Jan 20, 2026
Merged

sprutton1 merged 2 commits into
mainfrom
feat/veritech/pool-admission-semaphore

Conversation

@sprutton1

@sprutton1 sprutton1 commented Jan 20, 2026 •

Copy link
Copy Markdown
Contributor

How does this PR change the system?

This ties the size of veritech's available pool to it deciding to pull messages from nats. If the pool is empty, we won't pull more work until instances are readied. This effectively moves the queuing of function execution entirely to NATs, letting the back pressure be managed there instead of a per Veritech instances. This should mean that we never see execution pool starvation unless something has gone very wrong with the instance itself. This also means that we could more effectively dynamically scale veritechs based on the rate at which the nats messages are piling up without being serviced.

  • adds serve_with_external_semaphore to naxum to allow consumers to control semaphore behavior
    • important: this currently forget()s the acquired semaphore to allow consumers to control when it is replaced external to naxum using add_permit(). This feels wrong to me, but it seems like it is a supported pattern for OwnedSemaphore. I really just needed a way to block more requests pulling until instances reached a ready state in the pool.
  • threads through an enum in naxum to select on behavior. I don't love this additional branch, but I didn't want to duplicate the message processing logic and couldn't see a better way to modify the behavior to inject my forget call
  • adds a semaphore to poolnoodle that is responsible for adding permits back to the sempahore once instance reach a ready state
  • removes veritech_requests_concurrency_limit as it is no longer used

How was it tested?

Locally and with integration tests. Added a test to veritech-client to validate backpressure in nats.

  • Integration tests pass
  • Manual test: new functionality works in UI
  • Manual test: (regression check) creating a component still works

Does it require a docs change?

  • No
  • Yes, and this PR includes it
  • Yes, and this PR does not include it (reasoning below)

In short: 🔗

@github-actions github-actions Bot added A-veritech Area: Task execution backend service [Rust] A-si-pool-noodle labels Jan 20, 2026
@github-actions

github-actions Bot commented Jan 20, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or OpenSSF Scorecard issues found.

Scanned Files

None

@sprutton1

Copy link
Copy Markdown
Contributor Author

/try

@github-actions

github-actions Bot commented Jan 20, 2026 •

Copy link
Copy Markdown

Okay, starting a try! I'll update this comment once it's running...
🚀 Try running here! 🚀

@sprutton1
sprutton1 requested review from fnichol and nickgerace and removed request for fnichol January 20, 2026 18:25
@sprutton1
sprutton1 marked this pull request as ready for review January 20, 2026 18:25

@nickgerace nickgerace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sprutton1 this looks correct. I particularly like the separation of modes for the semaphore since this was confusing the previous times we've tried to update this logic.

@zacharyhamm @jhelwig would be great reviewers as well. This code can be tricky.

@zacharyhamm zacharyhamm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks correct. But, what's the lift on adding a test to lib/veritech-client/tests/integration.rs that validates the semaphore is working as expected? I think it's worth it

@sprutton1
sprutton1 force-pushed the feat/veritech/pool-admission-semaphore branch from b78cfaf to 499de53 Compare January 20, 2026 20:30
@sprutton1

Copy link
Copy Markdown
Contributor Author

/try

@github-actions

github-actions Bot commented Jan 20, 2026 •

Copy link
Copy Markdown

Okay, starting a try! I'll update this comment once it's running...
🚀 Try running here! 🚀

@sprutton1
sprutton1 force-pushed the feat/veritech/pool-admission-semaphore branch from 499de53 to c0294ef Compare January 20, 2026 20:33
@sprutton1
sprutton1 added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit 90f7119 Jan 20, 2026
4 checks passed
@sprutton1
sprutton1 deleted the feat/veritech/pool-admission-semaphore branch January 20, 2026 20:48

@fnichol fnichol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is really nicely done!

Comment thread lib/naxum/src/serve.rs
async fn next_message<T, E, R>(
stream: &mut Pin<&mut T>,
semaphore: Option<Arc<Semaphore>>,
semaphore: &Option<SemaphoreMode>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right, I wonder why I didn't borrow the Option<Arc<Semaphore>> before. Makes a lot of sense!

warn!("failed to push to ready queue: {}", id);
}
metric!(counter.pool_noodle.ready = 1);
self.admission_semaphore.add_permits(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see the purpose of the .forget() now, this is a bit like a token bucket!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A-si-pool-noodle A-veritech Area: Task execution backend service [Rust]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants