JBoss Performance Optimization

Source: Internet
Author: User
Tags jboss xms jprofiler

Jboss

Linux JBoss Deployment Optimization settings:
specified by parameters in/conf/web.xml: <session-config> <session-timeout>1440</session-timeout> </ses Sion-config> units are minutes.
JBoss Deployment Directory Optimization: Eliminate and apply unrelated deployments to speed up JBoss run Bsh-deployer.xml client-deployer-service.xml ear-deployer.xml ejb-deployer.xml Http-invoker.sar jboss-bean.deployer Jboss-ws4ee.sar JMS jsr88-service.xml schedule-manager-service.xml scheduler-s Ervice.xml Sqlexception-service.xml Uuid-key-generator.sar
Lower the level of JBoss output log open <jboss>/server/default/conf/jboss-log4j.xml, which is a log4j profile. See http://logging.apache.org/log4j/1.2/index.html For detailed configuration instructions for the log4j. Too much log output can result in degraded server performance, thus reducing unnecessary log output. The method is broadly as follows:
1. Find the category element of Name= "Org.jboss" and set the priority element to <priority value= "INFO"/> 2. Build a new category with <category content Name= "javax.faces" ><priority value= "INFO"/></category> log4j also be able to input different logs into different places, in order to maintain the convenience later, should be different The category log is entered into a different file. Refer to the instructions on the above website for detailed methods.
Using the data compression function of Tomcat in JBoss, the contract management uses a lot of JavaScript css and so on, in order to reduce the transmission time, you can use the compression function. The method is: 1. Open <jboss>/server/default/deploy/jboss-web.deployer/server.xml 2. Find the connector element of protocol= "Http/1.1″, Add Property uriencoding= "utf-8″compression=" on "compressionminsize=" 2048″nocompressionuseragents= "Gozilla, Traviata" Compressablemimetype= "Text/html,text/xml,text/javascript, Text/css, text/plain,application/xhtml+xml,application /x-javascript,application/javascript,text/xhtml "after adding" similar to: <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 " Uriencoding= "utf-8″compression=" on "compressionminsize=" 2048″nocompressionuseragents= "Gozilla, Traviata" Compressablemimetype= "Text/html,text/xml,text/javascript, Text/css, text/plain,application/xhtml+xml,application /x-javascript,application/javascript,texT/xhtml "/>

Production example
<connector protocol= "http/1.1" port= "8080" address= "${0.0.0.0}"                   connectiontimeout= "20000" redirectport= "8443"                                   uriencoding= "Utf-8"                    compression= "on"                    compressionminsize= "2048"                    nocompressionuseragents= "Gozilla , Traviata "                  Compressablemimetype= "Text/html,text/xml,text/javascript, Text/css, text/plain,application/xhtml+xml,application /x-javascript,application/javascript,text/xhtml "       />

The following need to be debugged for a long time. ,
maxthreads= "maxsparsethreads=" minsparsethreads= "acceptcount=" 10 "

Allocating the appropriate memory to the JVM, typically 3/4 of the server's memory, is recommended to use at least 4G of RAM. java_opts = "-XMS4096M-XMX8192M-XX:+USEPARALLELGC-XX:+USEPARALLELOLDGC ...." "-xms=128m This is the heap initialization size. The maximum 32bit operating system is between 1.5g-2g. 64-bit Unrestricted-xmx=512m This is the maximum size of the heap. Try to set the-XMS and-xmx to the same size, so as to avoid memory reallocation affecting performance-xss=128k thread initialization size, before 5.0 default is 128k, then 1m, thread machine Max is 3000-5000-xx:maxpermsize= 256m. This is to indicate that the persistent class, that is, the Noheap region is the largest 256-xx:permsize=256m this persistent region is initialized to 256m, the size of the general durable class is 64m
The JVM garbage collector consists of three types: serial, parallel, concurrent serial: processing small data, jdk1.4 before default using parallel: 1.5 and 1.5 after use, processing
-XX:PARALLELGCTHREADS=20: Configures the number of threads for a parallel collector, that is, how many threads are garbage collected together. This value is best configured with the number of processors-XX:+USEPARALLELOLDGC: Configure the old Generation garbage collection method for parallel collection. JDK6.0 supports parallel collection of older generations. (The concurrency collector is mainly to ensure the response time of the system, reduce the time of garbage collection downtime.) It is suitable for application server, telecom field and so on. -XX:+USECONCMARKSWEEPGC set old age on behalf of concurrent collection. After configuring this in the test, the configuration of the-xx:newratio=4 is invalid for unknown reasons. Therefore, at this time the younger generation size is best set with-XMN. -xx:cmsfullgcsbeforecompaction= because the concurrent collector does not compress and defragment the memory space, it can produce "fragmentation" after a period of time, which makes the operation less efficient. This value sets how many times a GC is run to compress and defragment the memory space. -xx:parallelgcthreads=n: Set the concurrency collector the number of CPUs used by the young generation collection method for parallel collection. The number of parallel collection threads.


Modify the run.bat/run.sh in the bin directory of JBoss, on the ITS plus sign line:
Windows Set java_opts=%java_opts%-xms128m-xmx256m-xx:permsize=128m-xx:maxpermsize=256m-xx:maxnewsize=256m- DFILE.ENCODING=GBK echo "java_opts=" $JAVA _opts
Linux java_opts= "$JAVA _opts-xms128m-xmx256m-xx:permsize=128m-xx:maxpermsize=256m-xx:maxnewsize=256m- DFILE.ENCODING=GBK "echo" java_opts= "$JAVA _opts

Production example

#add wyg 2011-07-25 #modify wyg 2011-07-27 java_opts= "$JAVA _opts-xms1200m-xmx1200m-xx:permsize=600m-xx:maxpermsize=6 00m-xx:newsize=400m-xx:maxnewsize=400m-xx:+usetlab-xx:tlabsize=128k "


32-bit Windows operating system, the largest can be allocated to about 1.5G of memory. The reason is that the JVM must allocate contiguous blocks of memory when allocating memory for performance reasons, and before the JVM starts, there are often other applications that split the operating system's memory, so there is a failure to allocate heap memory when the JVM starts. Workaround: 1, start multiple JVM 2 on 32-bit Windows operating system, change to 64-bit operating system



Security settings 1, jmx-console login user name and password settings by default access to Http://localhost:8080/jmx-console can browse JBoss deployment management of some information, do not need to enter a user name and password, use a bit of a security risk. Here we configure JBoss for this issue, so that access to the Jmx-console must also know the user name and password in order to access. The steps are as follows: (1) Locate the JBoss installation directory/server/default/deploy/jmx-console.war/web-inf/jboss-web.xml file and remove the <security-domain> Java:/jaas/jmx-console</security-domain> 's comments. The modified file contents are: (2) Modify the Web. xml file under the Jboss-web.xml sibling directory (1), find the <security-constraint> node, and remove its comments (3) The Jmx-console security domain in the first step and the run role Jbossadmin in the second step are all configured in Login-config.xml, and we find it under the JBoss installation directory/server/default/config. Find Name: Jmx-console application-policy: <application-policy name = "Jmx-console" > <authentication> < Login-module code= "org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "Required" > <module-option name= " Usersproperties ">props/jmx-console-users.properties</module-option> <module-option name=" Rolesproperties ">props/jmx-console-roles.properties</module-option> </login-module> </ Authentication> </application-policy&Gt As you can see here, the information about the roles, users, etc. of the login is set in the Jmx-console-roles.properties and jmx-console-users.properties files in the props directory, respectively, and the two files are opened separately. After the configuration is complete, the reader can access the Jmx-console page by accessing: http://localhost:8088/jmx-console/, entering the user name and password defined in the Jmx-console-roles.properties file.
2. Web-console login username and password settings by default, when a user accesses JBoss Web-console, they do not need to enter a user name and password, and for security reasons, we add a username and password by modifying the configuration. The steps are as follows: (1) Find the JBoss installation directory f:/jboss/server/default/deploy/management/console-mgr.sar/web-console.war/web-inf/ Jboss-web.xml file, remove <security-domain>java:/jaas/web-console</security-domain> comments (2) Modify the Web. xml file in the Jboss-web.xml sibling directory (1), remove the comments from the <security-constraint> section (3) Open the JBoss installation directory in the JBoss installation directory/server/ Default/config under the Login-config.xml file, search Web-console, locate and modify the following: <application-policy name = "Web-console" >      <authentication>        <login-module code= " Org.jboss.security.auth.spi.UsersRolesLoginModule "flag =" Required ">             <module-option name= "Usersproperties" >props/web-console-users.properties</ module-option>            <module-option name= " Rolesproperties ">props/web-console-roles.properties</module-option>        </login-module>     </authentication> </ Application-policy> can be seen in the file, Information such as the username and role of the login Web-console is set in the Web-console-users.properties and web-console-roles.properties files in the directory where the Login-config.xml file is located, but because there is no These two files, we create these two files in the JBoss installation directory/server/default/conf/props directory, the contents of the file can refer to the contents of two corresponding configuration files in "Jmx-console login username and password Settings".

