Out of the box, the 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.
If you want to build your career as a JBoss professional, then visit Mindmajix - A Global online training platform for the “JBoss Training” Course. This course will help you to achieve excellence in this domain.
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: Windows32system32. 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.Finalbinnative” 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:
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.
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 a 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:
And here is a table reinforcing the meaning of the single properties:
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 the 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:
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:
Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!
|JBoss Training||Dec 05 to Dec 20||View Details|
|JBoss Training||Dec 09 to Dec 24||View Details|
|JBoss Training||Dec 12 to Dec 27||View Details|
|JBoss Training||Dec 16 to Dec 31||View Details|
Technical Content Writer
Copyright © 2013 - 2023 MindMajix Technologies