How to set the maximum number of Web connections in WildFly

The max-connections attribute sets the amount of concurrent connections that can be processed by an Undertow listener. You can apply to any of your available connectors.

For example, to set the maximum number of connections for the HTTP connector from WildFly / JBoss CLI execute:

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

The configuration will be updated as follows:

<server name="default-server">
      <http-listener name="default" max-connections="300" socket-binding="http" redirect-socket="https" enable-http2="true"/>
                
</server>

If your configuration supports the AJP protocol, you can set the maximum number of AJP connections as well:

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

That will be the result in your XML configuration:

<server name="default-server">
      <ajp-listener name="ajp" max-connections="300" socket-binding="ajp"/>
</server>

When you reach or exceed the maximum number of connections a message will be logged. More in detail:

  • When reaching max-connections limit:
DEBUG [org.xnio.nio.tcp.server] (default Accept) Total open connections reach high water limit (10) by this new accepting request java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:40008]
  • When exceeding max-connections limit:
DEBUG [org.xnio.nio.tcp.server] (default Accept) Exceeding connection high water limit (10). Closing this new accepting request java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:40010]

In order to enable the logging of the above messages, you have to enable DEBUG logging of org.xnio.nio.tcp.server logger:

/subsystem=logging/logger=org.xnio.nio.tcp.server:add(level=DEBUG)

In conclusion, we have covered how to set the maximum number of concurrent connections for WildFly / JBoss Web connectors and how to log messages if reaching or exceeding this number.