Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Both Apache Client and Netty are included in the runtime scope by default #3040

Open
axelfontaine opened this issue Feb 17, 2022 · 6 comments
Labels
documentation This is a problem with documentation. p3 This is a minor priority issue

Comments

@axelfontaine
Copy link

Describe the bug

When simply including a service, say ec2 in a Gradle build, both the Apache Client and Netty get pulled in as runtime transitive dependencies by default.

This is due to

<scope>runtime</scope>
and
<scope>runtime</scope>

This then automatically gets picked up by the Gradle application plugin and needlessly includes tons of jars in the final package.

Expected behavior

Default to a single client, preferably the plain and lightweight url-connection-client.

Current behavior

Dozens of additional jars are pulled in by default.

Steps to Reproduce

Create a new build.gradle.kts file and add the following dependency: implementation("software.amazon.awssdk:ec2:2.17.131").

Now run gradle dependencies and check the runtimeClasspath section.

Possible Solution

Only depend on url-connection-client by default.

Context

No response

AWS Java SDK version used

2.17.131

JDK version used

17.0.2

Operating System and version

Win11 x64

@axelfontaine axelfontaine added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 17, 2022
@debora-ito debora-ito self-assigned this Feb 18, 2022
@debora-ito debora-ito added feature-request A feature should be added or improved. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 18, 2022
@debora-ito
Copy link
Member

Hi @axelfontaine thank you for reaching out.

This is by design, Apache and Netty are distributed by default because they provide more robust features that support the SDK as a solution for customers of all types. With the robustness comes the jar size.

If you'd like to reduce the size of your project you can exclude both netty-nio-client and apache-client from the dependency list. We show an example of how to do this in the Developer Tools blog: Tuning the AWS Java SDK 2.x to reduce startup time. The post also have tips to reduce startup time of Lambda functions.

@debora-ito debora-ito added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Feb 18, 2022
@axelfontaine
Copy link
Author

I stand by my original comment. The default should be sensible, where in my opinion the current one isn't.

Regardless of the choice of default, configuration options as well as the current default should be documented on https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/http-configuration.html instead of random blog posts. It would also be nice if that page could include all available options and how to switch between them, as currently url-connection-client doesn't even get a mention.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Feb 23, 2022
@debora-ito
Copy link
Member

Agreed, we can definitely improve the Dev Guide around HTTP client options.

@debora-ito debora-ito added documentation This is a problem with documentation. and removed feature-request A feature should be added or improved. labels Feb 23, 2022
@debora-ito debora-ito removed their assignment Feb 23, 2022
@zoewangg
Copy link
Contributor

Hi @axelfontaine, thank you for your feedback. We should definitely improve our Dev Guide.

The reason why we include a default sync and async HTTP client in the SDK is that this way, the SDK client works out-of-box; otherwise, users would need to manually add another HTTP client dependency for sync or async client, which, we think, is a bad customer experience.

I think the choice of the HTTP client really depends on the use-case. Apache HTTP client offers better connection pooling and more features at the price of JAR size and startup time, and JDK HttpURLConnection is more lightweight with limited features. IMO in most cases, Apache HTTP client should be preferred unless startup latency or JAR size is a concern. In addition, Java SDK v1 also uses Apache HTTP client, so it seems to make sense to continue to use it as the default sync HTTP client in v2 to provide a consistent experience.

@axelfontaine
Copy link
Author

Fair enough. That's good rationale for picking the Apache HTTP client as a default. But don't bundle any additional one! If people want to switch to a different one, they can then simply follow the instructions on your soon to be updated docs page.

@erindru
Copy link

erindru commented Nov 22, 2022

Just had this exact problem.

I think the choice of the HTTP client really depends on the use-case

Indeed. Have you considered letting people decide their own use-cases for themselves?

The current approach pulls in a specific version of netty by default, which for our use-case actually caused a conflict because the rest of our code depended on a different version of netty.

Manually excluding netty-nio-client is not a great user experience because it has to be excluded from every single SDK library we use (s3, sts, sso, glue) which is quite verbose

@yasminetalby yasminetalby added the p3 This is a minor priority issue label Nov 28, 2022
aws-sdk-java-automation added a commit that referenced this issue May 21, 2024
…5713919e4

Pull request: release <- staging/17707c51-925a-4ba8-ba04-e805713919e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This is a problem with documentation. p3 This is a minor priority issue
Projects
None yet
Development

No branches or pull requests

5 participants