https://github.com/esastack/esa-httpserver
An asynchronous event-driven HTTP server based on netty.
https://github.com/esastack/esa-httpserver
h2c haproxy http2 https httpserver netty
Last synced: 9 months ago
JSON representation
An asynchronous event-driven HTTP server based on netty.
- Host: GitHub
- URL: https://github.com/esastack/esa-httpserver
- Owner: esastack
- License: apache-2.0
- Created: 2020-12-03T06:54:54.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-24T08:13:49.000Z (over 3 years ago)
- Last Synced: 2025-03-23T03:11:43.492Z (9 months ago)
- Topics: h2c, haproxy, http2, https, httpserver, netty
- Language: Java
- Homepage: https://www.esastack.io
- Size: 233 KB
- Stars: 87
- Watchers: 2
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ESA HttpServer

[](https://codecov.io/gh/esastack/esa-httpserver)
[](https://maven-badges.herokuapp.com/maven-central/io.esastack/httpserver/)
[](https://github.com/esastack/esa-httpserver/blob/main/LICENSE)
ESA HttpServer is an asynchronous event-driven http server based on netty.
## Features
- Asynchronous request handing
- Http1/H2/H2cUpgrade
- Https
- HAProxy
- Epoll/NIO
- Chunked read/write
- Body aggregation
- Multipart
- Metrics
- more features...
## Maven Dependency
```xml
io.esastack
httpserver
${mvn.version}
```
## Quick Start
```java
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();
```
## Performance
### Test cases
- We built an echo server by ESA HttpServer and used a http client to do the requests for RPS testing with different bytes payload(16B, 128B, 512B, 1KB, 4KB, 10KB)
- Also we used origin netty to build a server which is same with above for RPS testing (uses the `HttpServerCodec`, `HttpObjectAggregator` handlers directly).
### Hardware Used
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 |
### JVM Options
```
-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=.
```
### Server Options
- we set the value of IO threads to 8.
### RPS
| | 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 |