Configuring JBoss in a Production Server – Step by Step Guide


Configuring JBoss in a Production Server – Step by Step Guide

Introduction

 

This document records the changes to the JBoss AS to run as a production server where tomcat is under port 80, and allow it to run alongside a development server.  

 

Step 1 – Configuring Startup Scripts

The first thing I did was to create a set of startup/shutdown scripts for JBoss Server. These were copied to the desktop so that it is easy to start or stop the JBoss instance.

startjboss.cmd

d:
cd D:\server\jboss-4.2.2.GA\bin
run.bat -b 0.0.0.0

stopjboss.cmd

d:
cd D:\server\jboss-4.2.2.GA\bin
shutdown.bat -S

As you can see both these scripts are actually calling default scripts provided in the JBoss’ bin folder.

In the startup script the -b argument (binding ip) indicates the IP to which the server session is to be attached. 0.0.0.0 indicates that the server must be accessible from all ips including localhost (it binds the JBoss server to all ip addresses of server machine). If you don’t specify this, JBoss will be accessible only from 127.0.0.1.

Step 2 – Configuring JVM Memory Settings

The run.bat file in the bin folder contains JVM parameters including memory configuration. In the production server, ensure that these values are correctly set. For example, the following sets the minimum and maximum heap size as 1GB. It is better to keep them identical for performance reasons. The actual heap size setting will depend on your application requirements and also on the RAM size of the server machine.

set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m

Also ensure that adequate permgen space is set. Permgen space is the fixed memory required such as the code footprint. For large applications the default value of 64m may not be sufficient. Following sets the permgen space to 512MB.

set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=512m -XX:MaxPermSize=512m

Using Verbose Garbage Collection to Determine Heap Size

The HotSpot VM’s verbose garbage collection option (verbosegc) enables you to measure exactly how much time and resources are put into garbage collection. To determine the most effective heap size, turn on verbose garbage collection and redirect the output to a log file for diagnostic purposes.

   Use the -verbosegc option to turn on verbose garbage collection output for your JVM and redirect both the standard error and standard output to a log file.

 This places thread dump information in the proper context with WebLogic Server informational and error messages, and provides a more useful log for diagnostic purposes.

For example, on Windows and Solaris, enter the following:

% java -ms32m -mx200m -verbosegc -classpath $CLASSPATH
-Dweblogic.Name=%SERVER_NAME% -Dbea.home="C:\bea"
-Dweblogic.management.username=%WLS_USER%
-Dweblogic.management.password=%WLS_PW%
-Dweblogic.management.server=%ADMIN_URL%
-Dweblogic.ProductionModeEnabled=%STARTMODE%
-Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server
>> logfile.txt 2>&1

  1. where the logfile.txt 2>&1 command redirects both the standard error and standard output to a log file.

  2. On HPUX, use the following option to redirect stderr stdout to a single file:

    -Xverbosegc:file=/tmp/gc$$.out

where $$ maps to the process ID (PID) of the Java process. Because the output includes timestamps for when garbage collection ran, you can infer how often garbage collection occurs.

Step 3 – Changing Default HTTP Port to 80

The HTTP port for default JBoss installation is 8080. In production server, you will require this to be on port 80 (default HTTP port). If you are using HTTPS, you will need to change SSL port from 8443 to 443. Following files must be edited for this change. Look for the “Connector” tag with “port” attribute.

(a) default/deploy/jboss-web.deployer/server.xml
(b) default/deploy/http-invoker.sar/META-INF/jboss-service.xml
(c) default/deployers/jbossweb.deployer/server.xml
(d) default/deploy/jbossws.sar/jbossws.beans/META-INF/jboss-beans.xml

Step 4 – Configuring Datasource Settings

The datasource settings are stored in xml files under deploy folder of the server. For example, oracle-ds.xml is the configuration file I used in my application. This maps a connection setting to a JNDI name. The important parameters to configure are,

min-pool-size – This is the initial number of connections kept open to database.
max-pool-size – This is the maximum number of concurrent connections possible to the database. This value should be based on your application needs and also on the database configuration.

Step 5 – Configuring HTTP Connector Settings

The underlying HTTP connector of JBoss needs to be fine tuned for production settings. The important parameters are,

maxThreads – This indicates the maximum number of threads to be allocated for handling client HTTP requests. This figure corresponds to the concurrent users that are going to access the application. Depending on the machine configuration, there is a physical limit beyond which you will have to do clustering.

acceptCount – This is the number of request threads that are put in request queue when all available threads are used. When this exceeds, client machines get a request timeout response.

compression – If you set this attribute to “force”, the content will be compressed by JBoss and will be send to browser. Browser will extract it and display the page on screen. Enabling compression can substantially reduce bandwidth requirements of your application.

 

 

EDIT SERVER.XML IN C:\jboss-5.1.0.GA\server\default\deploy\jbossweb.sar COMMENT OUT THE EXISTING CONNECTOR ELEMENT AND ADD FOLLOWING

 

<Connector port="8080" address="${jboss.bind.address}"      

     maxThreads="250" maxHttpHeaderSize="8192" 

     emptySessionPath="true" protocol="HTTP/1.1" 

     enableLookups="false" redirectPort="8443" acceptCount="100" 

     connectionTimeout="20000" disableUploadTimeout="true" />

 

Step 6 – Configuring JSP Compilation Settings

JBoss application server regularly checks whether a JSP requires compilation to a servlet before executing a JSP. In a production server, JSP files won’t change and hence you can configure the settings for increased performance.

Open the web.xml in deploy/jboss-web.deployer/conf folder. Look for the jsp servlet in the file and modify the following XML fragment as given below,

<init-param>
<param-name>development</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>checkInterval</param-name>
<param-value>300</param-value>
</init-param>

Step 7 – Removing unwanted applications and services

JBoss comes with a lot of services and your enterprise applications may not need all of them. Removing these unwanted services can boost application server performance. Following are some of the JBoss services you can remove if your application is not using them. Delete the files/folders given in brackets to remove these services completely.

1.       Home page server- (deploy/ROOT.war)

2.       JMX Console server – (deploy/jmx-console.war) [Keep if you want to monitor jboss console]

3.       Web Console server – (deploy/management) [Keep if you want to monitor jboss console]

4.       Unique ID key generator – (deploy/uuid-key-generator.sar, lib/autonumber-plugin.jar)

5.       HTTP Invoker service – (deploy/http-invoker.sar)

6.       Quartz scheduler service – (deploy/quartz-ra.rar)

7.       Mail service – (deploy/mail-service.xml, lib/mail*.jar)

8.       Monitoring service – (deploy/monitoring-service.xml,lib/jboss-monitoring.jar)

9.       Scheduler service – (deploy/scheduler-service.xml, deploy/schedule-manager-service.xml,lib/scheduler-plugin*.jar)

10.   Messaging (JMS) service – (deploy/messaging, deploy/jms-ds.xml, deploy/jms-ra.rar, lib/jboss-messaging*.jar)

11.   deployers/messaging-definitions-jboss-beans.xml

12.   deploy/profileservice-secured.jar

13.   deployers/ejb-deployer-jboss-beans.xml

14.   deploy/ejb2-container-jboss-beans.xml  

15.   deploy/ejb2-timer-service.xml    

16.   deploy/ejb3-connectors-jboss-beans.xml   

17.   deploy/ejb3-container-jboss-beans.xml    

18.   deploy/ejb3-interceptors-aop.xml         

19.   deploy/ejb3-timerservice-jboss-beans.xml  

20.   deployers/jbossws.deployer

 

 

Subversion

 

This production configuration can be found under /Users/svnrep/jboss-config/server/production/

 

To obtain this configuration, change working directory to server/ under the JBoss root, and execute the following (on the server):

 

            svn export file:///Users/svnrep/jboss-config/server/production/ ./

 

 

Step 8 – Session Timeout

Set an approriate value for session timeout in web.xml 

<session-config>

<session-timeout>15</session-timeout>

</session-config>

 

JBoss tuning tip 1: Tune the garbage collector

se the the command line option -verbose:gc causes information about the heap and garbage collection to be printed at each collection.

 

 

Reference URLs

http://www.jayson.in/programming/how-to-configure-jboss-as-production-settings-and-tuning-tips.html

 

http://www.mastertheboss.com/en/jboss-application-server/113-jboss-performance-tuning-1.html

 

 

http://www.mastertheboss.com/en/jboss-application-server/130-jboss-performance-tuning-part-2.html

Advertisements

About Praveen Orathel

I am a java web application developer.
This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Configuring JBoss in a Production Server – Step by Step Guide

  1. Tangela says:

    “Configuring JBoss in a Production Server – Step by Step Guide | pjava”
    was in fact a truly great blog post, . Continue posting and I will continue to keep viewing!
    Thanks a lot ,Guadalupe

  2. Wow! In the end I got a website from where I be capable of in
    fact obtain valuable information regarding my study and
    knowledge.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s