Nginx : multiple download freeze my server

November 23, 2017 145 views
Nginx Ubuntu

We have a problem with Nginx. We have a converter server it's convert MP4 video to MP3 file and 300 user online, so when they start download their MP3 files at the same time, server time response become so huge like if it is freezed even if %vCPU doesn't exceeds 10% when he start the conversion using mpeg library.

My server Configuration (digitalocean)

16 vCPU.
RAM:30G
Data transfert :5TB.

Nginx Configuration (nginx.conf)

user www-data;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

worker_rlimit_nofile 20240;

events {
    worker_connections  4000;

    multi_accept on;
    use epoll;
}

http {
    include   /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  off;

    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    server_tokens off;

    client_header_timeout 10m;
    client_body_timeout 10m;
    send_timeout 10m;

    client_max_body_size 700m;
    connection_pool_size 256;
    client_body_buffer_size 1024k;
    client_header_buffer_size 8k;

    keepalive_timeout 30;
    keepalive_requests 100000;
    reset_timedout_connection on;
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

    #include /etc/nginx/conf.d/*.conf;
}

Web site nginx configuration:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html;
    index index.php index.html index.htm;

    client_max_body_size 700m;
    connection_pool_size 256;
    client_body_buffer_size 1024k;
    client_header_buffer_size 8k;


    limit_rate 125k;
    limit_req zone=one burst=5;


    # Make site accessible from http://localhost/
    server_name localhost;

    location / {

        try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

}

Do you know where the problem may come ?

1 Answer
Have another answer? Share your knowledge.