Skip to content

feat(aws-crt-client): add numEventLoopThreads#7171

Open
zoewangg wants to merge 1 commit into
masterfrom
zoewang/crt-num-event-loop-threads
Open

feat(aws-crt-client): add numEventLoopThreads#7171
zoewangg wants to merge 1 commit into
masterfrom
zoewang/crt-num-event-loop-threads

Conversation

@zoewangg

Copy link
Copy Markdown
Contributor

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
EventLoopGroup sized to Runtime.getRuntime().availableProcessors(), so a customer could not
size 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)) and
gives CRT users per-client IO-thread sizing and blast-radius isolation.

Modifications

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.

Testing

Added new unit tests

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue) — the two native-resource leak fixes

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds — built the affected module(s), not a full-repo mvn install
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

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.
@zoewangg
zoewangg requested a review from a team as a code owner July 20, 2026 22:59
@zoewangg zoewangg added the api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-surface-area-approved-by-team Indicate API surface area introduced by this PR has been approved by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant