Nginx optimization for 1k-2k visitors for live stream

I have a problem when there are 1k-2k visitors to the live stream, the site does not open, it opens from the 3rd-5th page refresh. What optimizations could I do to nginx so that the site opens to more than 2k visitors?


Can you provide some PeerTube logs? Do you know what is the bottleneck? CPU? Network? Nginx? PeerTube?

The logs were not saved, the processor was used somewhere at 50%, the player worked well, network traffic 60%, I intuit that the problem is in nginx because many times it shows me bad gateway and sometimes the site opens but does not display the live streams. I moved the folder /var/www/peertube/storage/streaming-playlists to ram (tmpfs) so it’s not a problem in SSD.

Okay thanks. Unfortunately I can’t help without nginx logs and peertube logs.

I tried with wrk to simulate several accesses to get the 500 error and here are the logs:

You need to increase nginx worker connections. See What are worker_connections in Nginx

Thanks for the help, I added it manually in nginx.conf

worker_processes 16;
events {
worker_connections 1024;
use epoll;
multi_accept on;
I hope it helps, does it make sense to add the last 2 lines?

worker_connections 1024 is the nginx default on nginx mainline.

I would keep worker_processes on auto and set worker_connections to 5000-10000. You’ll need to modify the /etc/security/limits.conf accordingly.