Live data from Hacker News

Ferron – A fast, memory-safe web server written in Rust

github.com

91–100 of 102 posts

Re: Ferron – A fast, memory-safe web server written in Rust

#91

Earlier quoted context omitted.

Fun experiment, try and benchmark a simple file download on a simple web server using rocket.rs (which also uses tokio and hyper, and has a built in fileserver type, so just a few lines of code) and compare it to a vanilla nginx config. Here’s the rocket.rs source I used: #[rocket::main] async fn main() -> Result { rocket::build() .mount("/", rocket::fs::FileServer::from("/tmp/test")) .ignite() .await? .launch() .awa…

Enabling lto, using codegen-units=1, and using the minimum required feature flags might improve performance a bit.

No, it won’t. Rocket is issuing 2 syscalls for every 4 kilobytes, which is what is killing the performance.

Re: Ferron – A fast, memory-safe web server written in Rust

#92

Earlier quoted context omitted.

This doesn't count because hyper doesn't support sendfile. Maybe hyper would outperform nginx in other scenarios.

Disabling sendfile in nginx makes it take 170ms instead of 150ms on my system. Because nginx knows to tune the buffer sizes properly, which goes a long way. Using strace reveals what’s happening, rocket is reading and writing to file descriptors 4 kilobytes at a time, using 2 syscalls every chunk. nginx uses far, far fewer of them. (And with sendfile enabled, only one for the whole download.) Also, there’s no reason…

> Because nginx knows to tune the buffer sizes properly, which goes a long way.

Interesting. Do you know which algorithm nginx uses to determine the proper buffer size?

Re: Ferron – A fast, memory-safe web server written in Rust

#93
post #89
post #86

Earlier quoted context omitted.

It absolute does. What do you think Arc/Rc are?

By the name i'd say Arc is reference counting, which isn't exactly garbage collection...

Reference counting is quite literally a subset of garbage collection.

Re: Ferron – A fast, memory-safe web server written in Rust

#94
post #93
post #89

Earlier quoted context omitted.

By the name i'd say Arc is reference counting, which isn't exactly garbage collection...

Reference counting is quite literally a subset of garbage collection.

Then malloc/free are quite literally a subset of the borrow checker :)

Re: Ferron – A fast, memory-safe web server written in Rust

#95
post #86

Earlier quoted context omitted.

no it doesn't

It absolute does. What do you think Arc/Rc are?

(Atomic) Reference Counted structs. They count their own references, there is no external mechanism tracking all of the reference counts at runtime. Modern rust does not include a garbage collector. You might be confusing a garbage collector with the general concept of memory management, which is a feature of (AFAIK) every high level language. Many C projects also have reference counted structs, but a reference count and a call to malloc/free doesn't quite qualify as garbage collection to most developers.

Re: Ferron – A fast, memory-safe web server written in Rust

#96
post #73

Random thing I’ve been wondering: is there a point in including TLS support in web servers any more? Isn’t it always better to run a reverse proxy and terminate HTTPs at the edge?

The web Server is the reverse proxy allowing the upstream to be plain http

Re: Ferron – A fast, memory-safe web server written in Rust

#97
post #86

Earlier quoted context omitted.

It absolute does. What do you think Arc/Rc are?

(Atomic) Reference Counted structs. They count their own references, there is no external mechanism tracking all of the reference counts at runtime. Modern rust does not include a garbage collector. You might be confusing a garbage collector with the general concept of memory management, which is a feature of (AFAIK) every high level language. Many C projects also have reference counted structs, but a reference count…

You might be confusing "garbage collector" and "garbage collection" and Rust definitely has the latter. Reference counting is also a subset of garbage collection. That is a matter of fact, not opinion. See below.

https://en.wikipedia.org/wiki/Garbage_collection_(computer_s...

Re: Ferron – A fast, memory-safe web server written in Rust

#98
post #93
post #89

Earlier quoted context omitted.

By the name i'd say Arc is reference counting, which isn't exactly garbage collection...

Reference counting is quite literally a subset of garbage collection.

Garbage Collector acts mainly in unpredictable way. I mean it is possible it won't free memory even if counter is zero already. This is not true if we are talking about Rust.

Re: Ferron – A fast, memory-safe web server written in Rust

#99
post #93

Earlier quoted context omitted.

Reference counting is quite literally a subset of garbage collection.

Garbage Collector acts mainly in unpredictable way. I mean it is possible it won't free memory even if counter is zero already. This is not true if we are talking about Rust.

https://news.ycombinator.com/item?id=43614013

Re: Ferron – A fast, memory-safe web server written in Rust

#100
post #41

Earlier quoted context omitted.

Offering more detailed timeouts for other stages of the request would be great, too. For example with HAProxy you can configure separate timeouts for just about everything. The time a request is queued (if you exceed the max connections), the time for the connection to establish, the time for the request to be recived, inactivity timeout for the client or server, inactivity timeout for websocket connections... The li…

I also implemented timeouts for response processing (including reading the request body from the client), to protect against Slow HTTP POST attacks.

Is it configurable?
Post reply on HN