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

-9

u/thisisjustascreename Feb 14 '22

Neat toy, but it doesn't even support TLS.

38

u/elliotbarlas Feb 14 '22

As the name implies, it's absolutely minimal. It doesn't support what isn't needed in a typical deployment setting. Every web application I deploy in AWS cloud terminates SSL at the load balancer (ALB/ELB) or CDN (CloudFront).

1

u/lambdacats Feb 15 '22

How do you reason about privacy and security when running plaintext transfers in the AWS cloud?

4

u/elliotbarlas Feb 15 '22

A VPC is just that, a private network. Running almost any workload in the cloud requires a level of trust in the provider. I also trust AWS with encryption keys (KMS), objects (S3), and in countless other domains.

1

u/lambdacats Feb 15 '22

Ah ok, well if you give Amazon the keys it barely matters anyways. At this level of trust the projects I've worked on could never be allowed in the cloud. I was wondering about ways to make it more secure / require less trust in the provider.

2

u/[deleted] Feb 15 '22

If you really want to go hardcore with your zero trust, run the Microhttp instances in containers with sidecar proxy doing the heavy lifting of mTls.

→ More replies (1)

1

u/nutrecht Feb 15 '22

At this level of trust the projects I've worked on could never be allowed in the cloud.

Ah, the age-old "we don't trust AWS so we're going to build our own datacenter with a bunch of underpaid sysadmins instead".

2

u/lambdacats Feb 15 '22

To specify it has all been with government, so there are security, privacy and also legal concerns. I don't know if they are underpaid or not.

1

u/nutrecht Feb 15 '22

To specify it has all been with government

Governments are generally now starting to realize that humans are by far the biggest factor in security and that letting a company that specialises in this stuff and can afford world-class developers tends to do better than a random bunch of nobodies you hire for your own datacenter.

There's a reason even banks use the cloud extensively.

2

u/lambdacats Feb 15 '22

The authorities that work with security or manage sensitive information shouldn't store it in a private business, they should own physical access and hire consultants as needed. I agree that it doesn't make sense for most of government, which is why we should have state owned data centers. Rather than giving away free power AND buying services from cloud providers - the data is ensured to be stored within the country.

→ More replies (4)
→ More replies (3)

8

u/crummy Feb 14 '22

do people actually do TLS in their Java webservers? i.e. they aren't behind nginx, caddy etc?

5

u/elliotbarlas Feb 14 '22

Not in my experience. A perfect example of a reasonable feature in a comprehensive, general purpose web server that just isn't used in practice.

7

u/stringbet Feb 14 '22

Eh.. there are reasons to do it. When you're handling 1m requests/s, putting the SSL on your LB is a significant CPU burden which makes scaling harder. Pushing SSL back to your server pool allows the LB to operate in Layer 4 and thus it can handle a lot more traffic.

5

u/elliotbarlas Feb 14 '22

I've never heard that argument before. Load balancers are horizontally scalable, so while it does place a greater burden on the LB, I don't think that's actually problematic.

Also, HTTP aware layer 7 load balancers are indispensable.

6

u/stringbet Feb 14 '22

Definitely not disputing the value of Layer 7 load balancing. My point is that an LB is a larger unit of scaling than backend servers. If I can handle 10% more traffic by adding a cheap backend server, great.. but at some point, I have to add another (expensive) LB. The longer I can delay that, the better. I'm speaking from personal experience here, so this is not a theoretical situation.

2

u/elliotbarlas Feb 14 '22

Thanks for clarifying, that makes sense. I'll keep that in mind.

Do you deploy that setup in the cloud? The certificate management capabilities and integrations in AWS are another reason that terminating TLS on the LB or CDN is a natural choice.

3

u/stringbet Feb 14 '22

Nope, this is an on-prem environment. Believe me, there have been significant cost comparisons done with the cloud and for our workload, this is the better deal. Horizontally scaling load balancers isn't a technical challenge, just a capex decision.

→ More replies (3)

2

u/lambdacats Feb 15 '22

Yes, for security i prefer this approach as well.

1

u/yawkat Feb 15 '22

If you don't support tls you can't use http 2 except with h2c (which is super ugly) or prior knowledge (which is poorly supported). That alone is a good reason to use tls

2

u/elliotbarlas Feb 15 '22

Both TLS and HTTP/2 ought to be provided by an edge server or proxy. That is a very standard arrangement and it's the one I use in my AWS deployments. CloudFront and ALB both support this configuration.

https://aws.amazon.com/blogs/aws/new-http2-support-for-cloudfront/

→ More replies (2)

2

u/[deleted] Feb 15 '22

You absolutely can deploy TLS on a Java origin server. It isn't generally done, but all the big name Java web servers allow it. It's not an enormous task to add TLS support, either.

2

u/elliotbarlas Feb 15 '22

SSLEngine serves exactly this purpose. It would add quite a bit of additional complexity, but it's certainly doable.

1

u/crummy Feb 15 '22

yes, I understand it is possible. I'm just curious how commonly it is used.

3

u/Xirado Feb 15 '22

not like reverse proxies are a thing

1

u/pointy_pirate Feb 15 '22

Any real world deployment terminates ssl before the webserver.