Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I run nginx for few websites and for video streaming using h264 module from code-shop.com.

When I start or restart nginx it works normally for a while after it starts generating very high load because of the HIGH IO (see screenshots from top & iotop)

iotop top

I would like to point out this has nothing to do with the ffmpeg that is in TOP, because it happens no matter if ffmpeg is on or off, so while I do agree it generated a load to CPU, it does not affect the I/O that much to result in this problem.

I use i7-3770 CPU, 8 GB of RAM and SSD disk to serve websites and everything else like system and programs and 2x3TB SATA disks @ 7200k rpm in RAID 0 ONLY for the video streaming directory.

Streaming speed is about 40mB/s according to program called nmon and that is not that much so SATAs would be overloaded.

Here is a screenshot also from nmon program but about disk usage: nmon disks

  1. Why is there 100% load on HDDs at 40mB/s while I have seen it go higher without any problems and people do achieve much greater speeds with the exact setup?

  2. Why are websites not working while nginx is generating 100% load on HDDs if websites and nginx run from SSD just like database?

Here is my nginx config:

#user www-data;
user nobody;
worker_processes  6;

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

events {
        worker_connections  1024;
}
timer_resolution 100ms;
#worker_rlimit_nofile  1100;

http {
        include       mime.types;
        default_type    application/octet-stream;
        server_names_hash_bucket_size 64;
        access_log  /var/log/nginx/access.log;

        sendfile        on;
        tcp_nopush     on;

        #keepalive_timeout  0;
        keepalive_timeout  20;
        tcp_nodelay        on;

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

    #Start: DDoS Defense
        limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
        limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
        server {
            limit_conn conn_limit_per_ip 10;
            limit_req zone=req_limit_per_ip burst=10 nodelay;
        }
        #End: DDoS Defense

    #Start: Size Limits & Buffer Overflow
    client_body_buffer_size 8K;
client_header_buffer_size 1k;
client_max_body_size 2m;
large_client_header_buffers 2 1m;

        # client_body_buffer_size  1k;
        # client_header_buffer_size 1m;
        # large_client_header_buffers 2 1m;
        #END: Size Limits & Buffer Overflows

    upstream php {
        server 127.0.0.1:9000;
    }

    upstream torr {
        server 127.0.0.1:9000;
    }

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

    server_tokens off;

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

and streaming configuration:

mp4;
mp4_buffer_size     1m;
mp4_max_buffer_size 10m;

limit_rate_after 10m;
limit_rate 1m;
share|improve this question
    
The IO rate may depend on how much random your disc access is; regular HDDs can easily do 150MB/s, but only on sequential reads, dropping very significantly with random reads. SSDs are generally much better with random reads than platter-based HDDs are, but they still experience performance drops with random reads, so, 40MB/s might as well be the bottleneck of your SSD. –  cnst Mar 26 '13 at 18:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.