Performance Tuning JBoss 7
Autor: Rafael | Publicado: 2014-10-10T07:12:00-03:00


Seguem algumas dicas para efetuar um tuning de performance da versão JBoss-as-7.1.1.Final Community em um Linux Debian 7.6.







Configurações da JVM 

Dentro do arquivo $JBOSS_home/bin/standalone.conf, você pode efetuar as seguintes configurações: 

- Memória: uma configuração para um servidor de pequeno porte para uma máquina com memória física de 4Gb seria:

JAVA_OPTS="-Xms2g -Xmx2g -XX:PermSize=256m -XX:MaxPermSize=512m"

- GC Paralelo: caso a máquina tenha vários processadores é interessantes habilitar o GC paralelo e dividir as regiões de memória.

# Paralell GCJAVA_OPTS="$JAVA_OPTS -server -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:SurvivorRatio=2 -XX:NewRatio=2"



Configurações do Linux

- Linux HugePages: Você pode também habilitar o HugePages no sistema operacional e habilitar o uso de large pages na JVM:

Veja aqui como habilitar o hugepages para o debian: https://wiki.debian.org/Hugepages. Basicamente é criar um grupo no linux, criar o ponto de montagem, configurar os parametros do kernel e adicionar um usuário ao grupo criado, ou seja, o usuário que irá subir o jboss.

Para uma máquina de 4Gb de memória física, temos os seguintes valores para o Hugepages:

Arquivo /etc/sysctl.conf:

# Total memorykernel.shmmax = 4294967295# Ceil(shmmax/PAGE_SIZE)kernel.shmall = 1048576# Allocate n * 2048kb (Hugepagesize) for HugePageTables
vm.nr_hugepages = 1536

Ainda no standalone.conf, para habilitar o uso do Hugepages na JVM, você precisa usar o parâmetro abaixo:

# Large PagesJAVA_OPTS="$JAVA_OPTS -XX:+UseLargePages"



Configurações do JBoss

Dentro do standalone.xml, temos:

- Compressão do tráfego: o mais recomendável é que você utilize um servidor web como Apache Web Server para receber as requisições e direcione para o jboss, mas mesmo assim é interessante verificar como compactar alguns tipos de arquivos:

&lt;system-properties&gt;&nbsp;&nbsp; &nbsp;&lt;property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/&gt;&nbsp;&nbsp; &nbsp;&lt;property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="text/html,text/xml,text/plain,text/css,text/javascript,text/json,application/x-javascript,application/javascript,application/json"/&gt;&nbsp;&nbsp; &nbsp;&lt;property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIN_SIZE" value="1024"/&gt;&lt;/system-properties&gt;

- Logger: diminua os níveis de logger do jboss, e se for o caso, remova o CONSOLE handler dele, para a maioria dos casos, você pode só diminuir o nível para WARN e deixar INFO para as mensagens de inicialização do JBoss:

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;logger category="org.jboss.as"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;level name="INFO"/&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/logger&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;...&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;root-logger&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;level name="WARN"/&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;/root-logger&gt;


&nbsp;- Thread Pool: configure um thread pool para receber as requisições web, estimando a quantidade de usuários concorrentes que você espera que aquele servidor suporte. Abaixo segue uma configuração para suportar em torno de 200 usuários concorrentes.

&nbsp;&nbsp;&nbsp; &lt;subsystem xmlns="urn:jboss:domain:threads:1.1"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;bounded-queue-thread-pool name="http-executor" blocking="true"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;core-threads count="200" /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;queue-length count="1000" /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;max-threads count="300" /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;keepalive-time time="5" unit="seconds"/&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/bounded-queue-thread-pool&gt;&nbsp;&nbsp;&nbsp; &lt;subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="true"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; executor="http-executor" enable-lookups="false" &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; max-connections="300" max-post-size="2048" max-save-post-size="4096"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /&gt; 

- Mail/Default: caso seu servidor não utilize o mail-session do JBoss, você pode remover a extension, o subsystem e o socket-binding conforme abaixo. Isso irá deixar a inicialização do servidor mais rápida.

&nbsp;&nbsp;&nbsp; &lt;extension module="org.jboss.as.mail"/&gt;&nbsp;&nbsp;&nbsp;&nbsp; ...&nbsp;&nbsp; &nbsp;&lt;subsystem xmlns="urn:jboss:domain:mail:1.0"&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;mail-session jndi-name="java:jboss/mail/Default"&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;smtp-server outbound-socket-binding-ref="mail-smtp"/&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;/mail-session&gt;&nbsp;&nbsp; &nbsp;&lt;/subsystem&gt;&nbsp;&nbsp;&nbsp; ...&nbsp;&nbsp; &nbsp;&lt;outbound-socket-binding name="mail-smtp"&gt;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;remote-destination host="localhost" port="25"/&gt;&nbsp;&nbsp; &nbsp;&lt;/outbound-socket-binding&gt;


- JBoss Web Native: instale os connectors nativos para uma melhor performance das conexões HTTP.

Abaixo segue o link para fazer download dos binários já compilados para cada plataforma:

http://jbossweb.jboss.org/downloads/jboss-native-2-0-10.html


Descompacte dentro da $JBOSS_HOME/bin/native:

ls -l $JBOSS_HOME/bin/native/lib*-1.so 


Habilite dentro do arquivo standalone.xml:

&lt;subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="true"&gt;


- Deployment Scanner: desabilite a checagem do scanner, assim ele não irá fazer hot-deploy de arquivos. Isso pode ser um falha de segurança e diminui o overhead no disco. Com a configuração abaixo, ele só irá fazer o deploy durante a inicialização do JBoss:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="0"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/subsystem&gt; 


&nbsp;- Compilation JSP e arquivos estátivos: desabilite a checagem para compilação das JSPs e desabilite a listagem de recursos estáticos:

&lt;subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;configuration&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;static-resources listings="false" sendfile="49152"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; file-encoding="utf-8" read-only="true" webdav="false" max-depth="3" disabled="false" /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;jsp-configuration &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; development="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; check-interval="1"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; disabled="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; display-source-fragment="true"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dump-smap="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; error-on-use-bean-invalid-class-attribute="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; generate-strings-as-char-arrays="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; java-encoding="UTF8"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; keep-generated="true"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mapped-file="true"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modification-test-interval="4"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; recompile-on-fail="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; scratch-dir=""&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; smap="true"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; source-vm="1.6"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tag-pooling="true"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; target-vm="1.6"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; trim-spaces="false"&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; x-powered-by="true"/&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/configuration&gt;


- Data Source: estime e configure a quantidade de conexões que a aplicação terá. A maioria das aplicações usam OpenSessionInView, ou seja, cada request utiliza somente uma conexão de banco, pensando assim, podemos estimar o tamanho do pool, com o mesmo tamanho do thread pool, assim para 200 usuários concorrentes, teríamos:

&lt;datasources&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;datasource jndi-name="java:jboss/datasources/ExemploDS" pool-name="ExemploDS" enabled="true" use-java-context="true" use-ccm="false"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;connection-url&gt;....&lt;/connection-url&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;driver&gt;....&lt;/driver&gt;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;pool&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;min-pool-size&gt;100&lt;/min-pool-size&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;max-pool-size&gt;200&lt;/max-pool-size&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;prefill&gt;true&lt;/prefill&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;use-strict-min&gt;false&lt;/use-strict-min&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/pool&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;statement&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;track-statements&gt;true&lt;/track-statements&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;prepared-statement-cache-size&gt;50&lt;/prepared-statement-cache-size&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;share-prepared-statements /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/statement&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;timeout&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;blocking-timeout-millis&gt;10000&lt;/blocking-timeout-millis&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;idle-timeout-minutes&gt;2&lt;/idle-timeout-minutes&gt;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;set-tx-query-timeout /&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;query-timeout&gt;30&lt;/query-timeout&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;use-try-lock&gt;30&lt;/use-try-lock&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/timeout&gt;

Lembre-se de verificar se o banco suporta essa quantidade de conexões. Para Oracle, você pode utilizar o select abaixo:

select name, value from v$parameterwhere name in ('processes', 'sessions', 'transactions');



- Validação da conexão: habilite também as validações de conexão. Isso evita problemas na aplicação devido oscilações na rede. Abaixo seguem alguns exemplos:

Oracle

&lt;validation&gt;&nbsp; &lt;valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/&gt;&nbsp; &lt;stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/&gt;&nbsp; &lt;exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/&gt;&lt;/validation&gt;

Postgresql:

&lt;validation&gt;
&nbsp; &lt;valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" /&gt;&nbsp; &lt;exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" /&gt;
&lt;/validation&gt;

Aqui temos a listagem completa para cada banco de dados:

http://www.ironjacamar.org/doc/userguide/1.0/en-US/html/ex_datasources.html



Configurações de Segurança

&nbsp;- Usuário jboss-as: Crie um usuário específico para o efetuar o start e shutdown do JBoss. Você pode utilizar os arquivos que vem dentro do jboss para configurar isso no linux:

$JBOSS_HOME/bin/init.d/
&nbsp; &nbsp; - jboss-as.conf
&nbsp; &nbsp; - jboss-as-standalone.sh

Copie o jboss-as.conf para /etc/jboss-as/

cp $JBOSS_HOME/bin/init.d/jboss-as.conf /etc/jboss-as/. 


Copie o jboss-as-standalone.sh para dentro de /etc/init.d/

cp $JBOSS_HOME/bin/init.d/jboss-as-standalone.sh&nbsp;&nbsp; /etc/init.d/jboss-as


Execute o chkconfig para adicioná-lo a configuração:

chkconfig --add jboss-as 


- DataSource: usuário e senha: não deixe exposto o usuário e senha da
 conexão de banco no standalone.xml. Você pode utilizar um 
security-domain com o SecureIdentity, que é um login-module que vem 
dentro do picketbox, que é a biblioteca de segurança do JBoss, e gerar 
uma senha criptografada.

Aqui você tem mais informações sobre o picketbox: http://picketbox.jboss.org/

Crie o security-domain:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;subsystem xmlns="urn:jboss:domain:security:1.1"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;security-domains&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;security-domain name="ExemploDSSecurity" cache-type="default"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;authentication&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;login-module code="SecureIdentity" flag="required"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;module-option name="username" value="dbuser"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;module-option name="password" value="2afa5c8be6f4b2ec"/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/login-module&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/authentication&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/security-domain&gt;

Altere o pool para usar o security-domain criado:

&lt;subsystem xmlns="urn:jboss:domain:datasources:1.1"&gt;&nbsp;&nbsp;&nbsp; &lt;datasources&gt;&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; &lt;datasource jndi-name="java:jboss/datasources/ExemploDS" 
pool-name="ExemploDS" enabled="true" use-java-context="true" 
use-ccm="false"&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;connection-url&gt;.....&lt;/connection-url&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;driver&gt;...&lt;/driver&gt;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;security&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;security-domain&gt;ExemploDSSecurity&lt;/security-domain&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/security&gt;

Para gerar a senha, crie o seguinte script:

$JBOSS_HOME/bin/makepasswd.sh
----------

#!/bin/bashread -s -p "password: " PASS## Build ClassPath for commandCP=CP=${CP}:$JBOSS_HOME/modules/org/picketbox/main/picketbox-4.0.7.Final.jarCP=${CP}:$JBOSS_HOME/modules/org/jboss/logging/main/jboss-logging-3.1.0.GA.jarecho ""java -classpath ${CP} org.picketbox.datasource.security.SecureIdentityLoginModule ${PASS}

------------

Dê a permissão necessária:

chmod +x makepasswd.sh


Execute e ele irá gerar uma senha que você irá substituir no parâmetro do módulo:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;module-option name="password" value="2afa5c8be6f4b2ec"/&gt;


Configurações de Monitoramento 

- JConsole: o JBoss tem um protocolo específico para conexão via JMX, então para conectar via jconsole, você precisa utilizar os pacotes que vem dentro do JBoss.

Em outra máquina com o JBoss, utilize o script abaixo para inicializar o jconsole:

&nbsp;$JBOSS_HOME/bin/jconsole.sh


Utilize a seguinte URL:

service:jmx:remoting-jmx://{host_name}:{port}

A porta padrão para do JBoss é a 9999.

Em outro momento, iremos explicar como utilizar ferramentas específicas como JProfiler, Zorka e Zabbix, AppDynamics para efetuar um monitoramento mais efetivo.

Aqui tem mais informações de como utilizar o jconsole:

https://developer.jboss.org/wiki/UsingJconsoleToConnectToJMXOnAS7&nbsp;

- JBoss Management: para habilitar o bind das interfaces de rede da aplicação de gerenciamento do JBoss para todos IPs disponíveis na máquina, você pode alterar a seguinte configuração:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;interface name="management"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;any-address/&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/interface&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;interface name="public"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;any-address /&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/interface&gt;

Lembre-se de configurar seu firewall para não permitir conexões na porta 9999 fora da sua rede, ela é a porta da interface de management da configuração acima.




Conclusão
&nbsp;Vimos algumas configurações de performance e segurança do JBoss, mas sempre há como melhorar alguns itens, caso você tenha mais algum detalhe que foi esquecido, não deixe de enviar para gente acrescentar aqui.