我想配置一個nginx作爲負載均衡器在彈性搜索羣集(版本1.3.7)之前。nginx因爲elasticsearch負載均衡性能低
我正在從3個基準服務器到集羣中的3個elasticsearch節點進行測試。 使用nginx作爲LoadBalancer我的性能下降了大約50%。
我能夠在沒有nginx的情況下在300秒內處理28K個請求,但是在300秒內只有13k個請求。 服務器是虛擬機,所以不應該是一個網絡問題,至少,物理問題。 Nginx服務器沒有高cpu負載或其資源有任何限制。
配置是非常簡單的:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
worker_rlimit_nofile 4096;
events {
worker_connections 1024;
}
和具體的ES:
server {
listen 9100;
server_name elasticsearch.site.com;
location/{
proxy_pass http://elasticsearch;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Proxy-Connection "Keep-Alive";
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log error;
}
upstream elasticsearch {
server elasticsearch1:9200;
server elasticsearch2:9200;
server elasticsearch3:9200;
keepalive 15;
}
我想知道是否有任何的方式來理解爲什麼nginx的不能提供每秒請求,或如果有任何方法可以調試這種情況。瞭解超時,保持活動連接或由nginx處理的任何其他資源將會很好。
嘗試haproxy也許?如果你特別想要某種負載平衡。 – Sobrique
如果緩衝是應用程序遇到緩慢的原因,我不會感到驚訝。需要考慮調整的兩個配置選項:[proxy_buffering](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering)和[proxy_request_buffering](http://nginx.org/en/docs/http/ ngx_http_proxy_module.html#proxy_request_buffering)。 – Anatoly