feat(aws-crt-client): add numEventLoopThreads#7171
Open
zoewangg wants to merge 1 commit into
Open
Conversation
Add numEventLoopThreads(Integer) to AwsCrtAsyncHttpClient.Builder and AwsCrtHttpClient.Builder to configure the CRT event-loop (IO) thread count. When set, the client owns a private EventLoopGroup of that size and shuts it down on close; when unset, it shares the process-wide default group (behavior unchanged). Values must be greater than 1, and a value >= 4 * availableProcessors() logs a one-time WARN to flag likely-accidental oversizing (warn-only, value still honored). Also fix two native-resource leaks that could occur when client construction fails: wrap the base constructor so already-created CRT resources (including a private EventLoopGroup and its threads) are released if a later allocation throws, and reject HTTP/2 on the sync client before super() so no resources are allocated on that path. Bring aws-crt-client into the architecture-tests scope (matching the other HTTP clients) and allowlist its existing warn/error log usages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The AWS CRT HTTP clients did not expose any per-client control over the number of CRT
event-loop (IO) threads. All CRT clients in a JVM share a single, process-wide default
EventLoopGroupsized toRuntime.getRuntime().availableProcessors(), so a customer could notsize IO threads per client or isolate one client's IO from the shared group. This closes a parity
gap with the Netty client (which exposes
SdkEventLoopGroup.builder().numberOfThreads(n)) andgives CRT users per-client IO-thread sizing and blast-radius isolation.
Modifications
Add numEventLoopThreads(Integer) to
AwsCrtAsyncHttpClient.BuilderandAwsCrtHttpClient.Builderto configure the CRT event-loop (IO) thread count. When set, the client owns a private EventLoopGroup of that size and shuts it down on close; when unset, it shares the process-wide default group (behavior unchanged). Values must be greater than 1, and a value >= 4 * availableProcessors() logs a one-time WARN to flag likely-accidental oversizing (warn-only, value still honored).Also fix two native-resource leaks that could occur when client construction fails: wrap the base constructor so already-created CRT resources (including a private EventLoopGroup and its threads) are released if a later allocation throws, and reject HTTP/2 on the sync client before super() so no resources are allocated on that path.
Bring aws-crt-client into the architecture-tests scope (matching the other HTTP clients) and allowlist its existing warn/error log usages.
Testing
Added new unit tests
Types of changes
Checklist
mvn installsucceeds — built the affected module(s), not a full-repomvn installLicense