Open vdudouyt opened 1 week ago
Limits on the number of file descriptors (fdlimit) in operating systems like Linux are often set to relatively low values by default for several reasons:
Modifying the fdlimit from within a web server at runtime is a controversial practice. Here are the pros and cons:
/etc/security/limits.conf
or through server settings (e.g., systemd).Overall, adjusting limits is a powerful tool but should be used carefully and thoughtfully.
One of the common problems I hit while running my own server software in high-load production is a shortage of fdlimit resources. A common approach to mitigate this problem is to automatically set the fdlimit before tokio::main() to a maximum value possible accordingly to sysctl settings: https://github.com/vdudouyt/std-fpm/blob/master/src/fdlimit.rs
Alternatively you can use the fdlimit crate, although I don't like it's thiserror dependency causing some proc-macro2 stuff to appear in
cargo tree
.