我在两台服务映像的应用程序服务器前运行haproxy负载平衡器。 问题是,如果我使用一个或两个服务器没有在性能上有所作为(见添加的图像)。 我正在使用数字海洋作为Vps的提供者。 vps正在运行nginx和
用两台服务器加载:
加载1个服务器:
Haproxyconfiguration看起来loke这个:
global log 127.0.0.1 local0 notice maxconn 10000 user haproxy group haproxy chroot /var/lib/haproxy daemon defaults log global mode http option httplog option dontlognull contimeout 5000 clitimeout 50000 srvtimeout 50000 errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http frontend www bind 12.34.56.789:80 option http-server-close default_backend web-backend backend web-backend balance roundrobin server web-1 12.34.56.789:80 check server web-2 12.34.56.789:80 check
如果您的应用程序花费太多时间来发送响应,则在负载平衡器后面添加更多服务器将无济于事。
这是响应时间的规律 。
负载平衡器不会改善您的响应时间,因为他需要等待来自应用程序服务器的响应来为客户端服务,那时连接保持build立并等待。
您的最大响应时间是70秒左右,并有超过17000个请求超时(这是不好的)。 这是一个应用程序问题。
还要确保你的数据库可以处理这些连接数量。
More application servers = more database connections