Hacker News new | ask | show | jobs
by norswap 3147 days ago
Can someone illuminate me on the necessity/benefits of embedding Jetty? I can never seem to understand what it offers that java.nio does not on a fundamental plumbing level (for sure, Jetty provides a lot of convenience classes on top of that plumbing), yet I see a lot of projects that could potentially get away with the plumbing embed Jetty and its thousand(s?) of minimally documented classes.
4 comments

I can never seem to understand what it offers that java.nio does not on a fundamental plumbing level (for sure, Jetty provides a lot of convenience classes on top of that plumbing)

Creating a minimalist server is an interesting excercise, everyone should do it to see how it's done imo. BUT it's the stuff like parsing http headers, query parameters, and request bodies (formencoded, chunked files?) that make a solution like Jetty worth while. Again, writing an http parser is a valuable learning experience, but your boss really doesn't want you spending time on it, OR paying to support it going forward.

As an aside, it used to be a thing in the late 90's early 2000's for every application out there to have it's own "XYZ Transport Protocol" ie XYZTP, and it really, really sucked.

And it isn't like this stuff is exactly trivial: with content transfer encodings, trailers, and exotic stuff like Expect: 100-continue, no one ever does this stuff correctly when they think they can just throw it together :/.
Makes sense. I guess I was a bit biased because I saw it used in projects that didn't need HTTP at all (can't unfortunately remember them).
> for sure, Jetty provides a lot of convenience classes on top of that plumbing

That's really the benefit. I have been using jetty for years. I trust them a lot more than I trust myself to create a web-server. If I were to write everything from scratch, I would never have finished the project.

It depends what you want to focus on: build a web server or a simple REST framework.

About a decade ago I worked on the query processor component for the Yahoo Vespa platform and I spent a month writing a web server to squeeze as much performance out of the JVM as possible. And indeed it was quite a bit faster than Jetty. Speed being a bit significant when you have a stringent latency budget.

However, I ended up deciding it wasn't really worth it. The extra millisecond or so consumed by Jetty wasn't worth the cost of having to maintain a relatively complete implementation of HTTP. So I took out my implementation and put Jetty back in.

There's also undertow, lighter and smaller memory/size footprint.
Yeah looks very good.

http://undertow.io/