JBoss AS Storage Hints
- Published: 22 October 2011
A default JBoss AS installation can take from 70-80 MB (JBoss AS 7) up to 200 Mb (JBoss AS 5) when unpacked. This amount of disk space can however grow up a lot if you let the application server breed without control. Here's what you must know if you are administering a JBoss AS:
The application server uses the disk space in several ways. The most important areas are:
Application server logs dir
Application server temp dir
Application server data dir
JBoss Web server work dir
Let's see each one and how to avoid your installation to each all of your disk space.
Controlling Application Server Logs
Server log files are written by default in the following folders:
|JBoss AS 4-5-6||JBoss AS 7|
In order to avoid that your logs take too much space you need to use a RollingFileAppender which automatically Rotates logs deleting the ones which are older then a certain index. They key properties are:
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="5" />
The value tells log4j.xml to rotate logs which are over 100KB and to keep up 50 5 rotated log files around.
Controlling Application Server temp space
The temp folder is used by the application server in various ways. For example SFSB are passivated in the folder server/<your config>/tmp/sessions. Another element which uses extensively this folder is the VFS (Virtual File System) which uses the temp folder to cache copies of your deployment units. This can be useful for speeding the performance of your application server but can let your server distribution grow too much. It's quite common to see a typical development application server reaching up to 30-40 GB of disk space just in the tmp folder!
You can use several switches to mitigate the impact of VFS on your file system. The most drastic one is:
-Djboss.vfs.forceNoCopy=true and -Djboss.vfs.forceCopy=false
which prevents caching at all deployment units in the temp folder. Many users however reported a performance decrease when using this setting. You could rather experiment the following settings which evict files which are older than 24 minutes:
Controlling Application Server data dir
The data dir is used by the application server in several ways: for example Hypersonic DB by default stores db files in the server/<your config>/data/hypersonic. They are plain text files which contain the database configuration and the DDL and table data.
Then WSDL for your web services are stored and versioned in the folder server/<yourconfig>/data/wsdl.
Next, the transaction logs which are stored in the folder server/<your config>/data/tx-object-store.
Most of the time you can safely remove the content of this folder when the server restarts; however consider saving the content of the data/hypersonic folder if you are developing with this database.
Controlling JBoss Web server work dir
The work directory, as its name suggests, is where JBoss Web server writes any files that it needs during run time, such as the generated servlet code for JSPs, the class files for the same after they are compiled, the serialized sessions during restarts or shutdowns (SESSIONS.ser).
This folder is quite useful if you are getting an exception on the JSP, because the exception line number is not the actual JSP line number but the compiled JSP line number. The location of the work folder is different depending on the server release:
|JBoss AS 4-5-6||JBoss AS 7|
You should keep copies of your web server context for performance reasons, otherwise the web server will recompile again your JSPs. However you should consider evicting the web contexts which are not used anymore. Also, cleaning up this folder can be used when you suspect that you are getting a stale copy of your web page from the browser.
Cleaning up all application server storage
If you want a fresh new environment for your application server you can use raw operating system commands to empty the storage used by the application server:
rem Windows Users
rmdir /s /q c:\apps\jboss-5.1.0.ga\server\default\tmp
rmdir /s /q c:\apps\jboss-5.1.0.ga\server\default\work
rmdir /s /q c:\apps\jboss-5.1.0.ga\server\default\log
# Unix users
rm -fr /home/jboss/server/default/tmp
rm -fr /home/jboss/server/default/work
rm -fr /home/jboss/server/default/log