是否有基于异步 I/O 的 AWS java 客户端?
1) 是否有使用异步 I/O 而不是线程池的 aws sdk 实现?我正在开发一个高度可扩展的 Web 服务,分析显示 CPU 浪费了大量的周期来管理进出亚马逊的网络 I/O。
2)当前客户端使用 Apache Http Client,如果我找不到异步实现 我将分叉我自己的版本来实现它。我正在考虑使用 Jetty Http 客户端。混合使用 Jetty 和 Apache 库是一种不好的形式吗?有更好的选择吗?
1) Is there an implementation of the aws sdk which uses asynchronous I/O instead of thread pools? I am working on a highly scalable web service and profiling shows that the CPU is wasting a lot of cycles managing network I/O to and from amazon.
2)The current client uses Apache Http Client, if I cannot find an asynch implementation I will fork my own version to implement it. I was thinking of using the Jetty Http Client. Is it bad form to mix Jetty and Apache libraries? Is there a better alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,没有,而且如果它已经存在的话,我会惊讶地发现它很难找到。
确实有更好的替代方案 - AWS SDK for Java 目前使用 Http Client 版本 4.x(您改为链接到旧版 3.1 版本 JavaDocs)来自 Apache HttpComponents,它方便地提供了 异步 HttpClient 以及:
正如所强调的,它应该只针对各自的用例提供便利,但是(根据您的评论)您正在向发送数千个请求AWS,这意味着开放请求往往会堆积起来,所以这可能确实有帮助。
Not that I know of, and I'd be surprised this to be difficult to find, if it would exist already.
There is a better alternative indeed - the AWS SDK for Java currently uses the Http Client version 4.x (you linked to the legacy 3.1 version JavaDocs instead) from Apache HttpComponents, which conveniently provides a Async HttpClient as well:
As emphasized, it should only be facilitated for respective uses cases, but (as per your comment) you are sending thousands of requests to AWs which means that open requests tend to pile up, so this might help indeed.
新的AWS SDK for Java 2.0 预览版是于 2017 年 6 月发布并提供此功能。
有关更多信息,请参阅
但是,请注意:
更新(2019 年 1 月)
当前版本是 2.3.0(很长一段时间没有预览)。
建议在基于 Maven 的项目中使用此 BOM:
The new AWS SDK for Java 2.0 preview was announced at June 2017 and provides this functionality.
For more information, see
However, be aware:
UPDATE (Jan. 2019)
Current version is 2.3.0 (for a long time out of preview).
Recommended is to use this BOM in maven based projects:
异步 IO 不是灵丹妙药 - 每个连接线程通常更快(吞吐量方面)并且更容易编码:
http://www.mailinator.com/tymaPaulMultithreaded.pdf
在我看来,您的限制因素是 Amazon 的 IO,而不是所有这些连接的 CPU 处理。事实上,您看到大量 CPU 时间花在轮询套接字上,这可能只是一个分析工件,因为这些调用会被阻塞。 (需要检查一下:您是否真的达到了 CPU 使用率上限?)
Asynchronous IO is not a silver bullet - thread-per-connection is usually faster (throughput-wise) and a lot easier to code:
http://www.mailinator.com/tymaPaulMultithreaded.pdf
It sounds to me like your limiting factor is the IO to Amazon, not the CPU processing of all those connections. The fact that you are seeing a lot of CPU time spent polling the sockets may just be a profiling artifact due to the fact that those calls block. (Something to check: are you actually maxing out CPU usage?)