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
+58-14Lines changed: 58 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,18 @@
1
1
## FusionAuth HTTP client and server [](https://github.com/FusionAuth/java-http/actions/workflows/test.yml)
2
2
3
-
**NOTE:** This project is in progress.
3
+
**NOTE:** This project is in progress. Version `0.3.0` is production ready, version `0.4.0` which will likely become `1.0.0` is still in development.
4
4
5
5
The goal of this project is to build a full-featured HTTP server and client in plain Java without the use of any libraries. The client and server will use Project Loom virtual threads and blocking I/O so that the Java VM will handle all the context switching between virtual threads as they block on I/O.
6
6
7
7
For more information about Project Loom and virtual threads, here is a good article to read: https://blogs.oracle.com/javamagazine/post/java-virtual-threads
8
8
9
+
## Project Goals
10
+
11
+
- Very fast
12
+
- Easy to make a simple web server like you can in Node.js
13
+
- No dependencies
14
+
- To not boil the ocean. This is a purpose built HTTP server that probably won't do everything.
15
+
9
16
## Installation
10
17
11
18
To add this library to your project, you can include this dependency in your Maven POM:
@@ -14,20 +21,20 @@ To add this library to your project, you can include this dependency in your Mav
14
21
<dependency>
15
22
<groupId>io.fusionauth</groupId>
16
23
<artifactId>java-http</artifactId>
17
-
<version>0.4.0-RC.4</version>
24
+
<version>0.4.0-RC.7</version>
18
25
</dependency>
19
26
```
20
27
21
28
If you are using Gradle, you can add this to your build file:
@@ -158,17 +165,54 @@ Then you can open `https://example.org` in a browser or call it using an HTTP cl
158
165
159
166
## Performance
160
167
161
-
A key component for this project is to have awesome performance. Here are some basic metrics using the FusionAuth load test suite against a simple application using the Prime Framework MVC. The controller does nothing except return a simple 200. Here are some simple comparisons between `Tomcat`, `Netty`, and `java-http`.
168
+
A key purpose for this project is obtain screaming performance. Here are some basic metrics using the FusionAuth load test suite against a boilerplate request handler. The request handler simply returns a `200`. Here are some simple comparisons between `apache-tomcat`, `Netty`, and `java-http`.
169
+
170
+
The load test configuration is set to `100` clients with `100,000` requests each per worker. This means the entire test will execute `10,000,000` requests. The HTTP client is [Restify](https://github.com/inversoft/restify) which is a FusionAuth library that uses `HttpURLConnection` under the hoods. This REST client is used because it is considerably faster than the native Java REST client. In a real life example, depending upon your application, this performance may not matter. For the purposes of a load test, we have attempted to remove as many limitations to pushing the server as hard as we can.
162
171
163
-
The load test configuration is set to 10 clients with 500,000 requests each. The client is Restify which is a FusionAuth library that uses `HttpURLConnection` under the hoods. All the servers were HTTP so that TLS would not introduce any additional latency.
172
+
All the servers were HTTP so that TLS would not introduce any additional latency.
164
173
165
174
Here are the current test results:
166
175
167
-
| Server | RPS | Failures per second |
168
-
|-------------|--------|---------------------|
169
-
|`java-http`| 63,216 | 0 |
170
-
|`Tomcat`| 51,351 | 0.103 |
171
-
|`Netty`| 540 | 1.818 |
176
+
| Server | Avg requests per second | Failures per second | Avg latency in ms | Normalized Performance (%) |
Note the JDK HTTP Server is `com.sun.net.httpserver.HttpServer`. I don't know that anyone would use this in production, the JDK has not yet made a version of this using a public API. It is included here for reference only.
185
+
186
+
Load test last performed May 30, 2025. Using the [fusionauth-load-test](https://github.com/fusionauth/fusionauth-load-tests) library.
187
+
188
+
### Running load tests
189
+
190
+
Start the HTTP server to test.
191
+
192
+
#### java-http
193
+
194
+
Start the HTTP server. Run the following commands from the `java-http` repo.
195
+
196
+
```bash
197
+
cd load-tests/self
198
+
sb clean start
199
+
```
200
+
201
+
#### Apache Tomcat
202
+
203
+
Start the HTTP server. Run the following commands from the `java-http` repo.
204
+
205
+
```bash
206
+
cd load-tests/tomcat
207
+
sb clean start
208
+
```
209
+
210
+
Once you have the server started you wish to test, start the load test. Run the following commands from the `fusionauth-load-tests` repo.
211
+
212
+
```bash
213
+
sb clean int
214
+
./load-test.sh HTTP.json
215
+
```
172
216
173
217
Netty and Tomcat both seem to suffer from buffering and connection issues at very high scale. Regardless of the configuration, both servers always begins to fail with connection timeout problems at scale. `java-http` does not have these issues because of the way it handles connections via the selector. Connections don't back up and client connection pools can always be re-used with Keep-Alive.
174
218
@@ -222,8 +266,8 @@ We are looking for Java developers that are interested in helping us build the c
0 commit comments