Skip to content

Commit 46623ab

Browse files
committed
update README for performance stats
1 parent 5ed4c8c commit 46623ab

File tree

1 file changed

+104
-5
lines changed

1 file changed

+104
-5
lines changed

README.md

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# httpserver
22

3-
An implementation of the JDK com.sun.net.httpserver.HttpServer specification with a few significant enhancements.
3+
A zero-dependency implementation of the JDK com.sun.net.httpserver.HttpServer specification with a few significant enhancements.
44

55
It adds websocket support using modified source from nanohttpd.
66

@@ -12,19 +12,21 @@ All async functionality has been removed. Most synchronized blocks were removed
1212

1313
The end result is an implementation that easily integrates with Virtual Threads available in JDK 21 - simply set a virtual thread based ExecutorService.
1414

15-
Designed for embedding only a 90kb jar.
15+
Improved performance by more than **3x** over the JDK implementation, using http pipelining, optimized String parsing, etc.
16+
17+
Designed for embedding with only a 90kb jar and zero dependencies.
1618

1719
## background
1820

19-
The JDK httpserver has no support for connection upgrades, so it is not possible to add websocket support.
21+
The JDK httpserver implementation has no support for connection upgrades, so it is not possible to add websocket support.
2022

2123
Additionally, the code still has a lot of async - e.g. using SSLEngine to provide SSL support - which makes it more difficult to understand and enhance.
2224

23-
The streams based processing offered by a thread per connection design simplifies the code substantially.
25+
The streams based processing and thread per connection design simplifies the code substantially.
2426

2527
## testing
2628

27-
Nearly all of the tests were migrated from the JDK so the current version should be highly compliant.
29+
Nearly all of the tests were included from the JDK so this version should be highly compliant and reliable.
2830

2931
## using
3032

@@ -36,6 +38,103 @@ or instantiate the server directly using [this](https://github.com/robaho/httpse
3638

3739
or the service loader will automatically find it when the jar is placed on the class path when using the standard HttpServer service provider.
3840

41+
## performance
42+
43+
This version performs more than **3x** better than the JDK version when tested using the [Tech Empower Benchmarks](https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Java/httpserver) on an identical hardware/work setup with the same JDK 21 version.<sup>1</sup> Early results with JDK-24 and the improved virtual threads scheduling shows even greater performance improvement.
44+
45+
The frameworks were also tested using [go-wrk](https://github.com/robaho/go-wrk)<sup>2</sup>
46+
47+
<sup>1</sup>_Currently working on submitting the robaho version to the Tech Empower benchmarks project for 3-party confirmation._<br>
48+
<sup>2</sup>_`go-wrk` does not use http pipelining so, the large number of connections is the limiting factor. `go-wrk` was tested using the Tech Empower server process._
49+
50+
51+
**robaho tech empower**
52+
```
53+
robertengels@macmini go-wrk % wrk -H 'Host: imac' -H 'Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 60 -c 64 --timeout 8 -t 2 http://imac:8080/plaintext -s ~/pipeline.lua -- 16
54+
Running 1m test @ http://imac:8080/plaintext
55+
2 threads and 64 connections
56+
Thread Stats Avg Stdev Max +/- Stdev
57+
Latency 658.83us 665.90us 19.01ms 16.14%
58+
Req/Sec 294.57k 28.40k 329.21k 85.67%
59+
Latency Distribution
60+
50% 0.00us
61+
75% 0.00us
62+
90% 0.00us
63+
99% 0.00us
64+
35179762 requests in 1.00m, 4.65GB read
65+
Requests/sec: 586136.93
66+
Transfer/sec: 79.38MB
67+
```
68+
69+
**jdk 21 tech empower**
70+
```
71+
robertengels@macmini go-wrk % wrk -H 'Host: imac' -H 'Accept: text/plain,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 60 -c 64 --timeout 8 -t 2 http://imac:8080/plaintext -s ~/pipeline.lua -- 16
72+
Running 1m test @ http://imac:8080/plaintext
73+
2 threads and 64 connections
74+
Thread Stats Avg Stdev Max +/- Stdev
75+
Latency 3.10ms 6.16ms 407.66ms 65.94%
76+
Req/Sec 86.84k 10.05k 119.40k 71.00%
77+
Latency Distribution
78+
50% 5.17ms
79+
75% 0.00us
80+
90% 0.00us
81+
99% 0.00us
82+
10371476 requests in 1.00m, 1.30GB read
83+
Requests/sec: 172781.10
84+
Transfer/sec: 22.24MB
85+
86+
```
87+
88+
**robaho go-wrk**
89+
```
90+
robertengels@macmini go-wrk % ./go-wrk -c=1024 -d=30 -T=100000 http://imac:8080/plaintext
91+
Running 30s test @ http://imac:8080/plaintext
92+
1024 goroutine(s) running concurrently
93+
2263637 requests in 29.998871972s, 269.85MB read
94+
Requests/sec: 75457.40
95+
Transfer/sec: 9.00MB
96+
Overall Requests/sec: 74447.26
97+
Overall Transfer/sec: 8.87MB
98+
Fastest Request: 527µs
99+
Avg Req Time: 13.57ms
100+
Slowest Request: 123.979ms
101+
Number of Errors: 0
102+
10%: 5.856ms
103+
50%: 6.873ms
104+
75%: 7.302ms
105+
99%: 7.699ms
106+
99.9%: 7.713ms
107+
99.9999%: 7.715ms
108+
99.99999%: 7.715ms
109+
stddev: 3.532ms
110+
```
111+
112+
**jdk 21 go-wrk**<sup>3</sup>
113+
```
114+
robertengels@macmini go-wrk % ./go-wrk -c=1024 -d=30 -T=100000 http://imac:8080/plaintext
115+
Running 30s test @ http://imac:8080/plaintext
116+
1024 goroutine(s) running concurrently
117+
1574549 requests in 13.563570087s, 177.19MB read
118+
Requests/sec: 116086.62
119+
Transfer/sec: 13.06MB
120+
Overall Requests/sec: 33459.36
121+
Overall Transfer/sec: 3.77MB
122+
Fastest Request: 842µs
123+
Avg Req Time: 8.82ms
124+
Slowest Request: 19.511295s
125+
Number of Errors: 739
126+
Error Counts: operation timed out=739
127+
10%: 1.597ms
128+
50%: 2.254ms
129+
75%: 2.48ms
130+
99%: 2.626ms
131+
99.9%: 2.631ms
132+
99.9999%: 2.631ms
133+
99.99999%: 2.631ms
134+
stddev: 187.376ms
135+
```
136+
<sup>3</sup>_Note the failures/timeouts when using the JDK version (which also skews the statistics a bit)._
137+
39138
## server statistics
40139

41140
The server tracks some basic statistics. To enable the access endpoint `/__stats`, set the system property `robaho.net.httpserver.EnableStatistics=true`.

0 commit comments

Comments
 (0)