Configuring Nginx / CentOS for Multi-Page Server Content

I have a 64bit Linux machine (centos5.5), 2.83GHz Q9550, 6 GB of RAM and one SATA 500gb drive.

On this computer, I only serve thumbnails, most of which are about 10 KB in size, and currently there are about 7 million thumbnails on the server. I have a setting in the / 25/25/25/25 folder setting, which was recommended to me.

On average, the nginx status report shows that im serves 300 to 400 active connections.

Example:

Active connections: 297 
server accepts handled requests
 1975808 1975808 3457352 
Reading: 39 Writing: 8 Waiting: 250 

Now the problem is that this machine has a very difficult time and is getting slower as my site becomes more busy. The load is always from 8 to 9.

I noticed that iostat shows over 100% usage.

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.20     1.40 99.80 31.14  1221.56   255.49    11.28   114.14  831.81   7.62  99.84

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.20     0.60 100.80 24.00  1192.00   203.20    11.18   113.77  775.42   8.02 100.04

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.20   314.80 44.80 130.00   598.40  3547.20    23.72   113.76  937.18   5.72 100.02

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00     5.40 56.20 110.80   660.80   937.60     9.57   112.37  518.01   5.99 100.04

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.60    12.40 82.80 41.60  1008.00   432.00    11.58   113.66  852.51   8.04 100.04

nginx:

worker_processes  6;
worker_connections  4096;

http {
        include                 mime.types;
        default_type            application/octet-stream;
        #access_log             logs/access.log  main;
        sendfile                on;
        #tcp_nopush             on;
        keepalive_timeout       4;
        gzip                    on;
        gzip_http_version       1.1;
        gzip_vary               on;
        gzip_comp_level         2;
        gzip_proxied            any;
        gzip_types              text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
        gzip_buffers            16 8k;
}

, , RAID , , SSD, -, /, ? , , , , 300 400 nginx .

+3
2

noatime @nos, :

  • nginx, access_log off; - ; .
  • . nginx .
  • tcp_nodelay on; nginx "" .
  • tcp_nopush. , , YMMV.
  • if_modified_since before; nginx 304 Not Modified .
  • open_file_cache
  • send_timeout, nginx .

:

  • hdparam. , , hdparam tweaks .
  • socket
  • ​​ . 1000 Hertz, , , , 100-250
  • , Bluetooth.

, , Varnish nginx- nginx . "" , nginx, / .

, , - , , , .

+13

7 , ? 10 , 500 000 , 1 ( ).

, . 15- - , SSD- - .

0

Source: https://habr.com/ru/post/1788718/


All Articles