All Projects → esastack → esa-httpclient

esastack / esa-httpclient

Licence: Apache-2.0 license
An asynchronous event-driven HTTP client based on netty.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to esa-httpclient

Esa Restlight
ESA Restlight is a lightweight and rest-oriented web framework.
Stars: ✭ 67 (-18.29%)
Mutual labels:  asynchronous, netty, https, http2, filter, haproxy, interceptor
HAProxy-2-RPM-builder
Build latest HAProxy binary with prometheus metrics support
Stars: ✭ 28 (-65.85%)
Mutual labels:  https, http2, haproxy
Nuster
A high performance HTTP proxy cache server and RESTful NoSQL cache server based on HAProxy
Stars: ✭ 1,825 (+2125.61%)
Mutual labels:  https, http2, haproxy
Golang Tls
Simple Golang HTTPS/TLS Examples
Stars: ✭ 857 (+945.12%)
Mutual labels:  https, http2, httpclient
Haproxy
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Stars: ✭ 2,463 (+2903.66%)
Mutual labels:  https, http2, haproxy
RB-libcURL
A Realbasic and Xojo binding to libcurl
Stars: ✭ 19 (-76.83%)
Mutual labels:  https, http2
Atmosphere
Realtime Client Server Framework for the JVM, supporting WebSockets with Cross-Browser Fallbacks
Stars: ✭ 3,552 (+4231.71%)
Mutual labels:  asynchronous, netty
Vue Loadable
⏳ Improve your loading state control with pretty simple methods and helpers.
Stars: ✭ 23 (-71.95%)
Mutual labels:  asynchronous, interceptor
Halive
A fast http and https prober, to check which URLs are alive
Stars: ✭ 47 (-42.68%)
Mutual labels:  asynchronous, https
Firefly
Firefly is an asynchronous web framework for rapid development of high-performance web application.
Stars: ✭ 277 (+237.8%)
Mutual labels:  asynchronous, http2
Request.swift
A tiny HTTP client written in swift. URLSession alternative
Stars: ✭ 14 (-82.93%)
Mutual labels:  asynchronous, httpclient
Sttp
The Scala HTTP client you always wanted!
Stars: ✭ 1,078 (+1214.63%)
Mutual labels:  asynchronous, httpclient
Microwebsrv2
The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
Stars: ✭ 295 (+259.76%)
Mutual labels:  asynchronous, https
Netty Http Client
An asynchronous http client in Java, with a clean, callback-based API, using Netty 4.x
Stars: ✭ 295 (+259.76%)
Mutual labels:  asynchronous, https
Asyncro
⛵️ Beautiful Array utilities for ESnext async/await ~
Stars: ✭ 487 (+493.9%)
Mutual labels:  asynchronous, filter
Korio
Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3
Stars: ✭ 282 (+243.9%)
Mutual labels:  asynchronous, httpclient
Netty Websocket Spring Boot Starter
🚀 lightweight high-performance WebSocket framework ( 轻量级、高性能的WebSocket框架)
Stars: ✭ 885 (+979.27%)
Mutual labels:  asynchronous, netty
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (+1791.46%)
Mutual labels:  asynchronous, http2
Async Gamequery Lib
A high-performance java game query library designed for steam/source based games and others
Stars: ✭ 88 (+7.32%)
Mutual labels:  asynchronous, netty
Backoff
Python library providing function decorators for configurable backoff and retry
Stars: ✭ 1,670 (+1936.59%)
Mutual labels:  asynchronous, retry

ESA RestClient

Build codecov Maven Central GitHub license

ESA RestClient is an asynchronous event-driven http client based on netty.

Features

  • Http1/H2/H2cUpgrade
  • Https
  • Epoll/NIO
  • Serialize and Deserialize
  • Interceptor
  • Filter
  • Retry, Redirect, 100-expect-continue
  • Segmented read/write
  • Multipart
  • Metrics
  • more features...

Maven Dependency

Note:netty 4.1.52.Final and tcnative 2.0.34.Final are directly dependent on.

Note: Please make sure the version of tcnative matches the version of netty.

<dependency>
    <groupId>io.esastack</groupId>
    <artifactId>restclient</artifactId>
    <version>${esa-restclient.version}</version>
</dependency>

Quick Start

final RestClient client = RestClient.ofDefault();

final String entity = client.post("http://127.0.0.1:8081/")
                        .maxRetries(3)     //设置重试次数
                        .readTimeout(3000)      //读超时
                        .entity("Hello Server")
                        .execute()
                        .toCompletableFuture()
                        .get()
                        .bodyToEntity(String.class);

Performance

Test cases

  • We built an echo server by ESA-HTTPServer and used ESA-RestClient(1.0.0)、ESA-HttpClient(1.0.0) to do the requests for RPS testing with fixed string:'OK' and different ratio of asynchronous to synchronous requests.This is because if all requests are executed asynchronously, many requests are requesting to obtain connections, resulting in errors. Therefore, the test method is to use asynchronous and synchronous alternately to make requests, so as to achieve the best performance.
  • Also we used Apache HttpComponents(5.1.2) and OK-HttpClient(4.9.2) to build a client which is same with above for RPS testing.

Hardware Used

We used the following software for the testing:

OS CPU Mem(G)
client CentOS Linux release 7.6.1810(docker) 4 8
server CentOS Linux release 7.6.1810(docker) 8 16

JVM Options

-Xms1024m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70

Ping Result

ping_result

Client Options

Framework Options
ESA-HttpClient System.setProperty("io.esastack.httpclient.ioThreads", "4");
HttpClient.create()
  .connectTimeout(1000)
  .readTimeout(3000)
  .connectionPoolSize(connectionPoolSize)
  .connectionPoolWaitingQueueLength(512).build();
ESA-RestClient System.setProperty("io.esastack.httpclient.ioThreads", "4");
RestClient.create()
  .connectTimeout(1000)
  .readTimeout(3000)
  .connectionPoolSize(connectionPoolSize)
  .connectionPoolWaitingQueueLength(512).build();
Apache HttpComponents PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManagerBuilder.create()
  .setMaxConnTotal(connectionPoolSize)
  .setConnectionTimeToLive(TimeValue.ofMinutes(1L))
  .build();

IOReactorConfig ioReactorConfig =IOReactorConfig.custom()
  .setIoThreadCount(4)
  .build();

client = HttpAsyncClients.custom()
  .setConnectionManager(connectionManager)
  .setIOReactorConfig(ioReactorConfig)
  .setDefaultRequestConfig(RequestConfig.custom()
    .setConnectTimeout(Timeout.ofSeconds(1))
    .setResponseTimeout(Timeout.ofSeconds(3))
    .build())
  .build();
OK-HttpClient client = new OkHttpClient.Builder()
  .connectTimeout(1, TimeUnit.SECONDS)
  .readTimeout(3, TimeUnit.SECONDS)
  .build();

client.dispatcher().setMaxRequests(maxRequest);
client.dispatcher().setMaxRequestsPerHost(maxRequest);

Best RPS

ESA-HttpClient ESA-RestClient Apache HttpComponents OK-HttpClient
Best RPS 116013.75 111217.98 89633.73 70501.59
ratio of async to sync 800 800 50 300
num of io threads 4 4 4 10(MaxRequestsPerHost)
num of biz threads 1 1 10 1

See more details in Reference Doc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].