JBoss Maximum Connection number configuration and JVM memory configuration

Source: Internet
Author: User
Tags server memory xms

one. Adjust the maximum number of JBoss connections .

Configure the Deploy/jboss-web.deployer/server.xml file.
<connector
port= "8080"
Address= "0.0.0.0"
maxthreads= "1600"
minsparethreads= "100"
Maxsparethreads= "250"
Emptysessionpath= "false"
enablelookups= "false"
redirectport= "8443"
acceptcount= "800"
connectiontimeout= "20000"
disableuploadtimeout= "true"
uriencoding= "UTF-8"
/>
MaxThreads: Represents the maximum number of simultaneous connections processed. The number of threads (maximum number of threads) should be set to 25% more (rule of thumb) than the maximum expected load (concurrent clicks).
Acceptcount: When the number of simultaneous connections reaches MaxThreads, you can also receive queued connections.

Minsparethread: Refers to "always keep this number of threads idle waiting after startup"; set 25% more than expected load.

Maxsparethread: Refers to "if the Minsparethread is exceeded, then always keep the number of threads idle Wait"; set 25% more than the expected load.

It mainly modifies two parameters maxthreads and Acceptcount values. Increasing the maxthreads and reducing the Acceptcount value is advantageous to shorten the response time of the system. But the sum of maxthreads and acceptcount can not exceed 6000, and maxthreads to increase CPU and memory consumption, Therefore, low-profile users can ensure the stability of the system by reducing the maxthreads and increasing the Acceptcount value at the same time.

The following table lists the general relationships between JBoss parameters and concurrent online in different concurrency scenarios.

Concurrency number

Server memory

JBoss parameters

MaxThreads Acceptcount
50 or less 2G 256 800
50-300 4G 600 1024
300-800 8G 1024 1528
800-1000 8G 1024 2048
1000-1200 12G 1526 2048
1200-1500 16G 2048 2048

Two. Tuning JVM parameters

A:JVM startup parameters are divided into three categories:
The first is the standard parameter (-), all JVM implementations must implement the functions of these parameters, and backward compatibility;
The second is the non-standard parameter (-X), which refers to some of the JVM's underlying configuration parameters, which are default in general development and do not require any configuration. However, in a production environment, it is not guaranteed that all JVM implementations are satisfied, so in order to improve performance, these parameters often need to be adjusted in order to achieve the best performance of the system. In addition, these parameters do not guarantee backward compatibility, that is, "if there is a change, not in the subsequent version of the JDK notification" (This is the official website of the exact words);
The third is non-stable parameters (-XX), such parameters in the JVM is unstable, not suitable for daily use, follow-up may be without notice in the case of the direct cancellation, need to use cautiously.
B: AndJVM memory can also be divided into three main domains:
New domain, old domain, and permanent domain. All new objects generated by the JVM are placed in the new domain. Once an object undergoes a certain number of garbage collection loops, it enters the old domain. In the permanent domain, it is used to store the JVM's own reflection objects, such as class and method objects, and the GC (garbage Collection) does not clean up the permanent domain during the main program run time. Where the new and old domains belong to the heap, the permanent domain is a separate domain and is not considered part of the heap.
C: The functions of the main parameters are as follows
-XMS: Set the initial size of JVM memory
-XMX: Set the maximum value of JVM memory
-XMN: Set the size of the new domain (this seems to be only valid for jdk1.4, and then discarded)
-XSS: Sets the stack size of each thread (that is, under the same physical memory, reducing this value can generate more threads)
-xx:newratio: Sets the ratio of the new domain to the old domain, such as-xx:newratio = 4, which means that the ratio of the new domain to the old domain is 1:4
 -xx:newsize: Set the initial value of the new field
       < Span class= "Apple-converted-space" > -xx:maxnewsize: Setting the maximum value for a new field
         -xx:permsize: Set the initial value of the permanent domain
         -xx:maxpermsize: Set maximum value for permanent domain
         -xx:survivorratio=n: Sets the ratio of Eden to two survivor areas in the new domain. (The Eden area is primarily used to store new objects, while two survivor are used to store objects that survived each garbage collection)
D: Common Errors &NBSP;:
         Java.lang.OutOfMemoryError believe that many developers have used, this is mainly the JVM parameters are not properly caused, but this error is divided into two kinds: Java.lang.OutOfMemoryError:Java heap Space and Java.lang.OutOfMemoryError:PermGen space, where the former is a memory overflow about heap memory, can be set with the configuration-xms and-xmx parameters, and the latter is a memory overflow about the persistent domain, which can be configured by-XX: MaxPermSize to set.

Below is an example, please modify according to the actual situation, modify the following content in the run.conf file :
Java_opts= "-xms256m-xmx2048m-xx:newsize=256m-xx:maxnewsize=512m-xx:permsize=128m-xx:maxpermsize=256m-xx:+ useconcmarksweepgc-xx:+cmspermgensweepingenabled-xx:+cmsclassunloadingenabled -Djboss.platform.mbeanserver "


log File Settings :

Jboss\server\default\log


If you need to modify the JBoss default log4j settings, you can modify the Jboss-log4j.xml file under the JBoss installation directory "server\default\conf, where you can see that the log4j log output is in the JBoss installation directory" Server\

If you use the LOG4J log framework, placing the configuration file under the project directory can easily cause conflicts with the JBoss log configuration, and a good way is to configure the log to the JBoss jboss-log4j.xml file, where the directory of the files is ($JBOSS)/server/ Default/conf. Add the following in the configuration file:

<appender name= "MyLog" class= "Org.apache.log4j.DailyRollingFileAppender" >
<!--Set channel name is: file, output mode dailyrollingfileappender-->
<param name= "File" value= "${jboss.server.home.dir}/log/mqs.log"/>
<!--log file path and file name--

<param name= "Append" value= "true"/>
<!--Set whether to add a new log on the base of the original log when the service is restarted--

<!--Rollover at midnight
<param name= "Datepattern" value= "'. ' Yyyy-mm-dd "/>


<!--Rollover at the top of each hour
<param name= "Datepattern" value= "'. ' Yyyy-mm-dd-hh "/>
-
<layout class= "Org.apache.log4j.PatternLayout" >
 <!--the default pattern:date priority [Category] message/n-->
& Nbsp;     <param name= "ConversionPattern" value= "%d%-5p [%c]%m%n"/>
      <!--the Full pattern:date MS Priority [Category] (THREAD:NDC) message/n
      <param name=" Conversionpattern "value="%d%-5r%-5p [%c] (%t:%x)%m%n "/>
       &NBSP;-->
   &NBSP;</LAYOUT>&NBSP;&NBSP;&NBSP;&NBSP;
  &NBSP;</APPENDER>

<logger name= "Com.all" additivity= "false" >
<level value= "INFO"/>
<appender-ref ref= "MyLog"/>
</logger>

You can write this when you use the log in Web engineering.

Logger log = Logger.getlogger ("Com.all");

Log.debug ("test");

where "Com.all" corresponds to the Name property value in <logger name= "Com.all" additivity= "false" >. The Additivity property is important to indicate whether to inherit the root configuration of the output channel, the default configuration is true, and if you do not set it to false, it causes the log output to be repeated to the console and JBoss log files.

Default

Jboss\server\default\log

JBoss Maximum Connection number configuration and JVM memory configuration

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.