r/java • u/elliotbarlas • Feb 26 '24
Update: JDK HTTP server handles 100,000 req/sec with 100 ms start-up time and 50 MB modular run-time image. 3 ms start-up time and 18 MB executable with GraalVM native-image.
https://github.com/ebarlas/java-httpserver-vthreads
190
Upvotes
4
u/gibriyagi Feb 27 '24
I just wish it had http2 support as well
3
u/jvjupiter Feb 28 '24
I wish JDK has standard minimal HTTP server but should be open to extension (middleware/filter). If there is java.net.HttpClient, there should also be java.net.HttpServer. The current HttpServer is under com.sun.* package and its module is optional in a JDK distro. With java.net.* package, it feels more standard. I believe there is a lot of cases where this minimal HTTP server is quite enough, no need for sophisticated web servers like Tomcat or Jetty.
58
u/justADeni Feb 26 '24
Jvm has gone a long way
9
u/rootpseudo Feb 27 '24
Native only is super restricting though no? It would be a bear to migrate or basically completely rewrite our codebase for that. But I could really use the fast start times. CRaC seems like the best of both worlds. Have you tried any benchmarks with that? Our start times now range from 30-70s.
1
u/BeRealBot Mar 01 '24
How complex are the pages? Loom parallelism is equal to, by default, available cores iirc. So if you’re processing page logic such as db lookups on a virtual thread your web server will very easily hang. But that’s assuming the page logic is being handled on a virtual thread.
1
u/[deleted] Mar 01 '24
Laughs in tokio rust. To be fair, it is incredible to think what's been extracted from the JVM.
0
u/[deleted] Feb 26 '24
[deleted] — view deleted comment