You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+104-5Lines changed: 104 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# httpserver
2
2
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.
4
4
5
5
It adds websocket support using modified source from nanohttpd.
6
6
@@ -12,19 +12,21 @@ All async functionality has been removed. Most synchronized blocks were removed
12
12
13
13
The end result is an implementation that easily integrates with Virtual Threads available in JDK 21 - simply set a virtual thread based ExecutorService.
14
14
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.
16
18
17
19
## background
18
20
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.
20
22
21
23
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.
22
24
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.
24
26
25
27
## testing
26
28
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.
28
30
29
31
## using
30
32
@@ -36,6 +38,103 @@ or instantiate the server directly using [this](https://github.com/robaho/httpse
36
38
37
39
or the service loader will automatically find it when the jar is placed on the class path when using the standard HttpServer service provider.
38
40
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._
<sup>3</sup>_Note the failures/timeouts when using the JDK version (which also skews the statistics a bit)._
137
+
39
138
## server statistics
40
139
41
140
The server tracks some basic statistics. To enable the access endpoint `/__stats`, set the system property `robaho.net.httpserver.EnableStatistics=true`.
0 commit comments