A slim JBoss Application Server for low resource consumption is essential in development, continuous integration (CI), or other resource-constrained environments. By adjusting key settings, you can reduce memory, CPU, and disk usage while maintaining functionality for testing and development. Here we share practical steps to optimize JBoss EAP or WildFly (the community version) for such scenarios.
Adjust JVM Settings
The Java Virtual Machine (JVM) is the backbone of JBoss. In low-resource environments, minimizing the JVM's memory
footprint is critical. Edit the standalone.conf (or standalone.conf.bat on Windows) file in the bin directory to
configure JVM options.
- Set Heap Size: Use modest heap sizes to limit memory usage. For example, set
-Xms64m -Xmx512mto start with a 64 MB initial heap and a 512 MB maximum heap. This is often sufficient for small applications in development. - Disable Explicit Garbage Collection: Add
-XX:+DisableExplicitGCto prevent unnecessary garbage collection triggered by application code, reducing CPU spikes. - Use a Lightweight Garbage Collector: Opt for the Serial GC (
-XX:+UseSerialGC) in low-memory setups, as it’s simpler and uses less overhead than parallel or concurrent collectors.
Optimize Server Configuration
Edit standalone.xml to strip the server down to what your application actually uses. A few small changes cut memory and CPU use.
- Remove unneeded subsystems: Delete subsystem entries you don't use. For example, remove the EJB entry if there are no EJBs. The
webservicesandmessaging-activemqentries can go too. - Cut logging overhead: Set log levels to
WARNorERROR. This reduces disk I/O and CPU use:
<logger category="org.jboss">
<level name="WARN"/>
</logger>
- Shrink thread pools: In the
iosubsystem, cap the worker threads at a low value. For example:<worker name="default" task-max-threads="10"/>.
Minimize Deployed Applications
Deploy only what you need. Fewer apps means less resource use.
- Keep deployments small: Skip large WAR or EAR files. Test single modules when you can, or use a small web app.
- Use development mode: Start JBoss with
--server-config=standalone-development.xml, or set thedevelopmentprofile instandalone.xml. This loads a lighter setup made for development.
Tune Database Connection Pools
Database connections eat resources. Set smaller pools in standalone.xml: min-pool-size="2" max-pool-size="5" works well for development, where few users connect at once. For testing, use an in-memory database such as H2 instead of PostgreSQL or MySQL.
Disable Unused Services
JBoss ships with services you may not need. Examples include JMX and remote debugging. In locked-down settings, turn them off.
- Disable JMX: Don't need monitoring? Then remove the
jmxsubsystem fromstandalone.xml. - Turn Off Remote Access: Remove the
managementsection fromstandalone.xml. You can also comment it out. This shuts down remote management and the HTTP management endpoints.
Use Lightweight Profiles
WildFly offers predefined profiles like standalone-lean.xml that strip down unnecessary features. Start the server
with this profile using ./standalone.sh --server-config=standalone-lean.xml. For JBoss EAP, create a custom lean
profile by copying standalone.xml and removing unneeded subsystems.
Monitor and Test
After applying changes, monitor resource usage with VisualVM or jstat, and test the server under your typical development or CI workloads. If issues appear, increase heap size or thread pool limits incrementally until performance stabilizes.