简体   繁体   English

支持流水线的基于 Java 的 HTTP 客户端

[英]Java based HTTP Client which supports Pipelining

您知道任何支持 HTTP/1.1 ( http://en.wikipedia.org/wiki/HTTP_pipelining ) 的 HTTP 流水线选项的免费 Java 库吗?

I don't think you will find any common ones supporting pipe-lining.我不认为你会发现任何支持管道衬里的常见的。 Jetty HttpClient seems to support it from document but I couldn't make it to do it. Jetty HttpClient 似乎从文档中支持它,但我无法做到。

Please note that Pipeline is different from keep-alive.请注意,Pipeline 与 keep-alive 不同。 Keep-alive just means reuse the connection but it may still send only one request at a time over the connection.保持活动只是意味着重用连接,但它仍然可能一次只通过连接发送一个请求。 With pipe-lining, you can send several requests at the same time over the same connection and wait for their respective responses.使用流水线,您可以通过同一个连接同时发送多个请求并等待它们各自的响应。

HTTPClient apparently supports pipelining here: HTTPClient 显然支持这里的流水线:

http://www.innovation.ch/java/HTTPClient/ http://www.innovation.ch/java/HTTPClient/

but I haven't tried it personally and can't verify this.但我没有亲自尝试过,无法验证这一点。

hotpotato will support pipelining really soon. hotpotato将支持真的很快流水线。 Performance-wise, it's way superior to Apache's HTTP Client, especially in high concurrency environments (multiple threads using the same instance of the client).在性能方面,它优于 Apache 的 HTTP 客户端,尤其是在高并发环境中(多个线程使用同一客户端实例)。

I still need to publish the results but on a LAN test, I'm getting ~7000req/s (hotpotato) vs ~100req/s (apache's).我仍然需要发布结果,但是在 LAN 测试中,我得到了 ~7000req/s(hotpotato)与 ~100req/s(apache 的)。 Of course, a great deal of the merit must go to Netty, the amazing framework hotpotato is built upon ;)当然,很多优点必须归功于 Netty,令人惊叹的框架 hotpotato 建立在 ;)

If you don't need a fancy full-fledged client, take a look here for a simpler version.如果您不需要花哨的成熟客户端,请查看此处以获取更简单的版本。

I realize my answer is about a year old, but as this is one of the top links for "java http pipelining", I thought it was relevant.我意识到我的答案大约有一年了,但由于这是“java http 流水线”的顶级链接之一,我认为它是相关的。

Hotpotato does indeed now support pipelining, and in my limited experience it's been working great so far. Hotpotato 现在确实支持流水线操作,根据我有限的经验,到目前为止它运行良好。 Also has a nice API to boot.还有一个很好的 API 来启动。

http://hotpotato.biasedbit.com/ http://hotpotato.biasedbit.com/

EDIT: Looks like this project is now unmaintained and the author recommends the Async HTTP client: https://github.com/ning/async-http-client/编辑:看起来这个项目现在没有维护,作者推荐异步 HTTP 客户端: https : //github.com/ning/async-http-client/

Apache HttpComponents Core 5 supports HTTP/1.1 pipelining. Apache HttpComponents Core 5支持 HTTP/1.1 流水线。 The example could be found here .这个例子可以在这里找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM