Status

Current state: "Under Discussion"

Discussion thread: DISCUSS KIP-1052 

JIRA


Motivation

When analyzing performance of long-running applications like Kafka, it is useful to separate the applications lifecycle into phases such as initialization, steady-state, transient-states due to changes in system load, and shut-down. Of these states, steady-state and transient-response-states are of special interest since these represent the normal operating states of the application. To measure the steady state performance of Kafka, one would typically set up a cluster, then create topics and proceed to measure the performance of various load points on their cluster. 
 
A problem arises, however, when using the producer performance test to measure steady-state performance. In our observations, the producer performance test has high latency during the initialization phase as producers are coming online and brokers are beginning to exchange replicated messages. Currently, all measurements with the producer performance test will include measurements of the high latency that occurs during startup in any evaluation of steady-state performance, especially when test durations are not sufficiently long. 

For example, if we observe high startup-related latency that lasts for 30 seconds into the producer performance test (about 6 prints of the 5-second window), we would need to collect at least 3000 seconds (about 50 minutes) of data for the startup latency to represent less than 1% of the latency (p99) and not affect our analysis of the steady-state latency.  This 3000-second test is still problematic in the evaluation of steady-state, however, since we cannot guarantee that high startup latency will be completely resolved by the 30-second (<1%) mark, causing even these long tests to have unstable results.

Consider, however, an example of testing that seeks to understand steady state performance. One test runs for 5 minutes compared to a test with the same configuration that runs for 50 minutes. We would observe the 5-minute test has a p99 latency higher than the 50-minute test even though the steady state latency is the same. Thus, for a user to accurately measure Kafka steady-state performance, they must gather very long tests to get a “clean” p99, uncontaminated by startup latency. 
 
When analyzing steady-state latency in Kafka, it is desirable to not include startup-latency in your measurements.  Therefore, we propose adding a mechanism to optionally separate the statistics for data gathered on the first N records during warmup from those measurements collected during steady-state measurements.

Public Interfaces

No public interfaces are affected. An option such as "--warmup-records" should be added to the producer performance test to request that the initial records sent in a test be gathered into a separate Stats object from the steady-state records. The default value for warmup records would be 0 to ensure the continued normal operation of the producer perf test.  Only the analysis and reporting of the producer performance test may change but would require the user to opt-in and add the warmup-records parameter.

Proposed Changes

We propose a modification of the producer performance test to add a command line argument for "warmup records". The total number of records for the test must be strictly greater than the number of warmup records or the test should throw an error. Negative values for warmup records should also throw an error.  A value of "0" for warmup records should have the test behave identically to not specifying the parameter. Messages sent during warmup would be accumulated in a separate Stats object from the "post-warmup" records that make up the steady state portion of the test.

For reporting, there are two options that seem to come down to user preference. Both options have two summary lines, one containing warmup data and the other being purely steady state results.  In the first option, the warmup measurements could be summarized independently in a "warmup-only summary", followed by a summary of the steady state performance. With this option, the user would be able to understand performance during the warmup as a distinct phase of the measurement, then compare that to the steady state performance. The second option would be for the first summary print to combine the warmup data with the post-warmup latency measurements for a "full test summary" that is, effectively, the same output that the test currently has. This option allows users to compare what the test would have reported in the absence of a warmup and compare that to steady state performance. The first approach identifies warmup as a distinct phase, the second might be a preferred option to allow users to transition from their traditional use of the benchmark to the warmup-enabled version of the benchmark. This second option is our preferred implementation, but the behavior could be toggled with another command line option such as '--combined-summary'.

Regarding the process of choosing a warmup duration, the warmup records should comprise the time required for producers to startup, allocate resources, connect to the brokers, then reach steady state performance. Although a one-minute warmup is common in Java performance analysis, a simple process for more accurately determining the warmup time of a given topology would be to run the test without a warmup first. The resulting time-series of the producer performance test output would typically have high latency during the first few windows of output (at 5 s per window). The minimum warmup records could then be chosen to be the number of records sent once producer latency reaches an acceptable steady state. Although the producer performance test output should provide sufficient information to set a warmup, additional data sources such as JMX:producer:record-queue-time, JMX:producer:request-latency-avg, and the various broker queue-time metrics could be consulted to help precisely determine when steady state has been achieved. Since the warmup data will be reported separately from the desired steady state results, and running longer warmups should not impact steady state performance, it's always good practice to run a warmup for slightly longer than is deemed necessary to guarantee records from the warmup have been processed and ensure steady state operation.

As of this writing, the producer performance test seeks to meet its target throughput by evaluating the total time elapsed and total records sent since the producer started up. This could lead to higher steady-state producer throughput than expected if the producer is sending slowly during the warmup phase. This behavior may be a desired artifact of the producer's operation in some test cases, but could cause confusion, particularly in cases where warmups and test durations are short. In general, once the producer has reached its intended steady state throughput and does not vary too much between print windows of the test, that can be considered a sufficient warmup.

Compatibility, Deprecation, and Migration Plan

The proposed modification to the producer performance test would not interfere with the previous methods and command lines used to measure producer performance. Those mechanisms would not be deprecated, but the users would have a choice to either include Kafka warmup in their results or avoid the warmup latency and focus on steady-state performance.

Rejected Alternatives

.