334 points · by Avlin67 · 4y ago · 141 comments
(I was going to share that link as well...)
https://github.com/denoland/deno/blob/main/ext/http/lib.rs#L...
Ie. so that the bytes of a large image or video that is coming from an origin server and being sent to a client never has to pass through the system RAM or CPU.
I'd probably implement this as mods to the sendfile() API so that a certain number of bytes can be copied from one socket to another, with that request going all the way to the firmware of the network card which will do the actual work.
It probably needs to work with HTTP/3 UDP and encryption too - so decrypt the data from this socket and send it to that socket reencrypted with this other key and packetized to this HTTP/3 stream. The firmware would need some way to do aborts/timeouts and kick a partially complete request back to software too.
Is it complex...? Yes. But will the compute savings be worth it...? At cloudflare scale, I think the answer is yes.
https://blog.cloudflare.com/cloudflares-gen-x-servers-for-an...
https://blog.cloudflare.com/tubular-fixing-the-socket-api-wi...
With shared source, the network card vendor can even repackage some of the types of acceleration you write for their other clients - and I bet they're already looking into acceleration of HTTP/3.
It's a win-win - because cloudflare gets massive compute savings, and the network card vendor knows they've built quite a high moat to buying someone else's hardware.
https://www.nvidia.com/en-us/networking/ethernet/connectx-6-...
Last time I benchmarked io_uring, it was good enough, but I was able to get measurably faster from syscalls and a well-crafted userspace thread pool for storage to NVMe.
(Note: the I/O thread pool I wrote came out noticably faster than fio, the benchmark tool, so don't assume fio results are the best possible.)
For that reason, I have a small application which can be configured for either io_uring or the thread pool, and the thread pool is preferred for performance.
1. Cloudflare has been great at rapidly iterating (compare the timeline between HTTP/3 support in Cloudflare vs Cloudfront... let alone AWS's ALB that still doesn't support it). Introducing hardware accelerators would surely hinder those efforts (ouch, we need Y to do this that the hardware can't do, and the vendor says it'll take 1 year to have new production-ready cards).
2. Cloudflare has been a good upsteram contributor for the projects they depend on (the kernel, the rust language, etc.). Partnering with a hardware vendor inevitably means closed source, deviations from upstream and ultimately a much larger hurdle to be a good citizen to the open-source community.
As you can see, the reasons are entirely selfish. I'd understand it if you do it anyways because the numbers make sense for your company. In the meantime... thanks for holding out until you really can't justify it anymore!
No, it absolutely doesn't "automatically" mean that. You can totally request some major hardware vendors to fully upstream hardware offload capabilities in their Linux drivers.
Other firms in the same space do things that are a lot more exotic, and it is worth it for them.
What is newsworthy is that there's a new server that's validated as fine.
https://blog.cloudflare.com/boringtun-userspace-wireguard-ru...
https://blog.cloudflare.com/building-cloudflare-images-in-ru...
Jokes aside that's some serious performance boost. Wonder what it'll perform like in everyone else's prod environment.
What precedent would it set for developers when 10 years down the line, a new shiny tool would just "ditch" the result of their hard work?
I've worked with essentially every exchange in the world and I've never seen http anywhere near order entry or market data
The article is interesting and the solution great but saying it is safer because Rust is misleading. I wrote a Rust milter for Postfix incorrectly and although it didn't crash as such, it completely didn't work because data was coming into it from outside. i.e. it is still possible to write broken code in Rust.
I've personally never considered nginx unsafe either but tbh, I am not exactly an nginx guru on the cutting edge of performance or load.
Using Rust (without unsafe) precludes memory management bugs being turned into exploits. That closes an entire category of attack.
Sure, “safety” can be defined along different axes, but Rust handles one entirely. How does that not make it safer than using a memory unsafe language?
It was never compared to using a memory unsafe language. It was compared to a wildly used and battle-tested open source software.