我想配置一个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