Configuring the HTTP connector
Recommended by 0 users
Configuring the HTTP connector
Out of the box, JBoss Web server uses the Java-based HTTP/1.1 (Coyote) connector for parsing HTTP requests and passes the request to the Web server engine.
The Java-based Coyote connector is a mature and extremely stable component and should be the choice for most situations, especially if you are just beginning to use JBoss AS.
On highly loaded systems, however, you can opt for the newer APR HTTP connector, which potentially offers the highest level of performance improvement, by leveraging proven operating system–level optimization on it.
The native APR connector is not a complete connector in the strictest sense. It actually makes use of the standard Java-based connector for most of its operations. However, when the native code APR connector is enabled, the Java code will switch to native implementation for several performance-sensitive and scalability-sensitive operations.
The APR connector optimizes performance and enhances scalability through three main mechanisms:
- Use of a sendfile kernel mode call to send large static files directly from the buffer cache
- Use of a single native code keep alive poller, to implement connection keep alive for a large number of connections
Installing the APR connector
JBoss AS is a pure Java application server and so the APR connector does not ship with the standard distribution. When you start the application server, you might have noticed the following log message:
15:50:39,187 INFO [org.apache.catalina.core.AprLifecycleListener] (MSC service Thread 1-2) The Apache Tomcat Native library, which allows optimal performance in production environments, was not found on the java.library.path
As a matter of fact, the AprLifecycleListener tries to find the APR libraries at startup. Since we still haven’t added them to the server installation, the Web server will fall back to the standard HTTP/1.1 connector.
Installing the APR connector is just a matter of following a few simple steps:
First, download the JBoss Native connector (part of the JBoss Web project) from: http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-9, taking care to choose the right native-built libraries for your operating system.
Once downloaded, unzip the JBoss Native into the home folder of your JBoss AS distribution.
As you can see, the archive contains into the native folder some operating system libraries, which will be used to enhance the capabilities of the http connector. Here, for example, is the library that will be used for a Windows machine:
Now, since the APR is a native library, you need to make sure that it’s available in the java.library.path environment variable. There are already a few places where the JVM will look for native libraries, such as the JAVA_HOME/bin folder or (on Windows machine) the c:\Windows32\system32. You can either place the native library there or add its path into the startup script of the application server:
set “JAVA_OPTS=%JAVA_OPTS% -Djava.library.path=C:\JBoss-as-7.0.2.Final\bin\native” Now, restart JBoss AS, which will now detect the presence of the native libraries and leverage them:
standalone.bat or standalone.sh
You will notice certain console output that indicates the presence of the APR:
Configuring the Web server resources
Now that we have covered the standard Web server configuration, we will look at the additional configuration options that are available, but not explicitly shown in the standalone.xml configuration file. The Web server configuration section is divided into two broad areas:
Static resources configuration: This includes resources, such as HTML pages and images
JSP configuration: This is used for pages that are dynamically generated by the Web container
We will deal with the two options in the following two sections.
Configuring static resources
Static resources include that part of the Web application (notably html pages and images) that do not require processing by the Web container, but just need to be rendered to the end user. For large applications requiring the highest throughput, we suggest you configure Apache as dispatcher for static resources. This will be explained in detail in Chapter 9, Load Balancing Web Applications, which discusses in depth load balancing applications.
For smaller projects, using JBoss for this purpose might be just as good, so we have included a sample static resources configuration which is based on the default values:
<subsystem xmlns=”urn:jboss:domain:web:1.1″ default-virtual-server=”default-host”>
<static-resources listings=”false” sendfile=”49152″ file-encoding=”utf-8″ read-only=”true” webdav=”false” max-depth=”3″ disabled=”false”/>
. . . . . .
And here is a table reinforcing the meaning of the single properties:
Configuring dynamic resources
Besides the configuration of static resources, you will more likely be interested in tuning the configuration of dynamic resources, such as JSP pages that are handled by JBoss Web server. By default, there’s no jsp-configuration element. If you want to include it, you need to add it as a child element of the configuration section, just like for the static resources. Here’s a jsp-configuration that relies on default values:
<jsp-configuration check-interval=”1″ development=”false” disabled=”false” display-source-fragment=”true” dump-smap=”false” error-on-use-bean-invalid-class-attribute=”false” generate-strings-as-char-arrays=”false” java-encoding=”UTF8″ keep-generated=”true” mapped-file=”true” modification-test-interval=”4″ recompile-on-fail=”false” scratch-dir=”” smap=”true” source-vm=”1.5″ tag-pooling=”true” target-vm=”1.5″ trim-spaces=”false” x-powered-by=”true”/>
Most of the configuration section is targeted at providing additional information to developers and some minor optimization to applications running in production. You should be aware of the development attribute, which determines if your dynamic pages (such as JSPs) will be ultimately checked for recompilation using the check-interval time (in seconds). So, when developing your applications, you should generally set this element to true, and to false when running in production.
The full description of the jsp-configuration section element follows here: