Java和Clojure開源的 HTTP 客戶端
-
JDK’s
URLConnection
uses traditional thread-blocking I/O. - Apache HTTP Client uses traditional thread-blocking I/O with thread-pools.
- Apache Async HTTP Client uses NIO.
-
Jersey is a ReST client/server framework; the client API can use several HTTP client backends including
URLConnection
and Apache HTTP Client. - OkHttp uses traditional thread-blocking I/O with thread-pools.
- Retrofit turns your HTTP API into a Java interface and can use several HTTP client backends including Apache HTTP Client.
- Grizzly is network framework with low-level HTTP support; it was using NIO but it switched to AIO .
-
Netty is a network framework with HTTP support (low-level), multi-transport, includes NIO and native (the latter uses
epoll
on Linux). - Jetty Async HTTP Client uses NIO.
- Async HTTP Client wraps either Netty, Grizzly or JDK’s HTTP support.
- clj-http wraps the Apache HTTP Client.
-
http-kit is an async subset of
clj-http
implemented partially in Java directly on top of NIO. - http async client wraps the Async HTTP Client for Java.
以下是負載測試的結果:
HTTP Client Load Test (colored is best) | Regular (thread-blocking) Apache (4.4.1) | Comsat (fiber-blocking) Apache (async 4.1) | Regular (thread-blocking) OkHttp 2.4.0 | Comsat (fiber-blocking) OkHttp 2.4.0 | Regular (thread-blocking) Jersey 2.19 w/JDK connector | Comsat (fiber-blocking) Jersey 2.19 w/JDK connector | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AHC blocking (BIO) | AHC async (NIO) + Quasar fibers | OkHttp blocking (BIO) | OkHttp async (BIO) + Quasar fibers | Jersey blocking | Jersey async + Quasar fibers | |||||||||||||||||||||
Long-lived concurrent 41k (maximum rate possible) | Max | 16715 | 41k | 16358 | 16608 | 16713 | 16713 | |||||||||||||||||||
Error | OOM - thread |