You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by zi...@apache.org on 2026/10/15 12:24:04 UTC

(pulsar) branch master updated: [improve][test] Add Shared subscriptions and alert fan-out scenarios to the performance tests (#26922)

This is an automated email from the ASF dual-hosted git repository.

nodece pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f5de2b6ca62 [improve][test] Add Shared subscriptions and alert fan-out scenarios to the performance tests (#26922)
3f5de2b6ca62 is described below

commit 3f5de2b6ca62b3fc8ba23bb670121c2237e42003
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Thu Oct 15 05:23:56 2026 -0700

    [improve][test] Add Shared subscriptions and alert fan-out scenarios to the performance tests (#26922)
---
 tests/performance/README.md                        | 13 ++--
 .../pulsar/tests/performance/report/RunReport.java | 14 ++++-
 .../tests/performance/report/RunReportTest.java    |  9 +++
 tests/performance/scenarios/README.md              |  9 ++-
 tests/performance/scenarios/docs/iot-telemetry.md  | 27 +++++++--
 .../scenarios/iot-alerts-fanout-max-rate.yaml      | 36 +++++++++++
 tests/performance/scenarios/iot-alerts-fanout.yaml | 46 ++++++++++++++
 tests/performance/scenarios/iot-alerts-sites.yaml  | 40 +++++++++++++
 .../performance/scenarios/iot-telemetry-base.yaml  |  5 +-
 .../performance/tools/DeviceSequenceTracker.java   | 18 +++++-
 .../tests/performance/tools/IotScenario.java       | 70 +++++++++++++++++++---
 .../tests/performance/tools/TelemetryConsumer.java | 22 +++----
 .../tests/performance/tools/TelemetryProducer.java | 15 ++++-
 .../tools/DeviceSequenceTrackerTest.java           | 55 ++++++++++++++++-
 .../tests/performance/tools/IotScenarioTest.java   | 41 +++++++++++++
 15 files changed, 376 insertions(+), 44 deletions(-)

diff --git a/tests/performance/README.md b/tests/performance/README.md
index 466b80aa7243..75d2802bf7f9 100644
--- a/tests/performance/README.md
+++ b/tests/performance/README.md
@@ -50,9 +50,9 @@ of real-world deployment. A run shows how Pulsar performs for it, and whether th
 Simulating a domain keeps the tests from becoming synthetic. A synthetic benchmark, such as a `pulsar-perf` producer
 and consumer pair, measures one path through Pulsar under conditions that real deployments seldom have, so an
 improvement in its results doesn't directly carry over to real-world use. A real deployment uses many features at
-the same time, such as many producers and topics, keyed messages, batching, deduplication, Key_Shared subscriptions
-and clients that restart, and it relies on delivery guarantees such as ordering. A simulated use case exercises the
-same combination, so that:
+the same time, such as many producers and topics, keyed messages, batching, deduplication, Key_Shared and Shared
+subscriptions and clients that restart, and it relies on delivery guarantees such as ordering. A simulated use case
+exercises the same combination, so that:
 
 - an improvement measured in a scenario is likely to show in the deployments that the scenario maps to, and
   bottlenecks that only appear when the features interact show up in the tests too
@@ -90,13 +90,14 @@ the run report are written for the IoT domain.
 | Telemetry message | A message with the device ID, the device's sequence number and the send time, `payload.size` bytes long |
 | Gateway | A Pulsar client in the gateways' container, with a producer named `iot-gateway-<gateway>-topic-<topic>` for each topic. `gateways.count` sets the number of gateways; their clients share I/O threads and memory, as the clients of one process can since PIP-234 |
 | Topics | `topics.count` topics; a device's messages always go to the same topic, the device ID modulo `topics.count` |
-| Application | A Key_Shared subscription on every topic, named `iot-application-<index>`, in the applications' container, which runs every application as the gateways' container runs every gateway. `applications.count` sets the number of applications; they differ only in their subscription |
+| Application | A subscription on every topic, Key_Shared unless `applications.subscriptionType` sets Shared or Failover, named `iot-application-<index>`, in the applications' container, which runs every application as the gateways' container runs every gateway. `applications.count` sets the number of applications; they differ only in their subscription |
 | Pod | A Pulsar client in the applications' container, with a consumer of the application's subscription, named `iot-application-<index>-pod-<pod>`. `applications.podsPerApplication` sets the number of pods per application; the clients of every application's pods share I/O threads and memory, as the gateways' clients do |
 
 - The gateways send each message from a random device through a random gateway, at `rate` messages per second, or as
   fast as they can when the rate is 0. It keeps one message per device in flight, as a device waits for its message to
-  be acknowledged, so that a device's messages reach Pulsar in order even through different gateways. The producers
-  batch messages by key, and the broker deduplicates them by producer name and sequence ID.
+  be acknowledged, so that a device's messages reach Pulsar in order even through different gateways. With Key_Shared
+  subscriptions the producers batch messages by key, and otherwise with the default batcher; the broker deduplicates
+  them by producer name and sequence ID.
 - `behaviors.podRestarts` restarts some of each application's pods periodically, which moves devices between the pods
   mid-stream.
 - Each application tracks the sequence of every device: it counts ordering violations, invalid messages and
diff --git a/tests/performance/report-tool/src/main/java/org/apache/pulsar/tests/performance/report/RunReport.java b/tests/performance/report-tool/src/main/java/org/apache/pulsar/tests/performance/report/RunReport.java
index 037017c32db8..b7ea62045c5a 100644
--- a/tests/performance/report-tool/src/main/java/org/apache/pulsar/tests/performance/report/RunReport.java
+++ b/tests/performance/report-tool/src/main/java/org/apache/pulsar/tests/performance/report/RunReport.java
@@ -433,15 +433,14 @@ public final class RunReport {
                         + workload.path("topics").path("count").asInt() + " topic(s)"))
                 .append(row("Applications", workload.path("applications").path("count").asInt() + " × "
                         + workload.path("applications").path("podsPerApplication").asInt()
-                        + " pods, Key_Shared"))
+                        + " pods, " + workload.path("applications").path("subscriptionType").asText("Key_Shared")))
                 .append(row("Messages", String.format(Locale.ROOT, "%,d measured, %,d warmup",
                         messageCount(producer, "measurementMessages",
                                 workload.path("measurement").path("messages").asLong()),
                         messageCount(producer, "warmupMessages", workload.path("warmup").path("messages").asLong()
                                 * Math.max(1, workload.path("warmup").path("rounds").asInt())))))
                 .append(row("Payload", workload.path("payload").path("size").asInt() + " bytes, batching "
-                        + (workload.path("gateways").path("producer").path("batchingEnabled").asBoolean()
-                        ? "on" : "off")))
+                        + batching(workload.path("gateways").path("producer"))))
                 .append(row("Rate limit", workload.path("rate").asLong() > 0
                         ? String.format(Locale.ROOT, "%,d msg/s", workload.path("rate").asLong()) : "none"));
         if (host != null) {
@@ -1501,6 +1500,15 @@ public final class RunReport {
         return producer.has(field) ? producer.path(field).asLong() : configured;
     }
 
+    /** Whether the gateways batch, with the batching delay when the scenario sets one. */
+    static String batching(JsonNode producerSettings) {
+        if (!producerSettings.path("batchingEnabled").asBoolean()) {
+            return "off";
+        }
+        JsonNode delay = producerSettings.path("batchingMaxPublishDelayMillis");
+        return delay.isNumber() ? "on, " + delay.asInt() + " ms delay" : "on";
+    }
+
     /**
      * Reads {@code topic-stats.csv} into per-round published and dispatched rates and backlogs. The dispatched rates
      * and the backlogs are those of each subscription, summed over its topics: an application consumes all of its
diff --git a/tests/performance/report-tool/src/test/java/org/apache/pulsar/tests/performance/report/RunReportTest.java b/tests/performance/report-tool/src/test/java/org/apache/pulsar/tests/performance/report/RunReportTest.java
index 6e76adb2753e..9442fb03127a 100644
--- a/tests/performance/report-tool/src/test/java/org/apache/pulsar/tests/performance/report/RunReportTest.java
+++ b/tests/performance/report-tool/src/test/java/org/apache/pulsar/tests/performance/report/RunReportTest.java
@@ -64,6 +64,15 @@ public class RunReportTest {
         }
     }
 
+    @Test
+    public void describesTheGatewaysBatching() throws Exception {
+        assertThat(RunReport.batching(mapper.readTree("{\"batchingEnabled\": false}"))).isEqualTo("off");
+        assertThat(RunReport.batching(mapper.readTree("{\"batchingEnabled\": true}"))).isEqualTo("on");
+        assertThat(RunReport.batching(mapper.readTree(
+                "{\"batchingEnabled\": true, \"batchingMaxPublishDelayMillis\": 10}")))
+                .isEqualTo("on, 10 ms delay");
+    }
+
     @Test
     public void reportsTheCatchUpOfTheApplicationsThatJoinedLater() throws Exception {
         JsonNode workload = mapper.readTree("{\"applications\": {\"subscriptionPrefix\": \"app-\"}}");
diff --git a/tests/performance/scenarios/README.md b/tests/performance/scenarios/README.md
index 0f0a2e483836..1056a4a8c685 100644
--- a/tests/performance/scenarios/README.md
+++ b/tests/performance/scenarios/README.md
@@ -35,9 +35,9 @@ guide](../README.md) walks through running a scenario and reading its report.
 
 ## Scenarios for the standalone launcher
 
-These scenarios run the IoT telemetry workload: keyed telemetry messages from gateways to Key_Shared applications,
-with delivery and ordering checks. [The IoT telemetry scenario](docs/iot-telemetry.md) describes the workload in
-detail.
+These scenarios run the IoT telemetry workload: keyed telemetry messages from gateways to applications, with delivery
+and ordering checks; the applications use Key_Shared subscriptions, and the alert scenarios Shared ones.
+[The IoT telemetry scenario](docs/iot-telemetry.md) describes the workload in detail.
 
 | Scenario | What it runs | Memory configuration |
 |---|---|---|
@@ -52,6 +52,9 @@ detail.
 | [`iot-telemetry-offload-seek.yaml`](iot-telemetry-offload-seek.yaml) | Seeks by timestamp in offloaded ledgers: 110,000 1 KiB messages 1 ms apart to one topic, offloaded to SeaweedFS, and six applications whose subscriptions are reset to publish times spread over the offloaded ledgers, with the storage's reads counted; see [Offloading](../docs/offloading.md) | medium, about 11 GB |
 | [`iot-telemetry-offload-random-seeks.yaml`](iot-telemetry-offload-random-seeks.yaml) | Random reads of offloaded ledgers by time: after 110,000 1 KiB messages 1 ms apart to one topic, offloaded to SeaweedFS, 500 seeks to random publish times, each reading the message there, with the storage's reads counted; see [Offloading](../docs/offloading.md#random-seeks) | medium, about 11 GB |
 | [`iot-telemetry-max-rate.yaml`](iot-telemetry-max-rate.yaml) | The maximum rate: the 500 gateways of the high-rate scenario publish four million unbatched messages to one topic without a rate limit, consumed by one application with 20 pods, on single-copy ledgers | high, about 14 GB |
+| [`iot-alerts-fanout.yaml`](iot-alerts-fanout.yaml) | Alert fan-out with Shared subscriptions and broker deduplication: 20 gateways publish 5,000 alerts per second to one topic, consumed by 50 applications, each a Shared subscription with 4 worker pods: 250,000 messages per second of dispatch | high, about 14 GB |
+| [`iot-alerts-fanout-max-rate.yaml`](iot-alerts-fanout-max-rate.yaml) | The alert fan-out at the maximum rate: two million unbatched alerts as fast as the cluster takes them | high, about 14 GB |
+| [`iot-alerts-sites.yaml`](iot-alerts-sites.yaml) | The alert fan-out across 1,000 per-site topics: 5 gateways, 10 applications with 4 pods each, 5,000 producers, 10,000 Shared subscriptions and 40,000 consumers at 5,000 alerts per second in all | high, with a 4 GB application heap, about 17 GB |
 
 ## Configurations
 
diff --git a/tests/performance/scenarios/docs/iot-telemetry.md b/tests/performance/scenarios/docs/iot-telemetry.md
index f44d7e2acace..7e22e88cabcf 100644
--- a/tests/performance/scenarios/docs/iot-telemetry.md
+++ b/tests/performance/scenarios/docs/iot-telemetry.md
@@ -118,8 +118,13 @@ outputs are in different directories, pass a common shared coordination director
 process in that run. Reusing the directory is fine; use a new run ID for each invocation of the workload.
 
 Set `gateways.producer.batchingEnabled` in the workload section to compare batched and unbatched keyed messages without
-changing the tool implementation. Batched runs use `BatcherBuilder.KEY_BASED`, which keeps each batch to
-one key as required for Key_Shared delivery.
+changing the tool implementation. With Key_Shared subscriptions, batched runs use `BatcherBuilder.KEY_BASED`, which
+keeps each batch to one key as Key_Shared delivery requires; with Shared and Failover subscriptions, they use the
+default batcher, which batches messages of any device together. A gateway has a producer for each topic, and the
+gateways send each message through a random gateway, so a producer receives a message every `gateways.count *
+topics.count / rate` seconds on average. A batch has more than one message only when that is shorter than the
+producer's batching delay, `gateways.producer.batchingMaxPublishDelayMillis`, which is the client's default, 1 ms, when
+the scenario doesn't set it.
 
 Warmup messages exercise the same producer, client, connection, topic and consumer paths as measured messages. They
 remain in the monotonic device sequences and end-to-end delivery checks, but are excluded from throughput. For a
@@ -191,15 +196,17 @@ workloads:
         batchingEnabled: true
         precreate: false       # open every producer before the first message
         precreateConcurrency: 32  # with precreate, producers created at the same time, in a random order
+        # batchingMaxPublishDelayMillis: 10  # how long a batch waits for more messages; the client's default is 1 ms
       env:                     # the gateways' container, which runs every gateway; from the memory configuration
         PULSAR_MEM: -Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m -XX:+UseTransparentHugePages -XX:+AlwaysPreTouch
     topics:
       count: 30
       prefix: persistent://public/default/iot-telemetry-
-    applications:              # each a Key_Shared subscription, consumed through its pods
+    applications:              # each a subscription of its own, consumed through its pods
       count: 20
       podsPerApplication: 100  # a Pulsar client with a consumer of the subscription each
       subscriptionPrefix: iot-application-
+      subscriptionType: Key_Shared  # not set in the base file: Key_Shared, Shared or Failover
       client:                  # the client resources that every pod's client shares
         ioThreads: 8
         listenerThreads: 16
@@ -237,6 +244,13 @@ since the launcher skips entries. An application that skips messages expects eve
 device's from the first one that it receives. [Offloading](../../docs/offloading.md) uses them to read a backlog from
 tiered storage from staggered positions.
 
+`applications.subscriptionType` is the subscriptions' type, Key_Shared by default. With Shared, a device's messages
+arrive in any order, so the applications check for lost and duplicated messages but not for their order, and the
+gateways batch messages of any device together, with the producer's default batcher; with Key_Shared and Failover the
+applications check each device's order, and with Key_Shared the gateways keep a batch to one device, as the next
+section describes. Skipping messages and resetting subscriptions need Key_Shared or Failover, since an application
+then expects each device's messages from the first one that it receives.
+
 `timeoutSeconds` bounds the whole workload: the applications stop waiting for messages after it and the run fails,
 the gateways give up waiting for a warmup round or the measurement's start, and the launcher waits for the containers
 a minute longer. It has to be at least the time that the warmup rounds, their delays and the measurement need at the
@@ -305,9 +319,10 @@ application. It must report zero invalid messages and zero ordering violations.
 for Pulsar's at-least-once delivery model and are counted separately so comparisons can detect changes in their
 frequency. The persisted gateway and application state checks for missing tail messages after all clients stop.
 
-Key_Shared scenarios use the key-based producer batcher. It keeps every batch to one key so the broker can
-route all messages for a device through the same Key_Shared hash range. Changing the batcher changes the
-ordering contract exercised by the scenario and should not be mixed into a performance comparison.
+Key_Shared scenarios use the key-based producer batcher, which keeps every batch to one key so the broker can route
+all messages for a device through the same Key_Shared hash range; the other subscription types use the default
+batcher. Comparing subscription types with batching on therefore also changes the batches, and changing the batcher
+changes the ordering contract exercised by the scenario, so neither should be mixed into a performance comparison.
 
 The full topology opens 100 gateway clients and 2,000 application clients, all in the applications' container. Across
 30 topics and 20 applications, this creates 60,000 internal topic consumers. The medium-memory configuration gives the
diff --git a/tests/performance/scenarios/iot-alerts-fanout-max-rate.yaml b/tests/performance/scenarios/iot-alerts-fanout-max-rate.yaml
new file mode 100644
index 000000000000..c168c61f462c
--- /dev/null
+++ b/tests/performance/scenarios/iot-alerts-fanout-max-rate.yaml
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# The alert fan-out of iot-alerts-fanout.yaml at the maximum rate: the gateways publish two million unbatched alerts
+# as fast as the cluster takes them, with up to 50,000 in flight, so that every alert is an entry of its own that the
+# broker deduplicates, persists and dispatches to the 50 Shared subscriptions. It measures the most alerts that one
+# topic fans out, and the broker's limit in the deduplication, Shared dispatch and acknowledgment paths.
+extends: iot-alerts-fanout.yaml
+workloads:
+  iotTelemetry:
+    rate: 0
+    warmup:
+      seconds: 0
+      messages: 200000
+      rounds: 1
+      roundDelaySeconds: 0
+    measurement:
+      messages: 2000000
+    timeoutSeconds: 600
+    gateways:
+      producer:
+        maxOutstanding: 50000
+        batchingEnabled: false
diff --git a/tests/performance/scenarios/iot-alerts-fanout.yaml b/tests/performance/scenarios/iot-alerts-fanout.yaml
new file mode 100644
index 000000000000..688eeab3c079
--- /dev/null
+++ b/tests/performance/scenarios/iot-alerts-fanout.yaml
@@ -0,0 +1,46 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# Alert fan-out with Shared subscriptions and broker deduplication: a building-management platform's gateways publish
+# the alerts of 100,000 devices to one topic, with the broker's deduplication on (cluster-base.yaml), so that a gateway
+# that resends after a reconnection doesn't raise an alert twice. Fifty backend applications, such as notification,
+# ticketing, an audit log, analytics and a digital twin, each read every alert through a Shared subscription of their
+# own, handled by a pool of four stateless worker pods: 250,000 messages per second of dispatch from one topic's
+# managed ledger to 200 consumers. A Shared subscription doesn't keep a device's alerts in order, so the applications
+# check for lost and duplicated alerts only, and the gateways batch alerts of any device together. Each of the 20
+# gateways' producers receives an alert every 4 ms on average, longer than the client's default batching delay of 1 ms,
+# so the producers wait 10 ms for more alerts: about two or three alerts a batch.
+extends: [iot-telemetry-base.yaml, configs/iot-telemetry-high-mem.yaml]
+workloads:
+  iotTelemetry:
+    rate: 5000
+    payload:
+      size: 256
+    devices:
+      count: 100000
+    gateways:
+      count: 20
+      producer:
+        precreate: true
+        batchingMaxPublishDelayMillis: 10
+    topics:
+      count: 1
+      prefix: persistent://public/default/iot-alerts-
+    applications:
+      count: 50
+      podsPerApplication: 4
+      subscriptionPrefix: alert-processor-
+      subscriptionType: Shared
diff --git a/tests/performance/scenarios/iot-alerts-sites.yaml b/tests/performance/scenarios/iot-alerts-sites.yaml
new file mode 100644
index 000000000000..d665c4a8149a
--- /dev/null
+++ b/tests/performance/scenarios/iot-alerts-sites.yaml
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# The alert fan-out of iot-alerts-fanout.yaml across many topics: the platform keeps a topic for each of 1,000 sites,
+# and 10 backend applications each consume every site's alerts through a Shared subscription of their own, with four
+# worker pods that each subscribe to all of the topics. The gateways publish 5,000 alerts per second in all, five per
+# site, with deduplication on, so the broker carries 5,000 producers with deduplication state, 10,000 subscriptions
+# and 40,000 consumers of light traffic each: it measures the per-topic, per-producer and per-consumer overhead. Each
+# producer, of a gateway and a site, receives an alert a second on average, so its batches hold one alert each.
+extends: iot-alerts-fanout.yaml
+workloads:
+  iotTelemetry:
+    gateways:
+      count: 5
+      producer:
+        precreateConcurrency: 64
+    topics:
+      count: 1000
+    applications:
+      count: 10
+      podsPerApplication: 4
+      # Each of a multi-topic consumer's 1,000 internal consumers keeps a copy of the consumer's configuration with
+      # every topic's name: 40 million names across the 40,000 consumers, about 1.5 GB, beyond the high-memory
+      # configuration's application heap
+      env:
+        PULSAR_MEM: -Xms4g -Xmx4g -XX:MaxDirectMemorySize=256m -XX:+UseTransparentHugePages -XX:+AlwaysPreTouch
+    timeoutSeconds: 360
diff --git a/tests/performance/scenarios/iot-telemetry-base.yaml b/tests/performance/scenarios/iot-telemetry-base.yaml
index ac286813e8e3..4f69e263e4e6 100644
--- a/tests/performance/scenarios/iot-telemetry-base.yaml
+++ b/tests/performance/scenarios/iot-telemetry-base.yaml
@@ -57,8 +57,9 @@ workloads:
     topics:
       count: 30
       prefix: persistent://public/default/iot-telemetry-
-    # Each application is a Key_Shared subscription of its own, consumed through its pods, each a Pulsar client with a
-    # consumer. One container runs every application, as one runs every gateway.
+    # Each application is a subscription of its own, Key_Shared unless subscriptionType sets Shared or Failover,
+    # consumed through its pods, each a Pulsar client with a consumer. One container runs every application, as one
+    # runs every gateway.
     applications:
       count: 1
       podsPerApplication: 1
diff --git a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTracker.java b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTracker.java
index fd9694a23fbf..2f5aad88051a 100644
--- a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTracker.java
+++ b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTracker.java
@@ -41,6 +41,9 @@ final class DeviceSequenceTracker {
     private static final int STATE_VERSION = 1;
     private static final int LOCK_COUNT = 1024;
     private static final int MAX_VIOLATION_SAMPLES = 100;
+    // Whether a device's messages must arrive in order; without it, a message after a gap waits for the gap like an
+    // ordering violation does, but isn't counted as one
+    private final boolean checkOrdering;
     private final long[] nextExpected;
     // Each device's latest in-order message: its sequence and its message ID's ledger, entry and batch index, to tell
     // a redelivered duplicate, with the same message ID, from a message persisted twice, with another
@@ -62,11 +65,17 @@ final class DeviceSequenceTracker {
     private final ConcurrentLinkedQueue<String> violationSamples = new ConcurrentLinkedQueue<>();
 
     DeviceSequenceTracker(int deviceCount) {
-        this(deviceCount, false);
+        this(deviceCount, false, true);
     }
 
-    DeviceSequenceTracker(int deviceCount, boolean startAtFirstSequence) {
+    /**
+     * @param startAtFirstSequence whether each device's messages are expected from the first one that it receives,
+     *                             for a subscription whose position was moved past the start
+     * @param checkOrdering whether each device's messages must arrive in order
+     */
+    DeviceSequenceTracker(int deviceCount, boolean startAtFirstSequence, boolean checkOrdering) {
         started = startAtFirstSequence ? new boolean[deviceCount] : null;
+        this.checkOrdering = checkOrdering;
         nextExpected = new long[deviceCount];
         lastKeyedSequence = new long[deviceCount];
         Arrays.fill(lastKeyedSequence, -1);
@@ -116,6 +125,9 @@ final class DeviceSequenceTracker {
                 Set<Long> devicePending = pending.computeIfAbsent(index, ignored -> new HashSet<>());
                 if (devicePending.add(sequence)) {
                     uniqueMessages.incrementAndGet();
+                    if (!checkOrdering) {
+                        return;
+                    }
                     long violationNumber = orderingViolations.incrementAndGet();
                     if (violationNumber <= MAX_VIOLATION_SAMPLES) {
                         violationSamples.add("device=" + deviceId + " expected=" + expected + " observed=" + sequence
@@ -134,7 +146,7 @@ final class DeviceSequenceTracker {
                 lastBatchIndex[index] = id.getBatchIndex();
             }
             Set<Long> devicePending = pending.get(index);
-            if (devicePending != null && violationSamples.size() < MAX_VIOLATION_SAMPLES * 2) {
+            if (checkOrdering && devicePending != null && violationSamples.size() < MAX_VIOLATION_SAMPLES * 2) {
                 violationSamples.add("device=" + deviceId + " recovered=" + sequence
                         + formatContext(messageId, sentNanos, topic, thread, redeliveryCount, receivedEpochMs));
             }
diff --git a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/IotScenario.java b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/IotScenario.java
index dd756a847615..12cdf5f4f9e1 100644
--- a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/IotScenario.java
+++ b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/IotScenario.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import org.apache.pulsar.client.api.SubscriptionType;
 
 /**
  * Configuration selected from the {@code workloads.iotTelemetry} scenario subtree.
@@ -80,9 +81,14 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
      * @param precreateConcurrency with {@code precreate}, the most producers that the gateways create at the same
      *                             time, in a random order of the gateways and topics; 1 creates them one at a time in
      *                             order
+     * @param batchingMaxPublishDelayMillis with {@code batchingEnabled}, how long a producer's open batch waits for
+     *                                      more messages, in milliseconds; null for the client's default, 1 ms. A
+     *                                      producer receives a message every {@code gateways.count * topics.count /
+     *                                      rate} seconds on average, so a batch has more than one message only when
+     *                                      the delay is longer than that
      */
     public record Producer(int ioThreads, int listenerThreads, int maxOutstanding, boolean batchingEnabled,
-                           boolean precreate, Integer precreateConcurrency) {
+                           boolean precreate, Integer precreateConcurrency, Integer batchingMaxPublishDelayMillis) {
         /** The default of {@code precreateConcurrency}, for scenarios written before it existed. */
         public static final int DEFAULT_PRECREATE_CONCURRENCY = 32;
 
@@ -91,6 +97,12 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
                 precreateConcurrency = DEFAULT_PRECREATE_CONCURRENCY;
             }
         }
+
+        /** Settings with the client's default batching delay. */
+        public Producer(int ioThreads, int listenerThreads, int maxOutstanding, boolean batchingEnabled,
+                        boolean precreate, Integer precreateConcurrency) {
+            this(ioThreads, listenerThreads, maxOutstanding, batchingEnabled, precreate, precreateConcurrency, null);
+        }
     }
 
     /** The telemetry topics, named {@code <prefix><index>}. */
@@ -98,10 +110,9 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
     }
 
     /**
-     * The applications, in one container, as the gateways are. Each application is a Key_Shared subscription of its
-     * own on every topic, named {@code <subscriptionPrefix><index>}, consumed through {@code podsPerApplication}
-     * pods, each a Pulsar client with a consumer of the subscription; the applications differ only in their
-     * subscription.
+     * The applications, in one container, as the gateways are. Each application is a subscription of its own on every
+     * topic, named {@code <subscriptionPrefix><index>}, consumed through {@code podsPerApplication} pods, each a Pulsar
+     * client with a consumer of the subscription; the applications differ only in their subscription.
      *
      * @param client the client resources that every pod's client shares
      * @param env the environment variables of the applications' container, which the launcher sets, such as
@@ -124,12 +135,19 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
      *                      -1 for none, and empty for none at all. An application that resets its subscription
      *                      expects as many messages as its backlog then has, each device's from the first one that it
      *                      receives
+     * @param subscriptionType the subscriptions' type: {@code Key_Shared}, the default, {@code Shared} or
+     *                         {@code Failover}. A Shared subscription doesn't keep a device's messages in order, so
+     *                         the applications check it for lost and duplicated messages only
      */
     public record Applications(int count, int podsPerApplication, String subscriptionPrefix, Client client,
                                Map<String, String> env, List<Integer> joinSeconds, Integer caughtUpLatencyMillis,
-                               List<Long> skipMessages, boolean unloadBeforeJoin, List<Long> resetToMillis) {
+                               List<Long> skipMessages, boolean unloadBeforeJoin, List<Long> resetToMillis,
+                               String subscriptionType) {
         /** The default of {@code caughtUpLatencyMillis}. */
         public static final int DEFAULT_CAUGHT_UP_LATENCY_MILLIS = 1000;
+        /** The subscription types that the applications support. */
+        static final List<SubscriptionType> SUBSCRIPTION_TYPES =
+                List.of(SubscriptionType.Key_Shared, SubscriptionType.Shared, SubscriptionType.Failover);
 
         public Applications {
             // kept with any nulls, which the scenario's validation rejects with its message
@@ -141,6 +159,9 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
             if (caughtUpLatencyMillis == null) {
                 caughtUpLatencyMillis = DEFAULT_CAUGHT_UP_LATENCY_MILLIS;
             }
+            if (subscriptionType == null) {
+                subscriptionType = SubscriptionType.Key_Shared.name();
+            }
         }
 
         public Applications(int count, int podsPerApplication, String subscriptionPrefix, Client client,
@@ -156,6 +177,13 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
                     skipMessages, unloadBeforeJoin, null);
         }
 
+        public Applications(int count, int podsPerApplication, String subscriptionPrefix, Client client,
+                            Map<String, String> env, List<Integer> joinSeconds, Integer caughtUpLatencyMillis,
+                            List<Long> skipMessages, boolean unloadBeforeJoin, List<Long> resetToMillis) {
+            this(count, podsPerApplication, subscriptionPrefix, client, env, joinSeconds, caughtUpLatencyMillis,
+                    skipMessages, unloadBeforeJoin, resetToMillis, null);
+        }
+
         public Applications(int count, int podsPerApplication, String subscriptionPrefix, Client client,
                             Map<String, String> env) {
             this(count, podsPerApplication, subscriptionPrefix, client, env, null, null);
@@ -295,7 +323,20 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
         require(!applications.unloadBeforeJoin() || applications.joinSeconds().stream()
                         .anyMatch(seconds -> seconds != null && seconds > 0),
                 "applications.unloadBeforeJoin needs an application that joins later, with joinSeconds above 0");
+        require(Applications.SUBSCRIPTION_TYPES.stream()
+                        .anyMatch(type -> type.name().equals(applications.subscriptionType())),
+                "applications.subscriptionType must be one of " + Applications.SUBSCRIPTION_TYPES + ", not "
+                        + applications.subscriptionType());
+        // An application that skips messages or resets its subscription expects each device's messages from the first
+        // one that it receives, which is the device's first one only when the subscription keeps the device's order
+        require(!SubscriptionType.Shared.name().equals(applications.subscriptionType())
+                        || applications.skipMessages().stream().allMatch(skipped -> skipped == null || skipped == 0)
+                        && applications.resetToMillis().stream().allMatch(resetTo -> resetTo == null || resetTo == -1),
+                "applications.skipMessages and applications.resetToMillis need a subscription type that keeps each"
+                        + " device's order, not Shared");
         require(producer.precreateConcurrency() >= 1, "gateways.producer.precreateConcurrency must be at least 1");
+        require(producer.batchingMaxPublishDelayMillis() == null || producer.batchingMaxPublishDelayMillis() >= 1,
+                "gateways.producer.batchingMaxPublishDelayMillis must be at least 1");
         if (timeoutSeconds < minimumRuntimeSeconds) {
             throw new IllegalArgumentException(String.format(Locale.ROOT, "Invalid IoT scenario: timeoutSeconds is %d,"
                             + " but the workload needs %d s: %d s of warmup (%d round(s) of %d s%s) and %d s of"
@@ -358,6 +399,16 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
         return applications.podsPerApplication();
     }
 
+    /** The applications' subscription type. */
+    public SubscriptionType subscriptionType() {
+        return SubscriptionType.valueOf(applications.subscriptionType());
+    }
+
+    /** Whether the subscription type keeps each device's messages in order, which the applications then check. */
+    public boolean keepsDeviceOrder() {
+        return subscriptionType() != SubscriptionType.Shared;
+    }
+
     /** When the application opens its pods, in seconds after the measurement starts; 0 for at the start. */
     public int joinSeconds(int applicationIndex) {
         return applications.joinSeconds().isEmpty() ? 0 : applications.joinSeconds().get(applicationIndex);
@@ -436,11 +487,16 @@ public record IotScenario(String serviceUrl, Warmup warmup, Measurement measurem
     public List<String> topicNames() {
         List<String> result = new ArrayList<>(topics.count());
         for (int i = 0; i < topics.count(); i++) {
-            result.add(topics.prefix() + i);
+            result.add(topicName(i));
         }
         return result;
     }
 
+    /** The topic with the index, from 0 to {@code topics.count} - 1. */
+    public String topicName(int topicIndex) {
+        return topics.prefix() + topicIndex;
+    }
+
     public String subscriptionName(int applicationIndex) {
         if (applicationIndex < 0 || applicationIndex >= applications.count()) {
             throw new IllegalArgumentException("Application index out of range: " + applicationIndex);
diff --git a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryConsumer.java b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryConsumer.java
index af376380c1f0..113f1469a9f7 100644
--- a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryConsumer.java
+++ b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryConsumer.java
@@ -48,17 +48,18 @@ import org.apache.pulsar.client.api.PulsarClient;
 import org.apache.pulsar.client.api.PulsarClientSharedResources;
 import org.apache.pulsar.client.api.Schema;
 import org.apache.pulsar.client.api.SubscriptionInitialPosition;
-import org.apache.pulsar.client.api.SubscriptionType;
 import picocli.CommandLine.Command;
 
 /**
- * Runs every application of the scenario in this JVM, as the gateways run in one. An application is a Key_Shared
- * subscription of its own on every topic, consumed through its pods, each a Pulsar client with a consumer of the
- * subscription; the applications differ only in their subscription. Every pod's client shares one set of client
- * resources, the event loop and the thread pools, sized by {@code applications.client}.
+ * Runs every application of the scenario in this JVM, as the gateways run in one. An application is a subscription
+ * of its own on every topic, of the type {@code applications.subscriptionType}, consumed through its pods, each a
+ * Pulsar client with a consumer of the subscription; the applications differ only in their subscription. Every pod's
+ * client shares one set of client resources, the event loop and the thread pools, sized by
+ * {@code applications.client}.
  *
- * <p>Each application checks its own delivery and ordering, and writes its outputs into a directory named after its
- * subscription in {@code --output}, as the run report names it. The progress stream sums the applications' counts.
+ * <p>Each application checks its own delivery and, unless its subscription is Shared, ordering, and writes its outputs
+ * into a directory named after its subscription in {@code --output}, as the run report names it. The progress stream
+ * sums the applications' counts.
  *
  * <p>An application with {@code applications.joinSeconds} after the measurement's start creates its subscription at
  * startup, so that the backlog builds up from the start, and opens its pods when it joins. It records when it joined
@@ -285,7 +286,8 @@ final class TelemetryConsumer extends PerformanceTool.ScenarioCommand {
             this.scenario = scenario;
             this.index = index;
             this.output = output;
-            tracker = new DeviceSequenceTracker(scenario.deviceCount(), scenario.startsAtFirstSequence(index));
+            tracker = new DeviceSequenceTracker(scenario.deviceCount(), scenario.startsAtFirstSequence(index),
+                    scenario.keepsDeviceOrder());
             // Unknown until the launcher has reset the subscription, which it tells with the prepared join
             expectedMessages = scenario.resetToMillis(index) >= 0 ? -1 : scenario.expectedMessageCount(index);
             catchUp = new CatchUpTracker(scenario.topicCount(), scenario.applications().caughtUpLatencyMillis());
@@ -320,7 +322,7 @@ final class TelemetryConsumer extends PerformanceTool.ScenarioCommand {
                 client.newConsumer(Schema.BYTES)
                         .topics(scenario.topicNames())
                         .subscriptionName(scenario.subscriptionName(index))
-                        .subscriptionType(SubscriptionType.Key_Shared)
+                        .subscriptionType(scenario.subscriptionType())
                         .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                         .subscribe()
                         .close();
@@ -527,7 +529,7 @@ final class TelemetryConsumer extends PerformanceTool.ScenarioCommand {
                         .topics(scenario.topicNames())
                         .subscriptionName(scenario.subscriptionName(index))
                         .consumerName("iot-application-" + index + "-pod-" + podIndex)
-                        .subscriptionType(SubscriptionType.Key_Shared)
+                        .subscriptionType(scenario.subscriptionType())
                         .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                         .messageListener((currentConsumer, message) -> {
                             long receivedEpochMs = System.currentTimeMillis();
diff --git a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryProducer.java b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryProducer.java
index 837b0bab4607..dfdf5270d63f 100644
--- a/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryProducer.java
+++ b/tests/performance/tools/src/main/java/org/apache/pulsar/tests/performance/tools/TelemetryProducer.java
@@ -42,6 +42,7 @@ import org.apache.pulsar.client.api.Producer;
 import org.apache.pulsar.client.api.ProducerBuilder;
 import org.apache.pulsar.client.api.PulsarClient;
 import org.apache.pulsar.client.api.PulsarClientSharedResources;
+import org.apache.pulsar.client.api.SubscriptionType;
 import picocli.CommandLine.Command;
 import picocli.CommandLine.Option;
 
@@ -370,13 +371,21 @@ final class TelemetryProducer extends PerformanceTool.ScenarioCommand {
 
     private ProducerBuilder<byte[]> producerBuilder(IotScenario scenario, List<PulsarClient> clients,
                                                     int gateway, int topic) {
-        return clients.get(gateway).newProducer()
-                .topic(scenario.topicNames().get(topic))
+        ProducerBuilder<byte[]> builder = clients.get(gateway).newProducer()
+                .topic(scenario.topicName(topic))
                 .producerName("iot-gateway-" + gateway + "-topic-" + topic)
-                .batcherBuilder(BatcherBuilder.KEY_BASED)
+                // Key_Shared delivers a batch to one consumer, so a batch keeps to one key, its device. With the
+                // other subscription types, a batch may mix devices.
+                .batcherBuilder(scenario.subscriptionType() == SubscriptionType.Key_Shared
+                        ? BatcherBuilder.KEY_BASED : BatcherBuilder.DEFAULT)
                 .enableBatching(scenario.gateways().producer().batchingEnabled())
                 .blockIfQueueFull(true)
                 .sendTimeout(0, TimeUnit.SECONDS);
+        Integer batchingMaxPublishDelayMillis = scenario.gateways().producer().batchingMaxPublishDelayMillis();
+        if (batchingMaxPublishDelayMillis != null) {
+            builder.batchingMaxPublishDelay(batchingMaxPublishDelayMillis, TimeUnit.MILLISECONDS);
+        }
+        return builder;
     }
 
     private void writeState(long[] sequences) throws Exception {
diff --git a/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTrackerTest.java b/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTrackerTest.java
index 2c97f3c65f42..941161b043c8 100644
--- a/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTrackerTest.java
+++ b/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/DeviceSequenceTrackerTest.java
@@ -19,6 +19,7 @@
 package org.apache.pulsar.tests.performance.tools;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import java.io.DataInputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import org.apache.pulsar.client.impl.MessageIdImpl;
@@ -39,7 +40,7 @@ public class DeviceSequenceTrackerTest {
 
     @Test
     public void startsAtEachDevicesFirstSequenceAfterSkippedMessages() {
-        DeviceSequenceTracker tracker = new DeviceSequenceTracker(3, true);
+        DeviceSequenceTracker tracker = new DeviceSequenceTracker(3, true, true);
         tracker.received(0, 5);
         tracker.received(0, 6);
         tracker.received(1, 0);
@@ -70,6 +71,58 @@ public class DeviceSequenceTrackerTest {
         assertThat(tracker.summary().valid()).isFalse();
     }
 
+    @Test
+    public void acceptsAnyOrderWithoutTheOrderingCheck() throws Exception {
+        // A Shared subscription delivers a device's messages in any order
+        DeviceSequenceTracker tracker = new DeviceSequenceTracker(1, false, false);
+        tracker.received(0, 2);
+        tracker.received(0, 0);
+        tracker.received(0, 2);
+        tracker.received(0, 1);
+        tracker.received(0, 1);
+
+        assertThat(tracker.summary()).isEqualTo(new DeviceSequenceTracker.Summary(3, 2, 0, 0, 0, 0));
+        assertThat(tracker.summary().valid()).isTrue();
+        Path samples = Files.createTempFile("ordering-violations", ".txt");
+        try {
+            tracker.writeViolationSamples(samples);
+            assertThat(Files.readAllLines(samples)).isEmpty();
+        } finally {
+            Files.deleteIfExists(samples);
+        }
+    }
+
+    @Test
+    public void persistsTheContiguousPrefixWithoutTheOrderingCheck() throws Exception {
+        // The persisted state is each device's next expected sequence, which the launcher compares with the gateways'
+        // sequences to find lost messages: a gap that stays open keeps it at the gap
+        DeviceSequenceTracker tracker = new DeviceSequenceTracker(2, false, false);
+        tracker.received(0, 2);
+        tracker.received(0, 0);
+        tracker.received(1, 1);
+        assertThat(readState(tracker)).containsExactly(1, 0);
+        tracker.received(0, 1);
+        tracker.received(1, 0);
+        assertThat(readState(tracker)).containsExactly(3, 2);
+    }
+
+    private static long[] readState(DeviceSequenceTracker tracker) throws Exception {
+        Path state = Files.createTempFile("device-sequences", ".bin");
+        try {
+            tracker.writeState(state);
+            try (var input = new DataInputStream(Files.newInputStream(state))) {
+                input.readInt();
+                long[] nextExpected = new long[input.readInt()];
+                for (int i = 0; i < nextExpected.length; i++) {
+                    nextExpected[i] = input.readLong();
+                }
+                return nextExpected;
+            }
+        } finally {
+            Files.deleteIfExists(state);
+        }
+    }
+
     @Test
     public void tellsRedeliveredDuplicatesFromMessagesPersistedTwice() throws Exception {
         DeviceSequenceTracker tracker = new DeviceSequenceTracker(1);
diff --git a/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/IotScenarioTest.java b/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/IotScenarioTest.java
index d232c28cd9ba..044f76ced5ef 100644
--- a/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/IotScenarioTest.java
+++ b/tests/performance/tools/src/test/java/org/apache/pulsar/tests/performance/tools/IotScenarioTest.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import org.apache.pulsar.client.api.SubscriptionType;
 import org.apache.pulsar.tests.performance.common.YamlScenarioLoader;
 import org.testng.annotations.Test;
 import picocli.CommandLine;
@@ -203,6 +204,35 @@ public class IotScenarioTest {
                 .hasMessageContaining("-1 for none, or at least 0");
     }
 
+    @Test
+    public void choosesTheSubscriptionType() {
+        IotScenario keyShared = scenario(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2),
+                null));
+        assertThat(keyShared.subscriptionType()).isEqualTo(SubscriptionType.Key_Shared);
+        assertThat(keyShared.keepsDeviceOrder()).isTrue();
+        IotScenario shared = scenario(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2), null,
+                null, null, null, false, null, "Shared"));
+        assertThat(shared.subscriptionType()).isEqualTo(SubscriptionType.Shared);
+        assertThat(shared.keepsDeviceOrder()).isFalse();
+        assertThat(scenario(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2), null, null,
+                null, null, false, null, "Failover")).keepsDeviceOrder()).isTrue();
+        assertThatThrownBy(() -> scenario(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2),
+                null, null, null, null, false, null, "Exclusive")))
+                .hasMessageContaining("applications.subscriptionType must be one of [Key_Shared, Shared, Failover]");
+        // skipping and resetting expect each device's messages from the first one received, in order
+        assertThatThrownBy(() -> unbatched(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2),
+                null, List.of(0, 30), null, List.of(0L, 10L), false, null, "Shared")))
+                .hasMessageContaining("need a subscription type that keeps each device's order");
+        assertThatThrownBy(() -> unbatched(new IotScenario.Applications(2, 2, "app-", new IotScenario.Client(2, 2),
+                null, List.of(0, 30), null, null, false, List.of(-1L, 5_000L), "Shared")))
+                .hasMessageContaining("need a subscription type that keeps each device's order");
+        // a scenario file without the setting keeps Key_Shared
+        IotScenario.Applications fromYaml = new YamlScenarioLoader().mapper().convertValue(Map.of("count", 2,
+                "podsPerApplication", 2, "subscriptionPrefix", "app-", "client",
+                Map.of("ioThreads", 2, "listenerThreads", 2)), IotScenario.Applications.class);
+        assertThat(scenario(fromYaml).subscriptionType()).isEqualTo(SubscriptionType.Key_Shared);
+    }
+
     @Test
     public void rejectsInvalidJoinSettings() {
         assertThatThrownBy(() -> scenario(new IotScenario.Applications(3, 2, "app-", new IotScenario.Client(2, 2),
@@ -247,6 +277,17 @@ public class IotScenarioTest {
                 .hasMessageContaining("gateways.producer.precreateConcurrency must be at least 1");
     }
 
+    @Test
+    public void rejectsABatchingDelayBelowOneMillisecond() {
+        assertThatThrownBy(() -> new IotScenario("pulsar://localhost:6650", new IotScenario.Warmup(0, 0, 1, 0),
+                new IotScenario.Measurement(120, 1_000), 0, new IotScenario.Payload(64), new IotScenario.Devices(1_000),
+                new IotScenario.Gateways(10, new IotScenario.Producer(2, 2, 100, true, true, null, 0), null),
+                new IotScenario.Topics(2, "persistent://public/default/iot-"),
+                new IotScenario.Applications(1, 2, "app-", new IotScenario.Client(2, 2), null), null, 300))
+                .isInstanceOf(IllegalArgumentException.class)
+                .hasMessageContaining("gateways.producer.batchingMaxPublishDelayMillis must be at least 1");
+    }
+
     @Test
     public void rejectsTwoWarmupLimits() {
         assertThatThrownBy(() -> scenario(20, 1_000, 1000, 0))