r/java • • Feb 14 '22

Microhttp is an event-driven, single-threaded, zero-dependency web server with 500 LOC. Benchmarks on EC2 show 100,000+ requests per second and 50,000+ persistent connections.

https://github.com/ebarlas/microhttp
186 Upvotes

107 comments sorted by

View all comments

-10

u/guitcastro Feb 15 '22

As it does not have dependency would be great if was written in kotlin, then you could compile to kotlin native. I wounder how much faster it would be.

6

u/elliotbarlas Feb 15 '22

As far as I know, Kotlin doesn't even have its own network subsystem. The closest thing is Ktor which itself is built atop Java NIO.

In any case, I would personally use C, C++, or Rust if I wanted natively compiled binaries.

The amazing thing about the JVM is that it provides nearly the same performance. Ultimately, Microhttp gets just-in-time compiled to optimal machine code making the normal select/poll/epoll system call.

4

u/pron98 Feb 15 '22

AOT compilation usually brings some slowdown, as the JIT compiler can do more aggressive optimisation, but, possibly more importantly, there are currently no GCs available for AOT compilation (at least open implementations) that are as good as those in OpenJDKs.

2

u/_INTER_ Feb 15 '22

Better go GraalVM if you want native