Live data from Hacker News

Nxweb – Fast and Lightweight Web Server

nxweb.org

41–50 of 75 posts

Re: Nxweb – Fast and Lightweight Web Server

#41
post #17

A lot of ad-tech companies build ad-servers in C, because the latency is so crucial in that context.

Or they don't know any better. I took part in a few projects that replaced high throughput servers handling mobile network traffic from C++ to Java.

Did you have tight and consistent latency requirements?

GC pauses are a killer. They can be worked around, but it takes intensive tuning.

The RTB bidder I wrote many moons ago at a startup was fast as hell, but had problems in the 95th percentile of requests meeting the latency targets, due to GC.

The ad servers at the big ad tech heavy weights are in C++.

Re: Nxweb – Fast and Lightweight Web Server

#42
post #30

Some questions: 1) Why you think that java is slower than C++? Server-side JIT compiles much more optimized code as it is really know what and how to optimize. 2) What about security? Almost half of the problems in security in last days came from native code stuff.

> half of the problems

citation needed

> native code stuff

That is inaccurate. But if you said that it comes from C memory management issues, that sounds more plausible. We could talk about Rust, but I even think that C++ is usually written in a much safer style than C.

Re: Nxweb – Fast and Lightweight Web Server

#44
post #17

Earlier quoted context omitted.

Or they don't know any better. I took part in a few projects that replaced high throughput servers handling mobile network traffic from C++ to Java.

Did you have tight and consistent latency requirements? GC pauses are a killer. They can be worked around, but it takes intensive tuning. The RTB bidder I wrote many moons ago at a startup was fast as hell, but had problems in the 95th percentile of requests meeting the latency targets, due to GC. The ad servers at the big ad tech heavy weights are in C++.

Of course, people aren't going to be happy when they packets get dropped or the network monitoring software wasn't able to provide a (soft) real time view of what was happening.

Also note I wasn't doing this alone, it was a very big project a mobile operator.

Re: Nxweb – Fast and Lightweight Web Server

#45
post #17

Earlier quoted context omitted.

Or they don't know any better. I took part in a few projects that replaced high throughput servers handling mobile network traffic from C++ to Java.

Java is garbage unless you specific 20 -D options to bend it to your will.

I could say the same thing of compiler optimisation flags.

Re: Nxweb – Fast and Lightweight Web Server

#46
post #17

Earlier quoted context omitted.

Or they don't know any better. I took part in a few projects that replaced high throughput servers handling mobile network traffic from C++ to Java.

Or maybe THEY don't know any better way to optimize/use C++ instead of switching to Java

Given that I remember the days when C and C++ compilers generated code worse than a junior Assembly programmer, I always find such comparisons interesting.

Not that they aren't true, rather their validaty depends a lot of programmer skillset and compilers being used.

Re: Nxweb – Fast and Lightweight Web Server

#47
post #17

Earlier quoted context omitted.

Or they don't know any better. I took part in a few projects that replaced high throughput servers handling mobile network traffic from C++ to Java.

Or maybe THEY don't know any better way to optimize/use C++ instead of switching to Java

[deleted]

Re: Nxweb – Fast and Lightweight Web Server

#48
post #32

Earlier quoted context omitted.

I'd imagine encoding/decoding will be really insignificant compared to generating the requested page or fetching data from a database in most, if not all, cases

Most websites do not see more than 100 requests per second. In those cases you are correct: parsing and de-parsing is insignificant compared to the amount of energy the computer is using to heat the room. However in order to do a trillion requests per day you need around 30 machines using a custom web server, or 300 machines using Fastcgi: In this situation the cost is an order of magnitude.

Many people observe that as miles-per-gallon gets better and better, it begins to become a deceptive measurement in a way, because going from 10 to 20 mpg is a much, much larger change than going from 30 to 40, or even from 80 to 140. It seems people get a better sense of what's going on to measure gallons per mile. When you start doing that it becomes more clear that going from .0001 gallons per mile to .00001 gallons per mile, as large as it may be in orders of magnitude, still isn't that big a deal. Either way you're looking at your cost-of-fuel being effectively zero for all practical use cases, because your costs will be dominated by something else.

Similarly, I've noticed that people tend to get a little silly about web server requests-per-second. It really gets to the point you probably ought to be talking about seconds per request, or perhaps rather, microseconds per request or something.

Because A: as you start talking about these fast servers, you need to contemplate whether your code can run in, say, 2.5 microseconds either; who cares whether your webserver takes 2 or 25 microseconds to handle a minimal request if your minimal response requires 8 milliseconds (i.e. "8000 microseconds")? 8ms would actually be pretty decent performance for a wide variety of non-trivial web requests.

And B: As the webservers get faster and faster, you really need to start wondering what corners they cut to push their reqs/s number up. I can make a blazingly fast webserver that would actually kill nginx's performance stone dead for a "return a constant JSON string response" task... the trick is that I'm not even going to look at the incoming web request, I'm going to just receive a socket, blast out my answer as a constant string buffer without even reading from the socket, and discard the socket. (If you're feeling particularly saucy, hook that up to a user-space TCP stack so you can drop the work of properly setting up and tearing down TCP connections.) There aren't that many real-world tasks for which that is a good solution (though, non-zero!), but it'll look like pure awesomesauce on the benchmark!

Properly handling HTTP is non-trivial problem, and even moreso if it's going to be hooked up to a program rather than a static file system or something similarly easy. I actually start getting nervous about web servers that show excessively high numbers. If your performance is much better than nginx, rather than me cheering for joy, I actually have a lot of questions about how you did that exactly, and what my website's security profile looks like with your way-faster server. I'm not saying these questions are completely unanswerable; perhaps there is a way to safely do a much faster web server. I'm just saying that rather than my default response being celebration and "Oh wowzers cool!", my default reaction is a healthy dollop of skepticism.

Re: Nxweb – Fast and Lightweight Web Server

#49
post #35
post #28

Earlier quoted context omitted.

20k/sec is a joke performance. Java/Scala with Akka handles millions of packages per sec and this is performance.

40k/sec http requests (no pipelining) per core is about as fast as it gets unless you move TCP into user space. Reports of "millions per sec" are usually talking about messages on established channels across all CPUs. If you're actually aware of a java based web server that can beat even 150k http requests measured by wrk or similar on local host I'd like to see it.

[deleted]

Re: Nxweb – Fast and Lightweight Web Server

#50
post #48
post #32

Earlier quoted context omitted.

Most websites do not see more than 100 requests per second. In those cases you are correct: parsing and de-parsing is insignificant compared to the amount of energy the computer is using to heat the room. However in order to do a trillion requests per day you need around 30 machines using a custom web server, or 300 machines using Fastcgi: In this situation the cost is an order of magnitude.

Many people observe that as miles-per-gallon gets better and better, it begins to become a deceptive measurement in a way, because going from 10 to 20 mpg is a much, much larger change than going from 30 to 40, or even from 80 to 140. It seems people get a better sense of what's going on to measure gallons per mile. When you start doing that it becomes more clear that going from .0001 gallons per mile to .00001 gallo…

Re: gallons of gas. There's the old puzzle: your spouse gets 100MPG in that super-hybrid-mobile. The salesperson wants to upgrade you for $1000 to the super-duper-hybrid-mobile at 200MPG! Double the mileage!

You suggest instead that you get the old truck serviced and replace the plugs, distributor and tailpipe. Estimated cost $1000, and should get you from 10MPG to 11MPG. Which is the better deal? Assuming you both drive about 100 miles per week.

Post reply on HN