-
Notifications
You must be signed in to change notification settings - Fork 846
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
Java 11 HTTP Client #1447
Comments
@gabfssilva I'm want this as well and willing to contribute with you on this (if you want). |
@dagnir is going to work on getting this into a better branch for further development. I believe it's pretty far along but we definitely are open to contributions. I think the biggest time blocker is updating our release system to be able to release this on a daily basis since our release tooling is all built to use JDK8 and not JDK11. We'll figure out what state we are in to be able to release this and follow back up. |
@spfink |
@fvasco I guess the big issue is not about the implementation itself but with how's the build is going to work with the other modules. It'd be nice to isolate only the new http client module to build with Java 11. Not sure if doing it is straightforward tho. |
@gabfssilva |
Any updates on this? |
No updates at this time. |
+1 |
Since we're waiting a lot for this, today I started to work on this: https://github.com/gabfssilva/aws-spi-java-11 |
…186f497d9 Pull request: release <- staging/505221ed-0a31-4c56-93b5-090186f497d9
Hello, I'm struggling using aws sdk java v2 with OpenJ9 JDK 11. |
You shouldn't have any issue using this SDK with OpenJ9, this issue that I've created is to use the Java 11 HTTP client instead of Netty, the default client for the SDK. I've used this library with OpenJ9 without any issues whatsoever, are you seeing any errors when you run on OpenJ9 that don't happen when you run with Hotspot? What about creating a specific issue for your problem? Maybe it makes more sense, @nrbw. |
Removing the Netty dependency is a big step to reduce the deployment size of a JVM lambda (really important in a cold start). |
Sorry for the late response. |
As of SDK release 2.20.0, there is now also |
@sigpwned AWS CRT supports platform-specific JARs and you can select the right favor for your application to reduce the JAR size. https://github.com/awslabs/aws-crt-java#platform-specific-jars-experimental |
+1 |
It's 2024 now, any progress on supporting Java 11 HttpClient? Now that JDK 21 has been released, an HTTP client suitable for running in a virtual thread is more crucial than ever before. |
Is there a reason that UrlConnectionHttpClient is unsuitable for use in virtual threads? Genuinely curious. My read is that virtual threads reduce the importance of supporting the Java 11 client, not increase it. |
The UrlConnectionHttpClient is suitable for use in virtual threads; however, it lacks support for connection pools and HTTP PATCH, the latter being essential for various AWS APIs. On the other hand, the Apache HttpClient (version 4) relies on synchronization internally, which can lead to issues such as thread pinning and deadlocks. (see https://issues.apache.org/jira/projects/HTTPCORE/issues/HTTPCORE-746?filter=allissues for details.) Considering the requirements of AWS Java SDK under virtual threads, the available options are limited. |
Hi @ingram90 and anyone who would like to see this feature supported in the SDK, can you let us know what is your use-case for Java 11 HTTP client? If the use-case is reducing start up latency, we'd recommend AwsCrtHttpClient(sync) and AwsCrtAsyncHttpClient(async), which have lower startup latency compared to other HTTP clients supported in the SDK. You can see our Dev Guide for more information https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/http-configuration.html. Note that AWS CRT Java supports platform-specific JARs, so you only need to include the dependency for the platform you need instead of the uber JAR. https://github.com/awslabs/aws-crt-java#platform-specific-jars |
A big one is that the built-in client does not require large external dependencies to function. |
@SentryMan I think it makes sense, but could you go into more details? What does no external dependencies mean to you? Less maintenance efforts, smaller JAR size, or something else? |
I deploy a bunch of Java applications in lambda so keeping my application size down is a priority for me. The fact that it natively supports virtual threads is a great bonus as well. |
The primary focus at the moment revolves around virtual threads. Is the AWS CRT client capable of supporting virtual threads without pinning? I haven't found any official documentation or analyses addressing this concern. Considering that the CRT employs native methods, which inherently involve thread pinning, it is not our preferred option at the moment. We are currently in the process of assessing the compatibility of CRT with virtual threads. However, using the Java 11 Http Client seems to be a more straightforward path for us. |
Currently all AWS libraries require Netty: a large library that provides functionality already present in the Java platform. |
I took a minute yesterday and ripped the Java 11 HTTP Client implementation out of the java-11-http-client branch on this repo, lightly modernized it, and put it in a new repo at sigpwned/aws-java-sdk-v2-java-nio-client. It builds, passes tests, and generates JavaDoc, but I haven't released it because I haven't had the time to give it a proper once-over yet. I hope to add a synchronous client and do a release ASAP this week. Of course, all feedback and contributions welcome. If we can get this working, I think it will be of significant interest to the community! |
OK, I've had a minute to look things over. Here's where things stand on the updated Java client:
I'll take on the basic blocking and tackling of Continuous Integration, Maven setup, and so on over the next few days. If anyone has an interest in helping out on the above, sigpwned/aws-java-sdk-v2-java-11-client#2 breaks out all the above in more detail. Please leave comments and/or PRs with any updates. All work is appreciated, and naturally you would be added to contributors! If anyone who works/has worked on the AWS Java SDK in an official capacity can weigh in on testing best practices, it would be particularly appreciated. @zoewangg, I'm hoping you might be able to give us a little guidance on what kind of testing is expected for "official" libraries (although I fully understand that this is an unofficial library with no support or approval by Amazon implied). Mostly, I'm just trying to figure out how we can make sure this project works for everyone, and I suspect that Amazon has put some thought into that already. 😉 @Quanzzzz and @dagnir, I thought you might enjoy hearing that your project from years ago is getting some attention right now. 😄 Any thoughts or assistance you feel like contributing would be a huge asset! Also, I hope no one minds, but I've also added everyone who has contributed in the conversation in the last few years to the contributor list. Thanks to all the below for helping form the idea for this project: I'm looking forward to working with everyone to get this library ready for community consumption! |
Most excellent, I'm looking forward to it. It's unfortunate though that the official AWS SDK does not have this functionality. |
I've got a (preliminary, beta) release of the AWS Java SDK v2 Java 11 Async HTTP Client deployed to Maven Central. You can add it to your project with GAV
Also, the GitHub repo has moved to @sigpwned/aws-java-sdk-v2-java-11-client. All feedback -- even if it's just "I tried it, and it worked" -- is welcome, appreciated, and useful! Issues and PRs are even better. Here's what's left in the plan: |
@ingram90 , @sigpwned, @zoewangg Thanks for your comments! I'm particularly interested in the virtual threads use case. Deployment artifacts size aside, until an official or stable third-party Java 11 HTTP client exists, if I want to take advantage of virtual threads in production code, is there any concern with using final var client = DynamoDbAsyncClient
.builder()
.httpClientBuilder(
// See: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/http-configuration-netty.html
NettyNioAsyncHttpClient
.builder()
.maxConcurrency(/* ... */)
)
.asyncConfiguration(b -> b
.advancedOption(
// See: https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/asynchronous.html
SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR,
Executors.newVirtualThreadPerTaskExecutor()
)
)
.build();
Thread.startVirtualThread(() -> {
try {
/*
* This will complete asynchronously via Netty/CRT's internal threads (if any).
* In the case of Netty HTTP client, AWS SDK will use a virtual thread to process the
* continuation of the future returned by Netty.
*/
final var future = client.getItem(r -> r.tableName("...").key(Map.of("...", AttributeValue.fromS("..."))));
/*
* This will block the current virtual thread, releasing the carrier platform thread to do other work.
* We use `.get()` instead of `.join()` so the Virtual Thread can react to interrupts.
*/
final var response = future.get();
// TODO: do something with response
} catch (ExecutionException | InterruptedException e) {
e.printStackTrace(System.out);
}
}); A more detailed example can be found here and the results are promising. Are there any gotchas that I'm missing? |
Seems a bit off topic, but at first glance I'm not seeing anything egregious |
Apache HTTP Client is planning to support them in Despite a Java 11 HTTP Client being the ideal path (smaller deployment artifact sizes), upgrading the underlying Apache client is an alternative. |
It's a pity that developers who pay for AWS services (or work for someone who pays) have to justify the obvious benefits of using a Java 11 http client and spend time to fix Amazon's software. Using the Java 11 http client with virtual threads eliminates the need for async, on top of the other benefits already mentioned (less external dependencies bloat, smaller deployable, less security attack surface, no "jar hell", etc). AWS SDK CRT http client library has this problems:
What would be awesome is, if the Amazon team comes up with a timeline for Java AWS SDK v3 that:
It is doable! Oracle's team ditched Netty and reimplemented the Helidon 4 server with virtual threads, with spectacular performance results! |
Any updates on this issue? |
@sigpwned Perhaps if you make a PR adding your implementation they'll take it then? |
Well, I did. Nothing unexpected - does not work properly. Since AWS CRT is a native binaries with java wrappers, results are quite predictable - thread pinning on foreign function invocations and a deadlock. @debora-ito can somebody from AWS step in and answer on those issues(including this one)? This silence is getting disreputable for such a huge company. Virtual threads are being getting adopted. This is a reality - no hiding from this. Also the fact that AWS SDK still supports Java 8 - IS NOT AN EXCUSE, since we have Multi-Release JARs. Amazon DO CAN provide one jar which can use benefits of different versions of Java. As other libraries do. |
There's a branch that contains a Java 11 HTTP client implementation (
java-11-http-client
). I see it's several commits behind master.Is there any reason why this wasn't merged before? Can someone tell what's left to do? This is a really nice feature if someone doesn't want to include Netty into their app library. ;)
I ask this because I'm willing to work on it if it's possible.
The text was updated successfully, but these errors were encountered: