参考调优:http://www.mastertheboss.com/jboss-server/jboss-performance/jboss-as-7-performance-tuning?showall=1
1,jvm
\wildfly-10.0.0.Final\bin\standalone.conf.bat (linux standalone.conf)
set "JAVA_OPTS=-Xmx2048m -Xms2048m -XX:MaxNewSize=896m -XX:NewSize=896m -XX:SurvivorRatio=6 -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=2048m -XX:+UseLargePages "
2,log 日志
日志输出定义在root-logger里面:
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
级别是INFO;可以改为warn,error等减少日志输出。将<handler name="CONSOLE"/>删除掉,就不会往控制台输出日志。增快速度。
log将输出到两个handler里面:console和file。这两个定义如下:
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<size-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<rotate-size value="1000k"/>
<max-backup-index value="5"/>
<append value="true"/>
<suffix value=".yyyy-MM-dd"/>
</size-rotating-file-handler>
文件用了size-rotating-file-handler。rotate-size规定了日志每达到1m,就生成新的日志。一天共会生成5个分割文件。当日志达到4个以后,剩下日志会全填充到server.log。导致这个转为.5文件后特别大。
3. 数据库连接池失败后,自动重新连接
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/statisticsystem?characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false</connection-url>
<driver>mysql</driver>
<security>
<user-name>jboss</user-name>
<password>jboss</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<xa-datasource jndi-name="java:jboss/datasources/MySqlStatDW" pool-name="MySqlStatDW" enabled="true" use-java-context="true">
<xa-datasource-property name="ServerName">
192.168.8.238
</xa-datasource-property>
<xa-datasource-property name="PortNumber">
5029
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
statistics
</xa-datasource-property>
<driver>mysql</driver>
<xa-pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</xa-pool>
<security>
<user-name>zhibin</user-name>
<password>zhibin123</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
<xa-datasource jndi-name="java:jboss/datasources/MySqlDataCenter" pool-name="MySqlDataCenter" enabled="true" use-java-context="true">
<xa-datasource-property name="ServerName">
211.100.75.213
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
cms
</xa-datasource-property>
<driver>mysql</driver>
<xa-pool>
<min-pool-size>5</min-pool-size>
<initial-pool-size>5</initial-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</xa-pool>
<security>
<user-name>CPdeveloper206</user-name>
<password>206@)^developer</password>
</security>
</xa-datasource>
?characterEncoding=utf-8 是数据库存中文乱码,加上后改好。(注意:创建schema或者table时候指定字符集是utf8)
4,事务的超时
<subsystem xmlns="urn:jboss:domain:transactions:3.0">
<core-environment>
<process-id>
<uuid/>
</process-id>
</core-environment>
<recovery-environment socket-binding="txn-recovery-environment" status-socket-binding="txn-status-manager"/>
<coordinator-environment default-timeout="60"/>
</subsystem>
5,任务job,分区任务最大的线程数
<subsystem xmlns="urn:jboss:domain:batch-jberet:1.0">
<default-job-repository name="in-memory"/>
<default-thread-pool name="batch"/>
<job-repository name="in-memory">
<in-memory/>
</job-repository>
<thread-pool name="batch">
<max-threads count="200"/>
<keepalive-time time="30" unit="seconds"/>
</thread-pool>
</subsystem>
6,数据库做http auth
<security-domain name="dbdomain" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/MySqlDS"/>
<module-option name="principalsQuery" value="select passwd from USERS where login=?"/>
<module-option name="rolesQuery" value="select Role , 'Roles' from USER_ROLES where login=?"/>
</login-module>
</authentication>
</security-domain>
7,上传文件最大尺寸限制
<server name="default-server">
<http-listener name="default" max-post-size="204857600" socket-binding="http" redirect-socket="https"/>
8,改成外网地址可以访问
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
<interface name="unsecure">
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>
</interfaces>