设置 Web 的最大连接数

Setting up maximum of connections for web

在 JBoss7 中,我们使用此

限制了网络连接数
<connector name="https" scheme="https" protocol="HTTP/1.1" socket-binding="https" secure="true" max-connections="3000">

for urn:jboss:domain:web:1.0子系统,在wildfly中被urn:jboss:domain:undertow:1.2取代。如何在 wildfly 中设置 max-connections

我查看了文档,但没有找到匹配的属性。

谢谢

尝试在过滤器定义下添加

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

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

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

看到一个configuration example and Model Reference

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

Federico Sierra 的上述评论是正确的。但是在 Wildfly 10.x 中过滤器名称 'connection-limit' 不再存在。相反,它现在被称为 'request-limit'.

因此对于 Wildfly 10.x 在 'server' 和 'host' 上下文中的 untertow 子系统中添加过滤器引用,在 'filters' 上下文中添加请求限制过滤器:

<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

如果您想限制 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

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

"The maximum number of concurrent connections. Only values greater than 0 are allowed. For unlimited connections simply undefine this attribute value."

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

<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 解决方案...