我们的生产服务器有Ubuntu 9.x, 内存8GB,HDD 250Gb使用nginx作为webserver。 我们目前在高峰时段遇到性能问题(1000次/秒) 我希望服务器可以服务1000个请求/秒,有人可以告诉我应该在nginx配置上更改什么。感谢
这里是nginx conf
#user nobody;
worker_processes 8;
events {
worker_connections 8024;
}
http {
passenger_root /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/passenger-3.0.9;
passenger_ruby /opt/ruby-enterprise-1.8.7-2009.10/bin/ruby;
passenger_pool_idle_time 0;
passenger_max_pool_size 15;
include mime.types;
default_type application/octet-stream;
sendfile on;
## General options
#ignore_invalid_headers on;
keepalive_requests 2000;
#recursive_error_pages on;
#server_name_in_redirect off;
#server_tokens off;
## TCP options
tcp_nodelay on;
tcp_nopush on;
## Timeouts
client_body_timeout 10;
client_header_timeout 10;
keepalive_timeout 65;
#send_timeout 10;
#expires 24h;
gzip on;
server {
listen 80;
server_name resumecompanion.com;
passenger_enabled on;
rails_env production;
root /var/www/resumecompanion.com/production/current/public;
#access_log off;
#error_log off;
## Redirect from www to non-www
if ($host = 'www.resumecompanion.com' ) {
rewrite ^/(.*)$ http://resumecompanion.com/$1 permanent;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
# HTTPS server
#
server {
listen 443;
server_name resumecompanion.com;
passenger_enabled on;
rails_env production;
ssl on;
ssl_certificate /opt/nginx/ssl/resumecompanion.com.crt;
ssl_certificate_key /opt/nginx/ssl/start_resumecompanion_com.key;
ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
root /var/www/resumecompanion.com/production/current/public;
}
}
答案 0 :(得分:3)
如果不分析系统,很难说...你必须首先找到大部分时间花在请求上的地方。它不常见的是ngingx或apache是问题的原因。
考虑到你发布了一个ruby-on-rails标签,我想你在nginx后面有一个rails应用程序...更有可能是rails应用程序导致问题。我要检查的第一件事是数据库查询。检查日志以查找慢查询并尝试找到一种方法使它们更快...索引始终是一个很好的开始....
如果你找不到任何东西,可以尝试使用工具作为新的遗物,找到你的性能问题......