Disable/Open file directory list edit f:/jboss/server/default/deploy/jboss-web.deployer/conf/web.xml prohibit setting listing to False, otherwise true
Prevent the log file from extending indefinitely in the f:/jboss/server/default/conf directory, open the Jboss-log4j.xml file under the following statement block: <appender name= "file" class= " Org.jboss.logging.appender.DailyRollingFileAppender "> <errorhandler class=" Org.jboss.logging.util.OnlyOnceErrorHandler "/> <param name=" File "value=" ${jboss.server.log.dir}/server.log "/> <param name=" Append "value=" false "/> Add the following statement: <param name=" MaxFileSize "value=" 10240KB "/> <para M name= "Maxbackupindex" value= "1"/> The maximum value of the file and the number of backups can be changed according to the actual situation




Data source

<max-pool-size>20</max-pool-size> <min-pool-size>5</min-pool-size> <idle-timeout-mi Nutes>0</idle-timeout-minutes>



Add Jprofiler startup parameters (to start JBoss Jprofilter first) Generally this comment is dropped
Modify the JBoss startup script by adding the following parameters:-agentlib:jprofilerti=port=8849-xbootclasspath/a: $JPROFILER _home/bin/agent.jar $JAVA _opts


Increase Jconsole Startup parameters
-djava.rmi.server.hostname=192.168.19.126-dcom.sun.management.jmxremote.port=9899- Dcom.sun.management.jmxremote.authenticate=false-dcom.sun.management.jmxremote.ssl=false $JAVA _opts



JBoss thread Pool

Conf/jboss-service.xml
<attribute name= "Maximumpoolsize" >40</attribute> <!--the max number of tasks before the queue is ful ---<attribute name= "Maximumqueuesize" >1000</attribute>

Name: Threadgroupname:thread group name in the pool threads KeepAliveTime: The maximum amount of time (in milliseconds) to keep active when threads is idle Maximumpoolsize: The maximum number of thread that can be concurrent minimumpoolsize: The minimum number of thread that can be concurrently maximumqueuesize: Maximum number of request that is allowed to wait Blockingmode: Waiting for the queue to be processed after it is full



Compiling the configuration of the JSP
In general, JSP files are compiled the first time they are called, and then each one [is modified once, it is recompiled.]
This facilitates development, but in a production environment, a changed configuration can cause problems
1. The first person to invoke a JSP page is to wait for the JSP page to be compiled, the best option is to turn off the lazy compilation feature of the page
2. Each page request checks to see if the JSP file has been modified to determine whether or not to recompile, and the check for each request is updated to reduce the performance of the production environment
The compilation and operation of JSP files is handled by a Java servlet, called Jspservlet, in the ..../deployers/jbossweb.deployer/web.xml configuration
<servlet> <servlet-name>jsp</servlet-name>
<init-param> <description>development</description>               <param-name>development</param-name> <param-value>false</param-value> </init-param>
<init-param> <description>development</description> <param-name>checkInterval</param-name> <param-value>300</param-value>
<!--5 min--
</init-param>
Parameters
Development
Default value: True
Description: Whether to use development mode, if used, then the Modificationtestinterval parameter will be called
Checkinterval
Default value: 0
Description: If the value of development to False,checkinterval is greater than 0, the compiler works, Checkinterval is the time interval for repeating compilation, and the default is 0
Modificationtestinterval
Default value: 4
Description: The time interval at which the JSP page repeats detection after the last call, and if it is 0, it is detected after each call and the default value is 4

If you have a lot of JSP pages that need to be precompiled, you can purchase a built-in compiler

JBoss Performance Optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.