Cafemmo Club
← Quay lại danh sách

Tư vấn cấu hình server đặt ảnh

command20/03/20221556 lượt xem7 bình luận
Hi, Mình có thuê 1 server riêng chỉ để phục vụ truy cập hình ảnh, mình mua server CPU ko cao, chủ yếu HDD nhiều (32TB) để chứa hình ảnh. Các thông tin của server này: - CPU: AMD Ryzen™ 5 3600 6-Core - RAM: 64 GB DDR4 ECC - HDD: 2 x 16 TB SATA Enterprise Hard Drive - Server này chỉ cài đặt nginx và CPU load average 0.2-0.3, RAM chỉ chiếm 500MB/62GB. - Uptime của server: hơn 100 ngày. - HDD: đã sử dụng hơn 55% - Trong file log error của nginx thì ko thấy dòng lỗi nào trong 1 tháng qua. Tuy nhiên, sau 1 tháng quan sát Cloudflare (bản Pro) thì thấy có nhiều error (dù xác xuất errors so với thành công thấp nhưng mình hy vọng các bác giúp để tối ưu hơn) như hình: - 522 Origin Connection Time-out - 500 Internal Server Error - 521 Origin Down - 524 Origin Time-out limits của 1 nginx process:
cat /proc/804218/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             256741               256741               processes
Max open files            70000                70000                files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       256741               256741               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0            
Max realtime priority     0                    0            
Max realtime timeout      unlimited            unlimited            us 
Cấu hình server này chỉ cài nginx và có thông số cấu hình như sau: - nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 1024;
    # multi_accept on;
}

http {
    # Custom log_format
    log_format custom '[$time_local] $http_cf_connecting_ip - $http_cf_ipcountry - $remote_addr - $remote_user "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_id';

    ##
    # 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 TLSv1.3; # 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_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    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/*;
}
File cấu hình của site trong folder site-enabled:
server {
    listen 80;
    root /home/user/domain.com;
    index index.html index.htm;
    server_name domain.com;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~*  \\.(jpg|jpeg|png|gif|ico|css|js|pdf|woff2|svg|webp)$ {
                expires 90d;
        }

        location ~ /\\.ht {
        deny all;
    }

    error_log /var/log/nginx/domain.com_error.log;
    access_log /var/log/nginx/domain.com_access.log custom;

}
Mong các bác chuẩn đoán "bệnh" giúp để tối ưu server chứa hình ảnh. Xin cám ơn,

Bình luận

Đang tải...

Đang kiểm tra đăng nhập...

Tư vấn cấu hình server đặt ảnh · Cafemmo Club