Chapter 9. Undertow subsystem tuning The non-blocking I/O (NIO) undertow subsystem introduced in JBoss EAP 7 has greatly improved performance compared to the web subsystem in JBoss EAP 6. Opportunities for tuning the undertow subsystem for your environment include: Buffer cache configuration Byte buffer pools configuration Jakarta Server Pages configuration options Listener configuration options Session attribute marshalling 9.1. Buffer cache configuration A buffer cache stores static files handled by the undertow subsystem. This includes images, static HTML, CSS, and JavaScript files. You can specify a default buffer cache for each Undertow servlet container. Having an optimized buffer cache for your servlet container can improve Undertow performance for serving static files. Buffers in a buffer cache are allocated in regions and are of a fixed size. There are three configurable attributes for each buffer cache: buffer-size The size of an individual buffer, in bytes. The default is 1024 bytes. Set the buffer size to entirely store your largest static file. buffers-per-region The number of buffers per region. The default is 1024. max-regions The maximum number of regions, which sets a maximum amount of memory allocated to the buffer cache. The default is 10 regions. You can calculate the maximum amount memory used by a buffer cache by multiplying the buffer size, the number of buffers per region, and the maximum number of regions. For example, the default buffer cache is 1024 bytes * 1024 buffers per region * 10 regions = 10 MB. Configure your buffer caches based on the size of your static files, and the results from testing expected loads in a development environment. When determining the effect on performance, consider the balance of the buffer cache performance benefit versus the memory used. 9.2. Byte buffer pools configuration Undertow byte buffer pools are used to allocate pooled NIO ByteBuffer instances. All listeners have a byte buffer pool and you can use different buffer pools and workers for each listener. Byte buffer pools can be shared between different server instances. The main byte buffer pool attribute that significantly affects performance is buffer-size . The default is calculated based on the RAM resources of your system and is sufficient in most cases. If you are configuring this attribute manually, an ideal size for most servers is 16 KB. 9.3. Jakarta Server Pages configuration options The following Jakarta Server Pages configuration options for Undertow servlet containers provide optimizations for how Jakarta Server Pages are compiled into Java bytecode: generate-strings-as-char-arrays If your Jakarta Server Pages contain a lot of String constants, enabling this option optimizes scriptlets by converting the String constants to char arrays. optimize-scriptlets If your Jakarta Server Pages contain many String concatenations, enabling this option optimizes scriptlets by removing String concatenation for every Jakarta Server Pages request. trim-spaces If your Jakarta Server Pages contain a lot of white space, enabling this option trims the white space from HTTP requests and reduces HTTP request payload. 9.3.1. Enabling Jakarta Server Pages options using the management console To enable the Undertow Jakarta Server Pages configuration options using the management console, complete the following steps: Procedure Navigate to Configuration Subsystems Web (Undertow) Servlet Container . Select the servlet container you want to configure and click View . Select Jakarta Server Pages and click Edit . For each option you want to enable, set the field to ON , and then click Save . 9.3.2. Enabling Jakarta Server Pages options using the management CLI To enable the Undertow Jakarta Server Pages configuration options using the management CLI, complete the following steps: Procedure Use the following command: For example, to enable generate-strings-as-char-arrays for the default servlet container, use the following command: 9.4. Listener configuration options Depending on your applications and environment, you can configure multiple listeners specific to certain types of traffic, for example, traffic on specific ports, and then configure options for each listener. The following are selected performance-related options that can be configured on HTTP, HTTPS, and AJP listeners. max-connections The maximum number of concurrent connections that the listener can handle. By default this attribute is undefined, which results in unlimited connections. You can use this option to set a ceiling on the number of connections a listener can handle, which might be useful to cap resource usage. In configuring this value you should consider your workload and traffic type. Also see no-request-timeout below. no-request-timeout The length of time in milliseconds that a connection is idle before it is closed. The default value is 60000 milliseconds (1 minute). Tuning this option in your environment for optimal connection efficiency can help improve network performance. If idle connections are prematurely closed, there are overheads in re-establishing connections. If idle connections are open for too long, they unnecessarily use resources. max-header-size The maximum size of an HTTP request header, in bytes. The default is 1048576 (1024KB). Limiting the header size can be useful to prevent certain types of denial of service attacks. buffer-pool Specifies the buffer pool in the io subsystem to use for the listener. By default, all listeners use the default buffer pool. You can use this option to configure each listener to use a unique buffer pool, or have multiple listeners use the same buffer pool. worker The undertow subsystem relies on the io subsystem to provide XNIO workers. This option specifies the XNIO worker that the listener uses. By default, a listener uses the default worker in the io subsystem. It might be useful to configure each listener to use a specific worker so you can assign different worker resources to certain types of network traffic. 9.4.1. Configuring listener options using the management console To configure the listener options using the management console, complete the following steps: Procedure Navigate to Configuration Subsystems Web (Undertow) Server . Select the server you want to configure and click View . In the left menu, select Listener then select the type of listener to configure, for example HTTP Listener , and select the listener in the table. CLick Edit , modify the options you want to configure, and click Save . 9.4.2. Configuring listener options using the management CLI To configure the listener options using the management CLI, complete the following steps: Procedure Use the following command: For example, to set max-connections to 100000 for the default HTTP listener in the default-server Undertow server, use the following command:

Commands:
/subsystem=undertow/servlet-container=__SERVLET_CONTAINER__/setting=jsp/:write-attribute(name=__OPTION_NAME__,value=true)
/subsystem=undertow/servlet-container=default/setting=jsp/:write-attribute(name=generate-strings-as-char-arrays,value=true)
/subsystem=undertow/server= SERVER_NAME / LISTENER_TYPE = LISTENER_NAME :write-attribute(name= OPTION_NAME ,value= OPTION_VALUE )
/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-connections,value=100000)