nginx-rtmp-module icon indicating copy to clipboard operation
nginx-rtmp-module copied to clipboard

fix exec_* startup delay if nofile is too high

Open Jamesits opened this issue 2 years ago • 0 comments

Currently we rely on a for loop to close all possible file descriptors, and when nofile is set to a large number (a very common case in Nginx deployments), the worker process might eat up a single core for a few minutes(!) after fork and before exec. This results in unexpected server performance impacts, and causes exec_push and exec_pull to be delayed a lot (e.g. you can't do low-latency realtime transcode anymore). Others have pointed out this problem but lowering nofiles is not a long term solution.

This patch resolves the performance issue, and have been steadily runnning in my environment for a while. But it requires Linux 5.9 + glibc 2.34, or FreeBSD 8.0+. I'm not sure if we can detect the existence of close_range in configure as I'm not really familiar of Nginx's build system conventions. I'd like to refine its compatibility if possible.

Jamesits avatar Dec 27 '23 04:12 Jamesits