java - 带有 tomcat 的 HAproxy - 连接不足

标签 java spring tomcat load haproxy

我们有一个在 tomcat 7 上运行的 Web 应用程序,我们还有 haproxy 来负载平衡所有请求。 我们进行了一些负载测试,并使用模仿真实用户的 httprequests 对 haproxy(服务器)进行了下雨。

当我们试图将并发用户数增加到 200 时,一些请求收到了

503 Service Unavailable

我们尝试将 tomcat 上的最大连接数设置为 1000

当我们进入管理器应用程序以在负载测试时实时查看服务器状态时,我看到以下行:

Max threads: 1000 Current thread count: 60 Current thread busy: 35

由于某种原因当前线程不超过60,当前线程忙不超过35!

当我们删除 haproxy 并直接调用 tomcat - 它起作用了!!!(意味着不再有错误 503 并且繁忙的线程 # 根据负载增加) .

那当然是我们的haproxy配置不对

这里是:

global
    daemon
    maxconn 2000
 debug

defaults
    mode http
    timeout connect 5000ms
    timeout client 120000ms
    timeout server 120000ms


listen X-TEST 0.0.0.0:8188   
mode http
stats enable
stats uri /haproxy?stats
stats realm Strictly\ Private
stats auth xxx:xxx
stats refresh 5s
option httpclose
option forwardfor
balance roundrobin


cookie JSESSIONID prefix
server x_SERVER1 10.0.110.44:8080 cookie JSESSIONID_SERVER_1 check    
server x_SERVER2 10.0.110.45:8080 cookie JSESSIONID_SERVER_2 check

最佳答案

好的,我们重新配置了 HAproxy,它现在可以工作了, 这是新的配置文件:

global
debug

defaults
mode http
timeout connect 5s
timeout queue   300s
timeout client  300s
timeout server  300s


frontend http-in
bind *:8080
default_backend xx

backend xx
cookie JSESSIONID prefix
server xx_SERVER1 10.0.110.44:8080 cookie JSESSIONID_SERVER_1 check maxconn 500
server xx_SERVER2 10.0.110.45:8080 cookie JSESSIONID_SERVER_2 check maxconn 500
option httpclose
option forwardfor
balance roundrobin
option redispatch
retries 15


listen admin
bind *:8081
stats enable
stats refresh 1s

关于java - 带有 tomcat 的 HAproxy - 连接不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22762825/

相关文章:

tomcat - 支持tomcat上的多语言网站

java - JerseyClient webResource 的问题

java - 在野蝇关闭时使用数据源

java - Spring WS - 在 STS 中一步一步(来自 WSDL)

java - 上下文组件扫描找不到我的自定义注释 bean

tomcat - 在 Heroku 上修改 Tomcat 连接器设置

java - ACTION_SENDTO Intent 在抽屉导航 fragment 中不起作用

java - 需要将java类转换为xml吗?

java - 在 Java 中关闭流

java - Tomcat 7 更新后继续使用旧的 jsp