An asynchronous event-driven HTTP server based on netty.
ESA HttpServer is an asynchronous event-driven http server based on netty.
<dependency>
<groupId>io.esastack</groupId>
<artifactId>httpserver</artifactId>
<version>${mvn.version}</version>
</dependency>
HttpServer.create()
.handle(req -> {
req.onData(buf -> {
// handle http content
});
req.onEnd(p -> {
req.response()
.setStatus(200)
.end("Hello ESA Http Server!".getBytes());
return p.setSuccess(null);
});
})
.listen(8080)
.awaitUninterruptibly();
HttpServerCodec
, HttpObjectAggregator
handlers directly).We used the following software for the testing:
wrk4.1.0
OS | CPU | Mem(G) | |
---|---|---|---|
server | centos:6.9-1.2.5(docker) | 4 | 8 |
client | centos:7.6-1.3.0(docker) | 16 | 3 |
-server -Xms3072m -Xmx3072m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+PrintTenuringDistribution -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:logs/gc-${appName}-%t.log -XX:NumberOfGCLogFiles=20 -XX:GCLogFileSize=480M -XX:+UseGCLogFileRotation -XX:HeapDumpPath=.
16B | 128B | 512B | 1KB | 4KB | 10KB | |
---|---|---|---|---|---|---|
Netty | 133272.34 | 132818.53 | 132390.78 | 127366.28 | 85408.7 | 49798.84 |
ESA HttpServer | 142063.99 | 139608.23 | 139646.04 | 140159.5 | 92767.53 | 53534.21 |