Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public class Workload {
*/
public long consumerBacklogSizeGB = 0;

/**
* Producer publish rate (msg/s) to apply during the backlog-drain phase.
* Default -1 means "unset" — producers keep producerRate through the drain
* (original behavior). >= 0 throttles producers for the drain only; 0 is
* floored to ~1 msg/s by Worker.adjustPublishRate (effectively stopped).
*/
public int drainProducerRate = -1;

public int warmupDurationMinutes = 30;
public int sampleRateMillis = 10000;
public int testDurationMinutes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ private void buildAndDrainBacklog(List<String> topics) throws IOException {

log.info("--- Start draining backlog ---");

if (workload.drainProducerRate >= 0) {
log.info("Throttling producers to {} msg/s for backlog drain", workload.drainProducerRate);
worker.adjustPublishRate(workload.drainProducerRate);
}

worker.resumeConsumers();

final long minBacklog = 1000;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.openmessaging.benchmark;

import static org.junit.Assert.assertEquals;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.junit.Test;

public class WorkloadTest {

// Mirror the strict YAML workload mapper used in Benchmark.java.
private static final ObjectMapper MAPPER = new ObjectMapper(new YAMLFactory());

private static final String BASE =
"name: drain-test\n"
+ "topics: 1\n"
+ "partitionsPerTopic: 1\n"
+ "messageSize: 100\n"
+ "producerRate: 1000\n"
+ "testDurationMinutes: 1\n";

@Test
public void drainProducerRateDefaultsToUnset() throws Exception {
Workload w = MAPPER.readValue(BASE, Workload.class);
assertEquals(-1, w.drainProducerRate);
}

@Test
public void drainProducerRateParsesWhenPresent() throws Exception {
Workload w = MAPPER.readValue(BASE + "drainProducerRate: 5000\n", Workload.class);
assertEquals(5000, w.drainProducerRate);
}
}
Loading