【问题标题】:Setting up maximum of connections for web为网络设置最大连接数
【发布时间】:2015-07-01 18:47:47
【问题描述】:

在 JBoss7 中,我们使用这个限制了 Web 连接的数量

<connector name="https" scheme="https" protocol="HTTP/1.1" socket-binding="https" secure="true" max-connections="3000">

对于 urn:jboss:domain:web:1.0 子系统,它在 Wildfly 中被 urn:jboss:domain:undertow:1.2 替换。如何在wildfly中设置max-connections

我浏览了文档并没有找到匹配的属性。

谢谢

【问题讨论】:

    标签: wildfly


    【解决方案1】:

    尝试在过滤器定义下添加

    <filters>
        <connection-limit name="limit-connections" max-concurrent-requests="3000" queue-size="100"/>
    </filters>
    

    然后在主机或位置下添加(取决于您的需要)

    <filter-ref name="limit-connections"/>
    

    查看configuration exampleModel Reference

    另请参阅配置 Web 服务器池:http://www.javacodegeeks.com/2014/01/entering-undertow-web-server.html

    【讨论】:

    • 如果不添加此过滤器,默认允许的最大并发请求数是多少?
    • @CaffeineCoder 是的,我知道,但问题是 jboss7(tomcat Web 容器)不会被彻底淹没。
    • @FedericoSierra 我认为他在他的问题中要求 WIldfly-“。如何在 wildfly 中设置最大连接数?”。为了回答你对 JBoss 的问题,这个参数是未定义的,这会导致无限的连接。
    【解决方案2】:

    Federico Sierra 的上述评论是正确的。但在 Wildfly 10.x 中,过滤器名称“connection-limit”不再存在。相反,它现在称为“请求限制”。

    因此,对于 Wildfly 10.x,在“服务器”和“主机”上下文中的 untertow 子系统中添加过滤器引用,并在“过滤器”上下文中添加请求限制过滤器:

    <subsystem xmlns="urn:jboss:domain:undertow:3.1">
    [...]
      <server name="default-server">
      [...]
        <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        [...]
          <filter-ref name="limit-connections"/>
        </host>
      </server>
    [...]
      <filters>
        <response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
        <request-limit name="limit-connections" max-concurrent-requests="3000" queue-size="100"/>
      </filters>
    </subsystem>
    

    参考:https://github.com/wildfly/wildfly/blob/master/undertow/src/test/resources/org/wildfly/extension/undertow/undertow-3.1.xml

    【讨论】:

      【解决方案3】:

      如果您想限制 HTTP/HTTPS/AJP 连接器的最大并发连接数,您必须设置属性 max-connections。 示例:

      /subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-connections,value=300)
      

      来源:How to set the maximum number of Web connections in WildFly

      【讨论】:

      • 你知道最大连接数和定义过滤器的区别吗?
      【解决方案4】:

      我会使用文档中定义的max-conncections 属性。对于http 和/或https 连接。它被定义为

      "最大并发连接数。只有值更大 允许大于 0。对于无限连接只需取消定义 属性值。”

      我没有看到定义额外过滤器的好处。但也许其他人可以对此有所了解......与其他解决方案非常相似,它看起来像这样:

      <subsystem xmlns="urn:jboss:domain:undertow:10.0">
      [...]
        <server name="default-server">
          <http-listener name="default" socket-binding="http" max-connections="3000" redirect-socket="https" enable-http2="true"/>
          <https-listener name="https" socket-binding="https" max-connections="3000" security-realm="ApplicationRealm" enable-http2="true" />
        [...]       
        </server>
      [...]
      </subsystem>
      

      更新:我刚刚意识到这是 Francesco 提议的standalone.xml 解决方案...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-09-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多