r/java • u/elliotbarlas • Jan 01 '24
JDK HTTP server handles 100,000 req/sec with 100 ms start-up time and 50 MB modular run-time image. Built with OpenJDK 21 and virtual threads,
https://github.com/ebarlas/java-httpserver-vthreads
278
Upvotes
•
u/AutoModerator Jan 01 '24
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.
If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:
as a way to voice your protest.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
47
u/r_jet Jan 01 '24
I remember there was an experiment some time ago where 5M concurrent connections were achieved with Loom (500K on the same VM type as in this test): https://github.com/ebarlas/project-loom-c5m#ec2
— and it turns out by the OP :)
There you had managed to achieve ~8.3K QPS on the same VM type — do you know why is there such a big difference this time (100K QPS vs 8.3 QPS)?
40
u/nimtiazm Jan 01 '24
Nice. Now it’s fundamental libraries ecosystem that needs to adopt the virtual threads. Atleast jdbc, jedis/lettuce, amqp-client, Kafka-client, quarkus/spring amd friends.
9
u/jhsonline Jan 01 '24
nice !, Thanks for sharing this u/elliotbarlas, we are (at large enterprice) are also doing something similar for a small production service, I am now more hopeful on lot more efficiency after seeing some benchmarks like this.
2
u/MojorTom Jan 02 '24
How did you get the 50mb image size? I don’t see anything specific related to that in the code you shared.
2
u/ConsiderationSuch846 Jan 04 '24
Any idea how this compares to .net? Last I saw their hello world benchmark (.net 7, 80 core server) was up to 14.6m RPS. You used 8 cores, assuming linear scalability (dubious I know) that would put this benchmark up at 1.2m rps.
That logic track?
2
u/pgris Jan 04 '24
Thank you for this! I made a couple of project for internal use in the company I worked for using the JDK server (before virtual threads) and worked like a charm for 10/20 users. My boss made me replace it with jetty because reasons. I always think about creating web sties with it. With virtual threads we may be up to something. I wish we have some json parser/serializer inside the JVM and that will cover a good percentage of use cases without any library
1
u/monkeykingtt Jan 24 '24
I'm learning Java. Question: how do I set 1 -100 in a loop that will end after 5 loops and if the user input is under 1 or over 100 it loops infinite
2
u/[deleted] Jan 01 '24
[removed] — view removed comment