Add flight-controlled thread pool expansion for silent requests, Fixes AB#3492151#2865
Add flight-controlled thread pool expansion for silent requests, Fixes AB#3492151#2865Prvnkmr337 merged 13 commits intodevfrom
Conversation
…92151 Fixes: AB#3492151 Problem: The Broker's silent token request thread pool (sSilentExecutor) is fixed at 5 threads. Under high load scenarios with multiple concurrent ATS requests from various client apps (Teams, Outlook, OneAuth), this can cause request queuing, increased latency, and potential timeouts. Solution: Introduce a flight-controlled mechanism to expand the thread pool from 5 to 8 threads, applying ONLY to the Broker module (not MSAL client apps). Changes: - CommonFlight.java: Add ENABLE_EXPANDED_BROKER_SILENT_THREAD_POOL flight (default: false) - CommandDispatcher.java: Add initializeSilentExecutorForBroker() and resetSilentRequestExecutorWithSize() methods with graceful executor shutdown handling - AndroidBrokerFlightsManager.kt: Call initializeBrokerSilentExecutor() during Broker initialization after flights are loaded Key design decisions: - Uses Android process isolation: Broker runs in separate process, so static sSilentExecutor is independent from MSAL client apps - Broker-only initialization: AndroidBrokerFlightsManager is Broker-specific code that MSAL apps never call - Flight-controlled: Safe rollout via ECS with instant rollback capability - Graceful shutdown: Existing executor is properly terminated before creating expanded pool
|
✅ Work item link check complete. Description contains link AB#3492151 to an Azure Boards work item. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a flight-controlled mechanism to expand the Broker's silent token request thread pool from 5 to 8 threads. The change is Broker-specific and leverages Android process isolation to ensure MSAL client apps remain unaffected. The expansion is controlled by the ENABLE_EXPANDED_BROKER_SILENT_THREAD_POOL flight with a default value of false.
Changes:
- Added new flight enum
ENABLE_EXPANDED_BROKER_SILENT_THREAD_POOLfor controlling thread pool expansion - Implemented
initializeSilentExecutorForBroker()andresetSilentRequestExecutorWithSize()methods to dynamically resize the silent executor based on flight state - Updated changelog to reflect the thread pool size increase
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java | Adds flight enum for enabling expanded broker silent thread pool with appropriate documentation |
| common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java | Implements broker-specific executor initialization with graceful shutdown and flight-based pool sizing logic |
| changelog.txt | Documents thread pool size increase (though entry needs more context about flight-controlled nature) |
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/flighting/CommonFlight.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
|
Just curious, how did we arrive at the number for threads allowed for silent requests as 8? Is it because we did some stress testing and confirmed that it is performing better? Or are we going to try it out in PROD directly? |
The count is based on experiment being done on client side(WXP) thread pool size. For context the flow is: So,
|
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/AuthenticationConstants.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
common/src/androidTest/java/com/microsoft/identity/common/CommandDispatcherTest.java
Outdated
Show resolved
Hide resolved
common4j/src/main/com/microsoft/identity/common/java/controllers/CommandDispatcher.java
Show resolved
Hide resolved
2. Move thread pool size merics reporting 3. Removed telemetry span reporting from initializeSilentExecutorWithExpandedPool due to lack of span during Broker boot flow.
Fixes: AB#3492151
Problem:
The Broker's silent token request thread pool (sSilentExecutor) is fixed at 5 threads. Under high load scenarios with multiple concurrent ATS requests from various client apps (Teams, Outlook, OneAuth), this can cause request queuing, increased latency, and potential timeouts.
Solution:
Introduce a flight-controlled mechanism to expand the thread pool from 5 to 8 threads, applying ONLY to the Broker module (not MSAL client apps).
Changes:
Key design decisions: