Skip to content

[WIP] Manage Porter threads and backpressure better#106

Draft
derekpierre wants to merge 5 commits intonucypher:developmentfrom
derekpierre:backpressure
Draft

[WIP] Manage Porter threads and backpressure better#106
derekpierre wants to merge 5 commits intonucypher:developmentfrom
derekpierre:backpressure

Conversation

@derekpierre
Copy link
Copy Markdown
Member

@derekpierre derekpierre commented Feb 26, 2026

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

  • Depends on changes in [WIP] Additional safety valves when using NetworkRequestClient for making threshold requests nucypher#3722

  • Use a global concurrent requests semaphore for absorbing some back-pressure from too many requests; if the semaphore can't be acquired after a timeout then return 429. Reduce Hendrix max threads since it can overwhelm the server.

    • Add in flight caps for server requests that require communication with multiple nodes in a cohort; we don't limit /get_ursulas and /bucket_sampling since those can be used for health checks.
  • Configure max worker threads used per request, and allow overwriting via env variable

Issues fixed/closed:

  • Fixes #...

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network.
E.g., if this PR addresses a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on?
Is there a particular commit/function/section of your PR that requires more attention from reviewers?

@derekpierre derekpierre requested a review from Copilot February 26, 2026 18:27
@derekpierre derekpierre self-assigned this Feb 26, 2026
@derekpierre derekpierre changed the title [WIP] Manage Porter threads and back pressure better [WIP] Manage Porter threads and backpressure better Feb 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds request-level backpressure to Porter’s Flask/Hendrix web controller by limiting concurrent in-flight requests, while exempting health-check style endpoints.

Changes:

  • Introduces a global in-flight request semaphore with an acquire timeout and 429 on overload.
  • Exempts /get_ursulas and /bucket_sampling from the in-flight cap.
  • Lowers Hendrix deployer default max threadpool size.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
porter/main.py Defines the non-capped health-check paths and passes them into the WebController.
porter/controllers.py Implements the in-flight semaphore gating in Flask request hooks and adjusts deployer defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.19%. Comparing base (bc1aee7) to head (6b9ee68).

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #106      +/-   ##
===============================================
+ Coverage        90.91%   91.19%   +0.27%     
===============================================
  Files               18       18              
  Lines              969      999      +30     
===============================================
+ Hits               881      911      +30     
  Misses              88       88              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…h multiple nodes in a cohort; we don't limit /get_ursulas and /bucket_sampling since those can be used for health checks.

Use a global concurrent requests semaphore for absorbing some back-pressure from too many requests; if the semaphore can't be acquired after a timeout then return 429.
Reduce Hendrix max threads since it can overwhelm the server.
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.

4 participants