1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[HELP] Serious challenge - tuning server

Discussion in 'Server Configuration and Hosting' started by Sunka, Nov 6, 2015.

  1. Sunka

    Sunka Well-Known Member

    Original post broken into several posts because of 10.000 character limit

    My forum is still alive on old server, from which I have to move in next few days. My plan is to setup vps server I have bought on Digital Ocean, and after optimization is done, I just upload xenforo files from old server and upload database. Files are almost uploaded to new server, and database will be the last thing to import.

    Below is my server specification, Xenforo specification and all relevant .ini and .conf files on my server (Centos + nginx + Mariad Db...).

    I would be glad if you will look at all that listed data, and help me to fine tuning server for my forum. On this server will be only my forum, and nothing else. Also, from time to time, users will upload big rar-ed files to XenForo resources (50-100MB).

    Remember that I could not test configuration live yet, because my forum is still online on old server, so at this moment, benchmarking is not possible, and tuning will mostly be established with datas listed below.
    If any other data is needed, tell me and I will be posted in this thread.

    Thank you all for your effort and time, and please have a patience with me, because I am still learning Linux and all associated with that ( 3 days ago I learned how to list file data in shell).



    New VPS server (Droplet on Digital Ocean)
    • Disk Space - 60 Gb SSD
    • Ram - 4 GB
    • CPU 2
    • Swap - 2 GB
    • Linux 3.10.0-229.14.1.el7.x86_64
    • CentOS 7.1
    • Centmin Mod 1.2.3-eva2000.08 (http://centminmod.com/)
      • Nginx 1.9.6 (https / SPDY SSL / HTTP/2 SSL + ngx_pagespeed + Lua/LuaJIT support)
      • PHP-FPM 5.4.45
      • Zend OpCache 7.0.5+
      • PHP 5.6.15
      • Redis server and cache configured
      • MariaDB 10.0.22, MySQL performance fork
      • Multi-threaded compression: pigz, pbzip2, lbzip2, plzip, p7zip (optional)
      • CSF Firewall
      • Pure-FTPD Virtual FTP User support

    My XenForo forum specification
    • XenForo - 1.5.1
    • Xenforo Media gallery addon
    • Xenforo Resources addon
    • Database - 831 MB (about 126 MB zipped)
    • Number of attachments - 3,601
    • Attachments disk usage - 9,737 MB
    • Addons - 66
    • Posts - 243,337
    • Users total - 3,700 (online registered users in peak time is about 50 + guests)
    • Peak time - 40-70 registered users + 150-200 guests + robots

    .ini and .conf files

    php.ini - contain default settings I belive. I will show only relevant and valid/uncommented settings, because complete original list are too long for posting.

    php.ini (original)

    precision = 14
    output_buffering = 4096
    implicit_flush = Off
    serialize_precision = 17
    zend.enable_gc = On
    expose_php = On
    max_execution_time = 30
    max_input_time = 60
    memory_limit = 128M
    post_max_size = 8M
    default_mimetype = "text/html"
    file_uploads = On
    upload_max_filesize = 2M
    max_file_uploads = 20
    allow_url_fopen = On
    allow_url_include = Off
    default_socket_timeout = 60
    [Pdo_mysql]pdo_mysql.cache_size = 2000
    smtp_port = 25
    sql.safe_mode = Off
    mysql.cache_size = 2000
    mysql.connect_timeout = 60
    mysqli.cache_size = 2000
    mysqli.default_port = 3306


    customphp.ini - Some of php.ini default settings are overridden by customphp.ini

    Code:
    zend_extension=opcache.so
    ;opcache.error_log=/var/log/php_opcache_error.log
    opcache.enable=1
    opcache.memory_consumption=256
    opcache.interned_strings_buffer=8
    opcache.max_wasted_percentage=5
    opcache.max_accelerated_files=16000
    ; http://php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq
    ; defaults to zend opcache checking every 180 seconds for PHP file changes
    ; set to zero to check every second if you are doing alot of frequent
    ; php file edits/developer work
    ; opcache.revalidate_freq=0
    opcache.revalidate_freq=180
    opcache.fast_shutdown=1
    opcache.enable_cli=0
    opcache.save_comments=1
    opcache.enable_file_override=1
    opcache.validate_timestamps=1[root@hostname etc]# cat /etc/centminmod/php.d/zzz_customphp.ini
    date.timezone = Europe/Zagreb
    max_execution_time = 240
    upload_max_filesize = 256M
    post_max_size = 256M
    max_input_time = 120
    upload_max_filesize = 256M
    max_input_vars = 12000
    continued in post #2
     
  2. Sunka

    Sunka Well-Known Member

    my.cnf

    Code:
    [mysqld]
    local-infile=0
    ignore-db-dir=lost+found
    character-set-server=utf8
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    
    #bind-address=127.0.0.1
    # optimized my.cnf for MariaDB 5.5.x
    # by eva2000
    # vbtechsupport.com
    
    tmpdir=/home/mysqltmp
    
    innodb=ON
    #skip-federated
    #skip-pbxt
    #skip-pbxt_statistics
    #skip-archive
    #skip-name-resolve
    #old_passwords
    back_log = 512
    max_connections = 500
    key_buffer_size = 256M
    myisam_sort_buffer_size = 256M
    myisam_max_sort_file_size = 2048M
    join_buffer_size = 256K
    read_buffer_size = 256K
    sort_buffer_size = 256K
    table_definition_cache = 8192
    table_open_cache = 4096
    thread_cache_size = 256
    wait_timeout = 1800
    connect_timeout = 10
    tmp_table_size = 256M
    max_heap_table_size = 256M
    max_allowed_packet = 64M
    max_seeks_for_key = 1000
    group_concat_max_len = 1024
    max_length_for_sort_data = 1024
    net_buffer_length = 16384
    max_connect_errors = 100000
    concurrent_insert = 2
    read_rnd_buffer_size = 512K
    bulk_insert_buffer_size = 8M
    query_cache_limit = 512K
    query_cache_size = 64M
    query_cache_type = 1
    query_cache_min_res_unit = 2K
    query_prealloc_size = 262144
    query_alloc_block_size = 65536
    transaction_alloc_block_size = 8192
    transaction_prealloc_size = 4096
    default-storage-engine = InnoDB
    
    log_warnings=1
    slow_query_log=0
    long_query_time=1
    slow_query_log_file=/var/lib/mysql/slowq.log
    log-error=/var/log/mysqld.log
    
    # innodb settings
    innodb_large_prefix=1
    innodb_purge_threads=1
    innodb_file_format = Barracuda
    innodb_file_per_table = 1
    innodb_open_files = 1000
    innodb_data_file_path= ibdata1:10M:autoextend
    innodb_buffer_pool_size = 512M
    
    ## https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_buffer_pool_instances
    #innodb_buffer_pool_instances=2
    
    innodb_log_files_in_group = 2
    innodb_log_file_size = 256M
    innodb_log_buffer_size = 8M
    innodb_flush_log_at_trx_commit = 2
    innodb_thread_concurrency = 0
    innodb_lock_wait_timeout=50
    innodb_flush_method = O_DIRECT
    innodb_support_xa=1
    
    # 200 * # DISKS
    innodb_io_capacity = 300
    innodb_read_io_threads = 4
    innodb_write_io_threads = 2
    
    # mariadb settings
    [mariadb]
    #thread-handling = pool-of-threads
    #thread-pool-size= 20
    #mysql --port=3307 --protocol=tcp
    #extra-port=3307
    #extra-max-connections=1
    
    userstat = 0
    key_cache_segments = 1
    aria_group_commit = none
    aria_group_commit_interval = 0
    aria_log_file_size = 64M
    aria_log_purge_type = immediate
    aria_pagecache_buffer_size = 64M
    aria_sort_buffer_size = 64M
    
    [mariadb-5.5]
    #ignore_db_dirs=
    query_cache_strip_comments=0
    
    innodb_read_ahead = linear
    innodb_adaptive_flushing_method = estimate
    innodb_flush_neighbor_pages = 1
    innodb_stats_update_need_lock = 0
    innodb_log_block_size = 512
    
    log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
    
    [mysqld_safe]
    socket=/var/lib/mysql/mysql.sock
    log-error=/var/log/mysqld.log
    #nice = -5
    open-files-limit = 8192
    
    [mysqldump]
    quick
    max_allowed_packet = 64M
    
    [myisamchk]
    tmpdir=/home/mysqltmp
    key_buffer = 256M
    sort_buffer = 32M
    read_buffer = 32M
    write_buffer = 32M
    
    [mysqlhotcopy]
    interactive-timeout
    
    [mariadb-10.0]
    # 2 variables needed to switch from XtraDB to InnoDB plugins
    #plugin-load=ha_innodb
    #ignore_builtin_innodb
    
    ## MariaDB 10 only save and restore buffer pool pages
    ## warm up InnoDB buffer pool on server restarts
    innodb_buffer_pool_dump_at_shutdown=1
    innodb_buffer_pool_load_at_startup=1
    innodb_buffer_pool_populate=0
    ## Disabled settings
    performance_schema=OFF
    innodb_stats_on_metadata=OFF
    innodb_sort_buffer_size=2M
    innodb_online_alter_log_max_size=128M
    query_cache_strip_comments=0
    log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk

    php-fpm.conf

    Code:
    ; Log level
    ; Possible Values: alert, error, warning, notice, debug
    ; Default Value: notice
    log_level = warning
    pid = /var/run/php-fpm/php-fpm.pid
    error_log = /var/log/php-fpm/www-error.log
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m
    process_control_timeout = 10s
    ;include=/usr/local/nginx/conf/phpfpmd/*.conf
    
    [www]
    user = nginx
    group = nginx
    
    listen = 127.0.0.1:9000
    listen.allowed_clients = 127.0.0.1
    ;listen.backlog = -1
    
    ;listen = /tmp/php5-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0666
    
    pm = dynamic
    pm.max_children = 8
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 4
    pm.max_requests = 500
    
    ; PHP 5.3.9 setting
    ; The number of seconds after which an idle process will be killed.
    ; Note: Used only when pm is set to 'ondemand'
    ; Default Value: 10s
    pm.process_idle_timeout = 10s;
    
    rlimit_files = 65536
    rlimit_core = 0
    
    ; The timeout for serving a single request after which the worker process will
    ; be killed. This option should be used when the 'max_execution_time' ini option
    ; does not stop script execution for some reason. A value of '0' means 'off'.
    ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
    ; Default Value: 0
    ;request_terminate_timeout = 0
    ; Default Value: 0
    ;request_slowlog_timeout = 0
    slowlog = /var/log/php-fpm/www-slow.log
    
    pm.status_path = /phpstatus
    ping.path = /phpping
    ping.response = pong
    
    ; Limits the extensions of the main script FPM will allow to parse. This can
    ; prevent configuration mistakes on the web server side. You should only limit
    ; FPM to .php extensions to prevent malicious users to use other extensions to
    ; exectute php code.
    ; Note: set an empty value to allow all extensions.
    ; Default Value: .php
    security.limit_extensions = .php .php3 .php4 .php5
    
    ; catch_workers_output = yes
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    php_admin_value[disable_functions] = shell_exec

    nginx.conf

    Code:
    user  nginx nginx;
    worker_processes 2;
    worker_priority -10;
    
    worker_rlimit_nofile 260000;
    timer_resolution 100ms;
    
    pcre_jit on;
    
    pid  logs/nginx.pid;
    
    events {
      worker_connections  4096;
      accept_mutex on;
      accept_mutex_delay 200ms;
      use epoll;
      #multi_accept on;
    }
    
    http {
    limit_req_zone $binary_remote_addr zone=xwplogin:16m rate=40r/m;
    #limit_conn_zone $binary_remote_addr zone=xwpconlimit:16m;
    
    more_set_headers "Server: nginx centminmod";
    
    include /usr/local/nginx/conf/vts_http.conf;
    include /usr/local/nginx/conf/geoip.conf;
    include /usr/local/nginx/conf/pagespeedadmin.conf;
    include /usr/local/nginx/conf/fastcgi_param_https_map.conf;
    
    log_format  main  '$remote_addr - $remote_user [$time_local] $request '
      '"$status" $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"'
      ' "$connection" "$connection_requests" "$request_time"';
    
    access_log  logs/access.log combined buffer=128k flush=5m;
    error_log  logs/error.log warn;
    
      index  index.php index.html index.htm;
      include  mime.types;
      default_type  application/octet-stream;
      charset utf-8;
    
      sendfile on;
      sendfile_max_chunk 512k;
      tcp_nopush  on;
      tcp_nodelay on;
      server_tokens off;
      server_name_in_redirect off;
     
      keepalive_timeout  8;
      keepalive_requests 1000;
      lingering_time 20s;
      lingering_timeout 5s;
      keepalive_disable msie6;
    
      gzip on;
      gzip_vary  on;
      gzip_disable "MSIE [1-6]\.";
      gzip_static on;
      gzip_min_length  1400;
      gzip_buffers  32 8k;
      gzip_http_version 1.0;
      gzip_comp_level 5;
      gzip_proxied  any;
      gzip_types text/plain text/css text/xml application/javascript application/x-javascript application/xml application/xml+rss application/ecmascript application/json image/svg+xml;
    
    client_body_buffer_size 256k;
    client_body_in_file_only off;
    client_body_timeout 10s;
    client_header_buffer_size 64k;
    ## how long a connection has to complete sending
    ## it's headers for request to be processed
    client_header_timeout  8s;
    client_max_body_size 120m;
    connection_pool_size  512;
    directio  4m;
    ignore_invalid_headers on;  
    large_client_header_buffers 8 64k;
    output_buffers  8 256k;
    postpone_output  1460;
    proxy_temp_path  /tmp/nginx_proxy/;
    request_pool_size  32k;
    reset_timedout_connection on;
    send_timeout  15s;
    types_hash_max_size 2048;
    server_names_hash_bucket_size 64;
    
    # for nginx proxy backends to prevent redirects to backend port
    # port_in_redirect off;
    
    open_file_cache max=50000 inactive=60s;
    open_file_cache_valid 120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    open_log_file_cache max=10000 inactive=30s min_uses=2;
    
    ## limit number of concurrency connections per ip to 16
    ## add to your server {} section the next line
    ## limit_conn limit_per_ip 16;
    ## uncomment below line allows 500K sessions
    # limit_conn_log_level error;
    #######################################
    # use limit_zone for Nginx <v1.1.7 and lower
    # limit_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    # use limit_conn_zone for Nginx >v1.1.8 and higher
    # limit_conn_zone $binary_remote_addr zone=limit_per_ip:16m;
    #######################################
    
    include /usr/local/nginx/conf/conf.d/*.conf;
    }

    continued in post #3
     
  3. Sunka

    Sunka Well-Known Member

    (nginx) virtual.conf

    Code:
    server {
    #  listen  80;
      listen  80 default_server backlog=2048 reuseport;
      server_name hostname.pijanitvor.com;
      root  html;
    
      access_log  /var/log/nginx/localhost.access.log  main buffer=256k flush=5m;
      error_log  /var/log/nginx/localhost.error.log  error;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
      location /nginx_status {
      stub_status on;
      access_log  off;
      allow 127.0.0.1;
      #allow youripaddress;
      deny all;
      }
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
    #  Enables directory listings when index file not found
    #  autoindex  on;
    
    #  Shows file listing times as local time
    #  autoindex_localtime on;
    
    #  Enable for vBulletin usage WITHOUT vbSEO installed
    #  try_files  $uri $uri/ /index.php;
     
      }
    
      # example nginx-http-concat
      # /csstest/??one.css,two.css
      #location /csstest {
      #concat on;
      #concat_max_files 20;
      #}
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/include_opcache.conf;
    include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/phpstatus.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_mainserver.conf;
    
      }

    pijanitvor.com.conf

    Code:
    server {
      listen  80;
      server_name pijanitvor.com;
      return 301 $scheme://www.pijanitvor.com$request_uri;
      }
    
    server {
      server_name www.pijanitvor.com;
    
      access_log /home/nginx/domains/pijanitvor.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/pijanitvor.com/log/error.log;
    
      root /home/nginx/domains/pijanitvor.com/public;
    
      location / {
      index index.php index.html index.htm;
      try_files $uri $uri/ /index.php?$uri&$args;
      }
    
      location /internal_data/ {
      internal;
      allow 127.0.0.1;
      allow MY IP;
      deny all;
      }
    
      location /library/ {
      internal;
      allow 127.0.0.1;
      allow MY IP;
      deny all;
      }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }

    (nginx) php.conf

    Code:
    location ~ \.php$ {
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass  127.0.0.1:9000;
      #fastcgi_pass  unix:/tmp/php5-fpm.sock;
      fastcgi_index  index.php;
      #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      fastcgi_param  SCRIPT_FILENAME  $request_filename;
      #fastcgi_param PHP_ADMIN_VALUE open_basedir=$document_root/:/usr/local/lib/php/:/tmp/;
    
    # might shave 200+ ms off PHP requests
    # which don't pass on a content length header
    # slightly faster page response time at the
    # expense of throughput / scalability
    #sendfile on;
    #tcp_nopush off;
    #keepalive_requests 0;
    
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 512k;
    fastcgi_buffers 512 16k;
    fastcgi_busy_buffers_size 1m;
    fastcgi_temp_file_write_size 4m;
    fastcgi_max_temp_file_size 4m;
    fastcgi_intercept_errors on;
    
    # next 3 lines when uncommented / enabled
    # allow Nginx to handle uploads which then
    # passes back the completed upload to PHP
    #fastcgi_pass_request_body off;
    #client_body_in_file_only clean;
    #fastcgi_param  REQUEST_BODY_FILE  $request_body_file;
    
    #new .04+ map method
    fastcgi_param HTTPS $server_https;
    
    # comment out PATH_TRANSLATED line if /usr/local/lib/php.ini sets following:
    # cgi.fix_pathinfo=0
    # as of centminmod v1.2.3-eva2000.01 default is set to cgi.fix_pathinfo=1
    
    fastcgi_param  PATH_INFO  $fastcgi_path_info;
    fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
    
    fastcgi_param  QUERY_STRING  $query_string;
    fastcgi_param  REQUEST_METHOD  $request_method;
    fastcgi_param  CONTENT_TYPE  $content_type;
    fastcgi_param  CONTENT_LENGTH  $content_length;
    
    fastcgi_param  SCRIPT_NAME  $fastcgi_script_name;
    fastcgi_param  REQUEST_URI  $request_uri;
    fastcgi_param  DOCUMENT_URI  $document_uri;
    fastcgi_param  DOCUMENT_ROOT  $document_root;
    fastcgi_param  SERVER_PROTOCOL  $server_protocol;
    fastcgi_param  REQUEST_SCHEME  $scheme;
    fastcgi_param  HTTPS  $https if_not_empty;
    
    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE  nginx/$nginx_version;
    
    fastcgi_param  REMOTE_ADDR  $remote_addr;
    fastcgi_param  REMOTE_PORT  $remote_port;
    fastcgi_param  SERVER_ADDR  $server_addr;
    fastcgi_param  SERVER_PORT  $server_port;
    fastcgi_param  SERVER_NAME  $server_name;
    
    # Set php-fpm geoip variables
    fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
    fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
    fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;
    fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip_city_country_code;
    fastcgi_param GEOIP_CITY_COUNTRY_CODE3 $geoip_city_country_code3;
    fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip_city_country_name;
    fastcgi_param GEOIP_REGION $geoip_region;
    fastcgi_param GEOIP_CITY $geoip_city;
    fastcgi_param GEOIP_POSTAL_CODE $geoip_postal_code;
    fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip_city_continent_code;
    fastcgi_param GEOIP_LATITUDE $geoip_latitude;
    fastcgi_param GEOIP_LONGITUDE $geoip_longitude;
    
    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS  200;
    
      }

    zendopcache.ini

    Code:
    zend_extension=opcache.so
    ;opcache.error_log=/var/log/php_opcache_error.log
    opcache.enable=1
    opcache.memory_consumption=256
    opcache.interned_strings_buffer=8
    opcache.max_wasted_percentage=5
    opcache.max_accelerated_files=16000
    ; http://php.net/manual/en/opcache.configuration.php#ini.opcache.revalidate-freq
    ; defaults to zend opcache checking every 180 seconds for PHP file changes
    ; set to zero to check every second if you are doing alot of frequent
    ; php file edits/developer work
    ; opcache.revalidate_freq=0
    opcache.revalidate_freq=180
    opcache.fast_shutdown=1
    opcache.enable_cli=0
    opcache.save_comments=1
    opcache.enable_file_override=1
    opcache.validate_timestamps=1

    redis.conf - original .conf file, only changes are below

    Code:
    aof-rewrite-incremental-fsync yes
    maxmemory 64mb
    maxmemory-policy allkeys-lru
    maxmemory-samples 10

    (nginx) drop.conf

    Code:
    location = /robots.txt  { access_log off; log_not_found off; }
      location = /favicon.ico { access_log off; log_not_found off; expires 30d; }
      location ~ /\.  { access_log off; log_not_found off; deny all; }
      location ~ ~$  { access_log off; log_not_found off; deny all; }
      location ~ /\.git { access_log off; log_not_found off; deny all; }
      # for security see https://community.centminmod.com/posts/17234/
      location ~* \.(bak|php~|php#|php.save|php.swp|php.swo)$ { return 444; }

    (nginx) staticfiles.conf

    Code:
    # prepare for letsencrypt
      # https://community.centminmod.com/posts/17774/
      location ~ /.well-known {
      location ~ /.well-known/acme-challenge/(.*) {
      more_set_headers  "Content-Type: application/jose+json";
      }
      }
    
      location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
      gzip_static off;
      #add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      expires 30d;
      break;
      }
    
      location ~* \.(js)$ {
      #add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      expires 30d;
      break;
      }
    
      location ~* \.(css)$ {
      #add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      expires 30d;
      break;
      }
    
      location ~* \.(html|htm|txt)$ {
      #add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      expires 1d;
      break;
      }
    
      location ~* \.(eot|svg|ttf|woff|woff2)$ {
      #add_header Pragma public;
      add_header Cache-Control "public, must-revalidate, proxy-revalidate";
      access_log off;
      expires 30d;
      break;
     
    rafass likes this.
  4. Mouth

    Mouth Well-Known Member

  5. Sunka

    Sunka Well-Known Member

  6. Mouth

    Mouth Well-Known Member

    That's only 1/8th of your total RAM. With a 4Gb VPS, I'd be inclined to give MySQL 1Gb of that, thus innodb_buffer_pool_size = 1G
    ... especially if your using standard search, and not elasticsearch.
     
    Xon and Sunka like this.
  7. Marcus

    Marcus Well-Known Member

    For RAM useage:
    - 1 GB for your database
    - 1 GB for PHP "workers"
    - 500 MB for Elasticsearch
    - 64-128 MB for php opcache

    I don't think you will profit from tuning, I would run your community with standard settings and benchmark it. Then "finetune" and benchmark it again. If there are no real differences, just use the standard settings to make your life easier.
     
    Sunka likes this.
  8. Sunka

    Sunka Well-Known Member

    Is this that setting? - innodb_buffer_pool_size
    Where is that setting?
    I do not have Elasticsearch installed, yet
    Where is that setting?

    Thank you! (y)
     
  9. Xon

    Xon Well-Known Member

    Yes.


    In each php-fpm config file, add to the end:
    php_admin_value[memory_limit] = 256M
    php_value[max_execution_time] = 8

    The total number of php-fpm processes should be no more than 2-3 times your CPU core count. The execution time out thing is just to prevent silliness, but you can leave it out.
     
    Sunka and RoldanLT like this.
  10. Sunka

    Sunka Well-Known Member

    So to add this on the end of php-fpm.conf?
    Any other file?

    Like this

    php-fpm.conf
    Code:
    ; Log level
    ; Possible Values: alert, error, warning, notice, debug
    ; Default Value: notice
    log_level = warning
    pid = /var/run/php-fpm/php-fpm.pid
    error_log = /var/log/php-fpm/www-error.log
    emergency_restart_threshold = 10
    emergency_restart_interval = 1m
    process_control_timeout = 10s
    ;include=/usr/local/nginx/conf/phpfpmd/*.conf
    
    [www]
    user = nginx
    group = nginx
    
    listen = 127.0.0.1:9000
    listen.allowed_clients = 127.0.0.1
    ;listen.backlog = -1
    
    ;listen = /tmp/php5-fpm.sock
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0666
    
    pm = dynamic
    pm.max_children = 8
    ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
    pm.start_servers = 2
    pm.min_spare_servers = 1
    pm.max_spare_servers = 4
    pm.max_requests = 500
    
    ; PHP 5.3.9 setting
    ; The number of seconds after which an idle process will be killed.
    ; Note: Used only when pm is set to 'ondemand'
    ; Default Value: 10s
    pm.process_idle_timeout = 10s;
    
    rlimit_files = 65536
    rlimit_core = 0
    
    ; The timeout for serving a single request after which the worker process will
    ; be killed. This option should be used when the 'max_execution_time' ini option
    ; does not stop script execution for some reason. A value of '0' means 'off'.
    ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
    ; Default Value: 0
    ;request_terminate_timeout = 0
    ; Default Value: 0
    ;request_slowlog_timeout = 0
    slowlog = /var/log/php-fpm/www-slow.log
    
    pm.status_path = /phpstatus
    ping.path = /phpping
    ping.response = pong
    
    ; Limits the extensions of the main script FPM will allow to parse. This can
    ; prevent configuration mistakes on the web server side. You should only limit
    ; FPM to .php extensions to prevent malicious users to use other extensions to
    ; exectute php code.
    ; Note: set an empty value to allow all extensions.
    ; Default Value: .php
    security.limit_extensions = .php .php3 .php4 .php5
    
    ; catch_workers_output = yes
    php_admin_value[error_log] = /var/log/php-fpm/www-php.error.log
    php_admin_value[disable_functions] = shell_exec
    php_admin_value[memory_limit] = 256M
    php_value[max_execution_time] = 8
    

    And change in my.cnf
    from:
    Code:
    innodb_buffer_pool_size = 512M 
    to:
    Code:
    innodb_buffer_pool_size = 1024M
     
  11. Xon

    Xon Well-Known Member

    Sunka likes this.
  12. Sunka

    Sunka Well-Known Member

    Btw, @Xon I just updated [MWS] Daily Statictic addon which you have improwed.
    I am getting this error after trying to update to newest version
    Callback DailyStats_Listener::extendCountersModel is invalid (Invalid Method).
     
  13. Sunka

    Sunka Well-Known Member

    Forgetit, after I delete first redundant files, update is pass well.

    Any other suggestion for my conf and ini data? (y)
     
  14. Xon

    Xon Well-Known Member

    You've hit the most obvious tune-ables.

    This is an annoying bug. Just try to install it again.
     
    Sunka likes this.

Share This Page