怎么感觉nginx代理反而拖累了速度呢

刘柳 发布于 2012/02/11 11:21
阅读 4K+
收藏 2

一个内部的系统,javaEE实现,tomcat6.0,服务器是双核 4G内存,大概350用户

设置的是tomcat最大内存768M。

用了nginx-1.1.10反向代理,发现速度反而被拖累了,没有直接用tomcat快(非常明显),贴出我的配置,大家帮我看看问题出在什么地方:

 
#user nobody;
worker_processes 2;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;

#cache
proxy_temp_path D:/nginx-1.1.10/temp/my;
proxy_cache_path D:/nginx-1.1.10/temp/my keys_zone=mycache:200m inactive=1d max_size=1g;



upstream backend {

server localhost:8282 weight=2;

#server localhost:8283;

ip_hash;
#add for session
#jvm_route $cookie_JSESSIONID|sessionid reverse;

}

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;


location / {
root html;
index index.html index.htm;
proxy_pass http://backend;
#newly add
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 15;
proxy_send_timeout 15;
proxy_read_timeout 15;
}
location ~* \.(gif|jpg|jpeg|png|bmp|swf|js|css)$
{

proxy_cache mycache;
proxy_cache_methods GET HEAD POST;
proxy_cache_min_uses 1;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;
proxy_cache_valid any 1m;
proxy_cache_key "$host:$server_port$uri$is_args$args";

proxy_redirect off;
proxy_pass http://backend;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

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


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

加载中
0
ValueError
ValueError
慢多少呢,用 firebug 提个具体的数据出来嘛。
0
采飞扬
采飞扬
我觉得吧,windows版本本身就不行,呵呵
0
ValueError
ValueError
lz 用的 windows 版么?
0
c
codehive

速度肯定会慢啊,多了一层代理时间啊!!!

前端加nginx/apache目标不是加快单个请求的速度,而是负载均衡加大并发吞吐量(接入loadbalance到多机),你如果稍微深入做大并发应用就不会得出这样的结论啊,

当然,nginx用linux版本是推荐的,但是这应该不是问题所在

 

蟋蟀哥哥
蟋蟀哥哥
我也估计lz用的windows
ValueError
ValueError
如果是 nginx windows 很可能真的就是问题所在……
0
刘柳
刘柳

确实是windows

其他方面的问题没有来得及查,发现很慢马上就去掉了,回头再看看

0
笨蛋敏儿
笨蛋敏儿
有没有结果啊?类似的问题求解答
返回顶部
顶部