負載均衡如何測試?
如題!
偶搜了一些帖子,只是簡單的不斷刷新頁面而已。
我配的nginx,後端是apache
用ab測試,結果全部集中訪問到了一台機器上了,手動刷新也無濟。
這其中有什麼訣竅嗎?
《解決方案》
雖然我長的不是很帥,但小時候也有人誇我左邊鼻孔很偶像派。
你加油吧
《解決方案》
配置文件貼上來nginx
《解決方案》
nginx默認是1:1進行均衡的,至於為何沒均衡,要看看配置文件
《解決方案》
回復 4# 南非螞蟻
見笑了,我的是測試環境
# cat /etc/nginx/nginx.conf
user nginx;
worker_processes 2;
worker_rlimit nofile 5120;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
server_tokens off;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
client_max_body_size 50m;
client_body_buffer_size 256k;
keepalive_timeout 65;
gzip on;
gzip_static on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_types text/plain application/x-javascript text/css application/xml;
proxy_hide_header Vary;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
include /etc/nginx/conf.d/*.conf;
}
# cat /etc/nginx/conf.d/default.conf
upstream test.org {
ip_hash;
server 192.168.122.10:80;
server 192.168.122.20:80;
server 192.168.122.30:80;
}
server {
listen 80;
server_name test.org alias www.test.org;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
#root /var/www/html;
index index.html index.php index.htm ;
proxy_redirect off;
proxy_pass http://test.org;
proxy_set_header host $host;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_504;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /NginxStatus {
stub_status on;
access_log on;
allow 192.168.122.0/24;
}
}
log_format test.org '$remote_addr - $remote_user [$time_local] $upstream_addr $upstream_status $request'
'"$status" $body_bytes_sent "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/test.org_access.log test.org;
《解決方案》
已解決,問題出在ip_hash上,去掉就好了,謝謝!