Chapter 9. Undertow Subsystem Tuning
The non-blocking I/O
undertow subsystem introduced in JBoss EAP 7 has greatly improved performance compared to the previous
web subsystem in JBoss EAP 6. Opportunities for tuning the
undertow subsystem for your environment include configuring buffer caches, JSP settings, and listeners.
9.1. Buffer Caches
A buffer cache is used to cache static files handled by the
Buffers in a buffer cache are allocated in regions, and are of a fixed size. There are three configurable attributes for each buffer cache:
- The size of an individual buffer, in bytes. The default is 1024 bytes. Red Hat recommends that you set the buffer size to entirely store your largest static file.
- The number of buffers per region. The default is 1024.
- 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 = 10MB.
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.
For instructions on using the management CLI to configure buffer caches, see Configuring Buffer Caches in the JBoss EAP Configuration Guide.
9.2. Configuring Byte Buffer Pools
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.
For a full list of the attributes available for configuring byte buffer pools, see Byte Buffer Pool Attributes in the JBoss EAP Configuration Guide.
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 16KB.
See the JBoss EAP Configuration Guide for instructions on how to create and configure byte buffer pools.
9.3. JSP Configuration
There are JSP configuration options for Undertow servlet containers that provide optimizations for how JSP pages are compiled into Java bytecode.
If your JSPs contain a lot of
Stringconstants, enabling this option optimizes scriplets by converting the
If your JSPs contain many
Stringconcatenations, enabling this option optimizes scriplets by removing
Stringconcatenation for every JSP request.
- If your JSPs contain a lot of white space, enabling this option trims the white space from HTTP requests and reduces HTTP request payload.
Configuring JSP Options
You can enable these Undertow JSP configuration options using the management console or management CLI.
To enable them using the management console:
- Navigate to Configuration → Subsystems → Web (Undertow) → Servlet Container.
- Select the servlet container you want to configure and click View.
- Select JSP and click Edit.
- For each option you want to enable, set the field to ON and then click Save.
To enable them using the management CLI, use the following command:
For example, to enable
defaultservlet container, use the following command:
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.
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
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.
The maximum size of a 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.
Specifies the buffer pool in the
iosubsystem to use for the listener. By default, all listeners use the
You can use this option to configure each listener to use a unique buffer pool, or have multiple listeners use the same buffer pool.
undertowsubsystem relies on the
iosubsystem to provide XNIO workers. This option specifies the XNIO worker that the listener uses. By default, a listener uses the
defaultworker in the
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.
Configuring Listener Options
You can configure listener options using the management console or management CLI.
To configure them using the management console:
- 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.
To configure them using the management CLI, use the following command:
For example, to set
defaultHTTP listener in the
default-serverUndertow server, use the following command: