CINXE.COM
Commons Performance - Apache Commons Performance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Commons Performance - Apache Commons Performance</title> <style type="text/css" media="all"> @import url("./css/maven-base.css"); @import url("./css/maven-theme.css"); @import url("./css/site.css"); </style> <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" /> <meta name="author" content="Apache Commons team" /> </head> <body class="composite"> <div id="banner"> <a href="../../../" id="bannerLeft"> <img src="../../../images/logo.png" alt="" /> </a> <a href="index.html" id="bannerRight"> <img src="images/performance-logo.png" alt="" /> </a> <div class="clear"> <hr/> </div> </div> <div id="breadcrumbs"> <div class="xleft"> Last Published: 18 September 2010 | Version: 0.1-SNAPSHOT </div> <div class="xright"> <a href="http://www.apachecon.com/" class="externalLink">ApacheCon</a> | <a href="http://www.apache.org" class="externalLink">Apache</a> | <a href="../../../">Commons</a> | <a href="../../../sandbox/">Sandbox</a> </div> <div class="clear"> <hr/> </div> </div> <div id="leftColumn"> <div id="navcolumn"> <h5>Commons Performance</h5> <ul> <li class="none"> <strong>Overview</strong> </li> </ul> <h5>Development</h5> <ul> <li class="none"> <a href="mail-lists.html">Mailing Lists</a> </li> <li class="none"> <a href="issue-tracking.html">Issue Tracking</a> </li> <li class="none"> <a href="source-repository.html">Source Repository</a> </li> <li class="none"> <a href="apidocs/index.html">Javadoc (latest)</a> </li> <li class="none"> <a href="http://people.apache.org/builds/commons/nightly/performance" class="externalLink">Nightly builds</a> </li> </ul> <h5>Project Documentation</h5> <ul> <li class="expanded"> <a href="project-info.html">Project Information</a> <ul> <li class="none"> <strong>About</strong> </li> <li class="none"> <a href="integration.html">Continuous Integration</a> </li> <li class="none"> <a href="dependencies.html">Dependencies</a> </li> <li class="none"> <a href="issue-tracking.html">Issue Tracking</a> </li> <li class="none"> <a href="mail-lists.html">Mailing Lists</a> </li> <li class="none"> <a href="plugin-management.html">Plugin Management</a> </li> <li class="none"> <a href="license.html">Project License</a> </li> <li class="none"> <a href="plugins.html">Project Plugins</a> </li> <li class="none"> <a href="project-summary.html">Project Summary</a> </li> <li class="none"> <a href="team-list.html">Project Team</a> </li> <li class="none"> <a href="source-repository.html">Source Repository</a> </li> </ul> </li> <li class="collapsed"> <a href="project-reports.html">Project Reports</a> </li> </ul> <h5>Commons</h5> <ul> <li class="none"> <a href="../../../">Home</a> </li> <li class="collapsed"> <a href="../../../components.html">Components</a> </li> <li class="collapsed"> <a href="../../../sandbox/index.html">Sandbox</a> </li> <li class="collapsed"> <a href="../../../dormant/index.html">Dormant</a> </li> <li class="none"> <a href="../../../volunteering.html">Volunteering</a> </li> <li class="none"> <a href="../../../patches.html">Contributing Patches</a> </li> <li class="none"> <a href="../../../building.html">Building Components</a> </li> <li class="none"> <a href="../../../releases/index.html">Releasing Components</a> </li> <li class="none"> <a href="http://wiki.apache.org/commons/FrontPage" class="externalLink">Wiki</a> </li> </ul> <h5>ASF</h5> <ul> <li class="none"> <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a> </li> <li class="none"> <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a> </li> </ul> <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"> <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img> </a> </div> </div> <div id="bodyColumn"> <div id="contentBox"> <div class="section"><h2>Overview</h2> <p>Commons performance is a small framework for developing configurable microbenchmark clients. The "framework" consists of two abstract classes, "ClientThread" and "LoadGenerator." ClientThreads generate requests with configurable inter-arrival times (following various load generation profiles) and gather response time statistics. LoadGenerators spawn ClientThreads and aggregate statistics across threads. Configuration is loaded at the beginning of a run from an XML configuration file.</p> <p>Concrete implementations are provided for commons pool and commons DBCP. A primitive http load generator is also included as another sample LoadGenerator. See the class javadoc for <a href="./apidocs/org/apache/commons/performance/ClientThread.html">ClientThread</a> and <a href="./apidocs/org/apache/commons/performance/LoadGenerator.html">LoadGenerator</a> for more information on how to extend these classes to develop other microbenchmark clients. The Pool, DBCP, and HTTP implementations (in the <a href="./apidocs/org/apache/commons/performance/pool/package-summary.html">pool</a>, <a href="./apidocs/org/apache/commons/performance/dbcp/package-summary.html">dbcp</a> <a href="./apidocs/org/apache/commons/performance/http/package-summary.html">http</a> packages, respectively) provide examples of how to do this.</p> <p><a href="#Compiling and running the DBCP, pool and http tests">Pool, DBCP and http tests</a> | <a href="#Configuration">Configuration</a> | <a href="#Statistics">Statistics</a> | <a href="#Development tasks">Development tasks</a></p> </div> <div class="section"><h2><a name="Compiling_and_running_the_DBCP_pool_and_http_tests">Compiling and running the DBCP, pool and http tests</a></h2> <dl><dt>DBCP</dt> <dd>To run the dbcp tests:<ol type="1"><li>Edit the configuration in src/dbcp/config-dbcp.xml</li> <li>Make sure the configured database is running and accepting connections</li> <li>Specify the path to the jdbc driver jar and the dbcp and pool jars you want to test with in src/dbcp/build.properties </li> <li>Edit src/dbcp/logging.properties to provide a real path for the log file</li> <li>From src/dbcp, execute:<div class="source"><pre>ant</pre> </div> </li> </ol> <p>The first time you run against a configured database, a table with 10000 rows will be created and populated with random data.</p> </dd> <dt>Pool</dt> <dd>To run the pool tests:<ol type="1"><li>Edit the configuration in src/pool/config-pool.xml</li> <li>Edit src/pool/logging.properties to provide a real path for the log file</li> <li>Specify the path to pool jar you want to test with in src/pool/build.properties</li> <li>From src/pool, execute:<div class="source"><pre>ant</pre> </div> </li> </ol> </dd> <dt>http</dt> <dd>To run the http tests:<ol type="1"><li>Edit the configuration in src/http/config-http.xml</li> <li>Edit src/http/logging.properties to provide a real path for the log file</li> <li>from src/http, execute:<div class="source"><pre>ant</pre> </div> </li> </ol> </dd> </dl> </div> <div class="section"><h2><a name="Configuration">Configuration</a></h2> <p>Base configuration for all microbenchmark implementations using Commons Performance is included in the "run" section of the XML configuration file. The base parameters determine how many request threads are spawned, how many iterations each performs and how inter-arrival times (times between requests from each thread) are computed. A minimal configuration file would contain only the "run" element nested in the "configuration" root element. Configurations for the DBCP and Pool tests include additional parameters specified in other elements. </p> <div class="section"><h3>Base Configuration</h3> <table class="bodyTable"><tbody><tr class="a"><td align="left"><b>XML path to parameter</b></td> <td align="left"><b>What the parameter means</b></td> <td align="left"><b>Sample setting</b></td> </tr> <tr class="b"><td align="left">configuration/run/iterations</td> <td align="left">Number of iterations for each client thread</td> <td align="left">100 - each thread executes 100 requests.</td> </tr> <tr class="a"><td align="left">configuration/run/clients</td> <td align="left">Number of ClientThreads</td> <td align="left">10 - 10 client threads run concurrently</td> </tr> <tr class="b"><td align="left">configuration/run/delay-min</td> <td align="left">Minimum time between client requests per thread</td> <td align="left">250 - peak load is 4 client requests per thread per second</td> </tr> <tr class="a"><td align="left">configuration/run/delay-max</td> <td align="left">Maximum time between client requests per thread</td> <td align="left">500 - minimum load is 2 requests per client per second</td> </tr> <tr class="b"><td align="left">configuration/run/sigma</td> <td align="left">Standard deviation of inter-arrival times (only used when delayType is "random"</td> <td align="left">10 standard deviation of inter-arrival times is 10ms.</td> </tr> <tr class="a"><td align="left">configuration/run/delay-type</td> <td align="left">Whether inter-arrival times are random or deterministic. "constant" means deterministic, "gaussian" or "poisson" means random, following the given distribution, with mean determined by rampup or cycle state</td> <td align="left">"constant" - if cycle-type is "none", clients will fire requests at a constant rate of one request every min-delay ms (after ramping up if rampTime is positive.</td> </tr> <tr class="b"><td align="left">configuration/run/ramp-type</td> <td align="left">"linear" means that load ramps up or down linearly, "random" means it takes random jumps in the direction determined by cycle state</td> <td align="left">"linear" - if cycle-type is "none" and delay-type is constant, clients will ramp up linearly to delay-min interarrival times and then fire requests at a constant rate of one request every min-delay ms.</td> </tr> <tr class="a"><td align="left">configuration/run/ramp-period</td> <td align="left">The amount of time (in milliseconds) that a client spends ramping up or down</td> <td align="left">10000 - client threads take 10 seconds to ramp up from delay-min at the beginning of the run and if the cycle-type is "oscillating," the same amount of time to ramp back down to delay-max after sustaining peak load for peak-period</td> </tr> <tr class="b"><td align="left">configuration/run/peak-period</td> <td align="left">The amount of time (in milliseconds) that a client spends at peak load (only used if cycle-type is "oscillating"</td> <td align="left">20000 - client threads sustain peak load (one request per delay-min milliseconds) for 20 seconds each cycle</td> </tr> <tr class="a"><td align="left">configuration/run/trough-period</td> <td align="left">The amount of time (in milliseconds) that a client spends at minimum load (only used if cycle-type is "oscillating"</td> <td align="left">10000 - client threads stay at minimum load (one request per delay-max milliseconds) for 20 seconds each cycle</td> </tr> <tr class="b"><td align="left">configuration/run/cycle-type</td> <td align="left">"oscillating" means that load follows a cycle, starting at delay-max, ramping up to delay-min over ramp-period, staying at peak load for peak-period, then ramping down again over ramp-period, staying at delay-max for trough-period, and then repeating</td> <td align="left">"none" - clients ramp up at the beginning of the run to delay-min and stay at that level throughout the run</td> </tr> </tbody> </table> </div> <div class="section"><h3>Pool configuration (used by both Pool and DBCP)</h3> <table class="bodyTable"><tbody><tr class="a"><td align="left"><b>XML path to parameter</b></td> <td align="left"><b>What the parameter means</b></td> <td align="left"><b>Sample setting</b></td> </tr> <tr class="b"><td align="left">configuration/pool/type</td> <td align="left">Type of pool to use</td> <td align="left">GenericObjectPool - use a GenericObjectPool as the underlying object pool. The only alternative currently is "AbandonedObjectPool"</td> </tr> <tr class="a"><td align="left">configuration/pool/max-active</td> <td align="left">The commons pool maxActive setting - the maximum number of object instances that can be checked out from the pool at a given time</td> <td align="left">10 - at most 10 object instances can be in use by clients at a given time</td> </tr> <tr class="b"><td align="left">configuration/pool/max-idle</td> <td align="left">The commons pool maxIdle setting - the maximum number of object instances that can be idle in the pool at a given time</td> <td align="left">5 - at most 5 object instances can be sitting idle in the pool at a given time</td> </tr> <tr class="a"><td align="left">configuration/pool/min-idle</td> <td align="left">The commons pool minIdle setting - the minumum number of object instances that must be available (idle) in the pool at a given time</td> <td align="left">4 - there must always be 4 idle object instances waiting for clients in the pool</td> </tr> <tr class="b"><td align="left">configuration/pool/max-wait</td> <td align="left">The commons pool maxWait setting - the maximum amount of time (in milliseconds) that a client will wait for an instance to become available in the pool before throwing an exception. This parameter is only relevant when exhausted-action is "block"</td> <td align="left">-1 - a negative value means wait indefinitely</td> </tr> <tr class="a"><td align="left">configuration/pool/exhausted-action</td> <td align="left">The commons pool exhaustedAction setting - determines what the pool does when it gets a request for an object instance and there are no idle instances available. Must be one of "block" (client waits) "fail" (throw exception) or "grow" (create a new object instance)</td> <td align="left">block - client will wait until an instance becomes available or max-wait is exceeded</td> </tr> <tr class="b"><td align="left">configuration/pool/test-on-borrow</td> <td align="left">The commons pool testOnBorrow setting - determines whether or not the pool invokes the object factory's validate method on object instances borrowed from the pool before giving them out to clients. Must be either "true" or "false"</td> <td align="left">false - object instances are not validated when they are borrowed from the pool</td> </tr> <tr class="a"><td align="left">configuration/pool/test-on-return</td> <td align="left">The commons pool testOnReturn setting - determines whether or not the pool invokes the object factory's validate method on object instances when they are returned to the pool. Must be either "true" or "false"</td> <td align="left">true - object instances are validated before being returned to the pool.</td> </tr> <tr class="b"><td align="left">configuration/pool/time-between-evictions</td> <td align="left">The commons pool timeBetweenEvictions setting - the amount of time (in milliseconds) between runs of the idle object evictor. A negative value disables idle object eviction.</td> <td align="left">30000 - the idle object evictor runs every 30 seconds</td> </tr> <tr class="a"><td align="left">configuration/pool/tests-per-eviction</td> <td align="left">The commons pool testsPerEviction setting - the number of objects in the pool checked for expiry on each evictor run</td> <td align="left">10 - the evictor will examine up to 10 objects in the pool on each eviction run</td> </tr> <tr class="b"><td align="left">configuration/pool/idle-timeout</td> <td align="left">The commons pool idleTimeout setting - the amount of time that an instance can remain idle in the pool before becoming eligible for eviction. A negative value means instances do not expire.</td> <td align="left">20000 - instances become eligible for eviction when they have been sitting idle in the pool for more than 20 seconds</td> </tr> <tr class="a"><td align="left">configuration/pool/test-while-idle</td> <td align="left">The commons pool testWhileIdle setting - determines whether or not the idle object evictor validates objects that it examines during its runs. Must be "true" or "false"</td> <td align="left">true - each time the idle object evictor runs, it invokes the factory validate method on the idle objects that it examines during the run</td> </tr> <tr class="b"><td align="left">configuration/abandoned-config/log-abandoned</td> <td align="left">Determines whether or not abandoned object discovery events are logged. Only meaningful if pool type is AbandonedObjectPool. Must be "true" or "false"</td> <td align="left">true - each time an abandoned object is found, a stack trace showing its origin is logged</td> </tr> <tr class="a"><td align="left">configuration/abandoned-config/remove-abandoned</td> <td align="left">Determines whether or not abandoned objects are removed when found. Only meaningful if pool type is AbandonedObjectPool. Must be "true" or "false"</td> <td align="left">false - abandoned objects are not removed</td> </tr> <tr class="b"><td align="left">configuration/abandoned-config/abandoned-timeout</td> <td align="left">Inactivity timeout used to determine when an object is deemed to be abandoned.</td> <td align="left">50000 - objects not used for more than 50 seconds are considered abandoned.</td> </tr> </tbody> </table> </div> <div class="section"><h3>Additional configuration for DBCP</h3> <table class="bodyTable"><tbody><tr class="a"><td align="left"><b>XML path to parameter</b></td> <td align="left"><b>What the parameter means</b></td> <td align="left"><b>Sample setting</b></td> </tr> <tr class="b"><td align="left">configuration/database/driver</td> <td align="left">The fully qualified class name of the jdbc driver to use. Must be available in the classpath.</td> <td align="left">com.mysql.jdbc.Driver - use mysql jdbc driver</td> </tr> <tr class="a"><td align="left">configuration/database/url</td> <td align="left">The jdbc connection url</td> <td align="left">jdbc:mysql:///test - use the test mysql database on the local host</td> </tr> <tr class="b"><td align="left">configuration/database/username</td> <td align="left">The jdbc connection username</td> <td align="left">sa - all connections are created using "sa" database login id</td> </tr> <tr class="a"><td align="left">configuration/database/password</td> <td align="left">The jdbc connection password</td> <td align="left">'' (empty element) - no password</td> </tr> <tr class="b"><td align="left">configuration/database/query-type</td> <td align="left">The type of query used by the tests. Admissable values are "integerIndexed", "integerScan", or "textScan". The first part is the type of column used in the SELECT statement and the second determines whether or not the column is indexed</td> <td align="left">integerScan - generate queries that select on values from a non-indexed integer column</td> </tr> <tr class="a"><td align="left">configuration/connection-factory/type</td> <td align="left">The type of database connection factory to use. Admissable values are "Driver" or "DriverManager".</td> <td align="left">DriverManager - use DriverManagerConnectionFactory</td> </tr> <tr class="b"><td align="left">configuration/connection-factory/auto-commit</td> <td align="left">The autocommit property assigned to connections returned by the pool. Must be "true" or "false"</td> <td align="left">true - connections are set to autocommit transactions</td> </tr> <tr class="a"><td align="left">configuration/connection-factory/read-only</td> <td align="left">The readonly property assigned to connections returned by the pool. Must be "true" or "false"</td> <td align="left">false - connections are read/write</td> </tr> <tr class="b"><td align="left">configuration/connection-factory/validation-query</td> <td align="left">The validation query used to test connections. Only meaningful when one of test-on-borrow, test-on-return, test-while-idle is true.</td> <td align="left">"SELECT * FROM TEST" - this query is executed to validate connections. If it returns at least one row, validation succeeds.</td> </tr> <tr class="a"><td align="left">configuration/poolable-connection-factory/type</td> <td align="left">The PoolableConnectionFactory type. Currently only "PoolableConnectionFactory" is supported</td> <td align="left">PoolableConnectionFactory - only valid setting</td> </tr> <tr class="b"><td align="left">configuration/poolable-connection-factory/pool-prepared-statements</td> <td align="left">Whether or not prepared statement pooling is turned on. Must be either "true" or "false"</td> <td align="left">true - prepared statements are pooled</td> </tr> <tr class="a"><td align="left">configuration/poolable-connection-factory/max-open-statements</td> <td align="left">When pool-prepared-statements is true, this setting determines the maximum number or pooled prepared statements that can be open at a given time</td> <td align="left">10 - at most 10 prepared statements can be open at the same time</td> </tr> </tbody> </table> </div> <div class="section"><h3>Configuration for http</h3> <table class="bodyTable"><tbody><tr class="b"><td align="left"><b>XML path to parameter</b></td> <td align="left"><b>What the parameter means</b></td> <td align="left"><b>Sample setting</b></td> </tr> <tr class="a"><td align="left">configuration/http/url</td> <td align="left">url of resource to test</td> <td align="left">http://localhost/index.html</td> </tr> <tr class="b"><td align="left">configuration/http/method</td> <td align="left">http method -GET or POST</td> <td align="left">GET</td> </tr> <tr class="a"><td align="left">configuration/http/socket-timeout</td> <td align="left">http socket connection timeout in milliseconds</td> <td align="left">20000 - timeout after 20 seconds</td> </tr> <tr class="b"><td align="left">configuration/http/success-key</td> <td align="left">string to look for in http response indicating success</td> <td align="left">'successful' - threads throw HttpException if this string is not found in the response</td> </tr> </tbody> </table> </div> </div> <div class="section"><h2><a name="Statistics">Statistics</a></h2> <p>Runs consist of client threads submitting requests in a loop, with configurable delays in between. Statistics on latency of the core request operation are gathered by thread and overall. The "number of misses" reported per thread is the number of times that the request operation itself took longer than the presribed interarrival time for the thread (e.g. the thread is supposed to send one request each 100ms, but it has to wait 150ms for a response). If the number of misses is a significant percentage of the number of iterations, you should consider increasing the number of service nodes (pool maxActive) or decreasing the delay-min / delay-max.</p> </div> <div class="section"><h2><a name="Development_tasks">Development tasks</a></h2> <ol type="1"><li>Property representation and management is poor. Configuration objects should be defined and Digester should create and populate configuration beans.</li> <li>More pool types and more datasource / connection pool types should be supported.</li> <li>WaiterFactory should support stochastic latencies for lifecycle methods similar to ClientThread.nextDelay. Probably nextDelay belongs in a separate latency generation class. </li> <li>TESTS!!! Need more tests.</li> </ol> </div> </div> </div> <div class="clear"> <hr/> </div> <div id="footer"> <div class="xright">© 2007-2010 The Apache Software Foundation </div> <div class="clear"> <hr/> </div> </div> </body> </html>