Several people have commented that the
TimeAndSizeRollingAppender could, where many instances were configured, launch
many threads. With date roll
enforcement, backup log file scavenging, and backup log file compression all
configured, there could be 3 threads per TASRA instance. That simply didn’t scale. The original design assumption that only one
or two TASRA instances would be configured per application was clearly broken.
I have begun some work to minimise the number of threads
launched where multiple TASRA instances are configured. The first fruits of that have been released
and can be downloaded from www.simonsite.org.uk.
The changes permit an arbitrary number of TASRA instances to
share a single thread for all backup log file scavenging and backup log file
compression tasks. Date roll enforcement
is still carried out on a separate daemon thread, for now.
The benefit is best illustrated with some numbers; taking an
arbitrary 10 TASRA instances as opposed to just one to better illustrate the
effect:
TASRA configuration
|
Daemon thread count per 10 TASRA instances
|
|
20120703-0826 Release
|
20130130-1840 Release
|
|
ScavengeInterval=300000, DateRollEnforced=true, CompressionAlgorithm=ZIP
|
30
|
11
|
ScavengeInterval=300000, DateRollEnforced=false,
CompressionAlgorithm=ZIP
|
20
|
1
|
ScavengeInterval=300000, DateRollEnforced=false,
CompressionAlgorithm=default (not set)
|
10
|
1
|
ScavengeInterval=-1, DateRollEnforced=false, CompressionAlgorithm=default
|
0
|
0
|
By default, all TASRA instances will now share the same
thread. Optionally, m TASRA instances may be configured to use n threads, where m >= n >= 1. To do this, a common named object must be
shared by all TASRA instances that will share the same thread, and distinct
named object(s) for any other TASRA instances that will use different thread(s). The following sample configuration
illustrates two TASRA instances, “appender-1” and “appender-2”, each using its
own thread, “executor-1” or “executor-2”, respectively, in this case for
scavenging and compression tasks:
<appender name="file-appender-1"
class="uk.org.simonsite.log4j.appender.TimeAndSizeRollingAppender">
<param name="File"
value="${tasra.xml.test.log.file.1}" />
<layout class="org.apache.log4j.SimpleLayout"
/>
<param name="CompressionAlgorithm" value="ZIP" />
<logTaskExecutorService class="uk.org.simonsite.log4j.appender.NamedLoggingTaskExecutorService">
<param name="Name" value="executor-1"
/>
</logTaskExecutorService>
</appender>
<appender name="file-appender-2"
class="uk.org.simonsite.log4j.appender.TimeAndSizeRollingAppender">
<param name="File"
value="${tasra.xml.test.log.file.2}" />
<layout class="org.apache.log4j.SimpleLayout"
/>
<param name="CompressionAlgorithm"
value="ZIP" />
<logTaskExecutorService class="uk.org.simonsite.log4j.appender.NamedLoggingTaskExecutorService">
<param name="Name" value="executor-2"
/>
</logTaskExecutorService>
</appender>