K
K
kr_ilya2019-05-06 18:44:15
Nginx
kr_ilya, 2019-05-06 18:44:15

How to optimize nginx on a weak server?

There is such a server:
5cd0559f61983470784509.png
I tested under load 50 users, here are the results:
At the beginning
5cd050aa9423d984247161.jpeg
Peak load that I noticed:
5cd050ceeacda825293270.jpeg
Graph:
5cd0513cf1b20473730977.jpeg
I think that nginx, even on such a server, but for 50 people eats too much processor resources. How to optimize? What normal load on nginx should be expected on such a server?
nginx config:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
# worker_processes 8;
events {
  worker_connections 768;
  # multi_accept on;
}

http {

  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  # server_tokens off;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

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

  ##
  # SSL Settings
  ##

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_buffers 16 8k;
  gzip_comp_level 6;
    gzip_min_length 100;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # Virtual Host Configs
  ##

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

UPD: On the server, there is a light site on vue (production version, files are located in the var/www/html/ directory), after loading which an axois request is sent to the node js server, which hangs on port 3000 of the same server (located in root/server/ ) (I think node has no effect).
Here is another config:
server {
  listen 80 default_server;
  listen [::]:80 default_server;

  # SSL configuration
  #
  # listen 443 ssl default_server;
  # listen [::]:443 ssl default_server;
  #
  # Note: You should disable gzip for SSL traffic.
  # See: https://bugs.debian.org/773332
  #
  # Read up on ssl_ciphers to ensure a secure configuration.
  # See: https://bugs.debian.org/765782
  #
  # Self signed certs generated by the ssl-cert package
  # Don't use them in a production server!
  #
  # include snippets/snakeoil.conf;

  root /var/www/html;

  # Add index.php to the list if you are using PHP
  index index.html index.htm index.nginx-debian.html;

  server_name _;

  location / {
 	 try_files $uri $uri/ /index.html;
  }

  location ~* ^.+\.(rss|atom|jpg|jpeg|gif|png|ico|rtf|js|css|woff|woff2)$ {
    expires 365d;
  }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  #location ~ \.php$ {
  #	include snippets/fastcgi-php.conf;
  #
  #	# With php7.0-cgi alone:
  #	fastcgi_pass 127.0.0.1:9000;
  #	# With php7.0-fpm:
  #	fastcgi_pass unix:/run/php/php7.0-fpm.sock;
  #}

  # deny access to .htaccess files, if Apache's document root
  # concurs with nginx's one
  #
  #location ~ /\.ht {
  #	deny all;
  #}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2019-05-06
@ky0

It is not nginx that needs to be optimized, there are more than resources for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question