调整 nginx 以获得更好的性能

调整 nginx 以获得更好的性能

这个配置怎么样?有没有什么办法可以调整它,以便更快更好地处理更多点击?我有 2GB 的 RAM 和四核

user  nobody;
worker_processes  4;
error_log  /var/log/nginx/error.log debug;
worker_rlimit_nofile 32768;
events {
 worker_connections 8192; # increase for busier servers
 use epoll; # you should use epoll here for Linux kernels 2.6.x
 multi_accept on;
}
http {
 server_name_in_redirect off;
 server_names_hash_max_size 2048;
 server_names_hash_bucket_size 256;
 include    mime.types;
 default_type  application/octet-stream;
 server_tokens off;
 sendfile on;
 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout  15;
 gzip on;
 gzip_vary on;
 gzip_disable "MSIE [1-6]\.";
 gzip_proxied any;
 gzip_http_version 1.1;
 gzip_min_length  0;
 gzip_comp_level  9;
 gzip_buffers  16 8k;
 gzip_types    text/* application/* image/*;
 open_file_cache max=1000 inactive=20s;
 open_file_cache_valid    30s;
 open_file_cache_min_uses 2;
 open_file_cache_errors   off;
 if_modified_since before;
 ignore_invalid_headers on;
 client_header_timeout  1m;
 client_body_timeout 1m;
 send_timeout     1m;
 reset_timedout_connection on;
 connection_pool_size  256;
 client_header_buffer_size 256k;
 large_client_header_buffers 4 256k;
 client_max_body_size 4M;
 client_body_buffer_size 128k;
 request_pool_size  32k;
 output_buffers   4 32k;
 postpone_output  1460;
 proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=one:30m inactive=1d  max_size=500m;
 proxy_temp_path  /tmp/nginx/proxy;
 proxy_cache_key  "$scheme://$host$request_uri";
 client_body_in_file_only on;
 log_format bytes_log "$msec $bytes_sent .";

答案1

我觉得不错。你对此设置进行过压力测试吗?

相关内容