Repository navigation
[improve][test] Add network conditions, network faults and geo-replication to the performance tests - #26859
Merged
Conversation
…ation to the performance tests Let a scenario of the Pulsar Performance Testing Framework run over an impaired network: delay, jitter, packet loss and limited bandwidth between chosen containers, for the whole run or for a time, and timed faults: partitions, connection resets and silent disconnections. The impairments use Linux traffic control (tc with netem) from a privileged sidecar in the Docker engine host's namespaces, so TCP reacts as on a real network and nothing in the cluster changes. A scenario can also add a second cluster, which shares the configuration store with the first so that the namespace public/default replicates the workload's topics to it, with remote applications that check every replicated message and its order. - A network scenario section, validated by NetworkSettings, with endpoints for both clusters. - NetworkImpairments applies, times and removes the impairments and cleans them up on every path; networkCheck checks them on real containers, and unit tests drive their state machine. - The run report's Network conditions and Remote applications sections, the workloads' Pulsar client logs, the duplicates' classification, and the remote and replication stats. - Overlays under scenarios/network for network conditions, broker, bookie and metadata store faults, client disconnections and geo-replication, documented in docs/network-conditions.md. Assisted-by: Claude Code (claude-opus-5-5)
This was referenced Oct 12, 2026
Merged
Member
|
The introduction of the chaos test will greatly boost Pulsar's resilience. |
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The Pulsar Performance Testing Framework runs the cluster and its workloads on one host, over Docker's bridge network, where a round trip takes a tenth of a millisecond and nothing is lost. Real deployments don't look like that: IoT gateways reach the cluster over the internet or a cellular network, brokers and bookies sit in different availability zones, links get congested, and brokers, bookies and ZooKeeper get cut off. Geo-replicated clusters in different regions are connected over such networks too. How Pulsar's latency, throughput and recovery behave under those conditions, and whether every message still arrives in order, couldn't be tested with the framework.
This PR lets a scenario run over an impaired network: delay, jitter, packet loss and limited bandwidth between chosen containers, for the whole run or for a time, and timed faults: partitions, connection resets and silent disconnections. A scenario can also add a second cluster that the topics replicate to, with applications that consume the replicated messages there. The applications already check every device's messages, so a run with faults is a correctness test as well as a performance test.
The impairments use Linux traffic control (
tcwithnetem) on the containers' network interfaces instead of a TCP proxy such as Toxiproxy:-Pperformance.clusterPulsarImageandcompareImages.Modifications
networksection with impairments as a mapping by name, so that overlays compose and--setchanges one setting.between: [A, B], orfromandto. The endpoints aregateways,applications,clients,brokers,broker-N,bookies,bookie-N,zookeeper,configuration-storeandmetadata, and with a remote clusterremote-brokers,remote-broker-N,remote-bookies,remote-bookie-N,remote-zookeeper,remote-applications,local-regionandremote-region.delay,jitter,loss,lossBurst,ratewith a boundedqueue), apartition, areset, or asilentDisconnect.startafter the measurement's start or the gateways' start (anchor), for an optionalduration.NetworkSettingsvalidates it: unknown keys, endpoints, units and ranges, settings that don't fit the kind, a start after the measurement's estimated end, overlapping conditions on the same pair of containers, and a device's band limit.NetworkImpairmentsapplies them from a privileged sidecar in the Docker engine host's network and PID namespaces, as theperf statsidecar runs.prioqdisc with a netem band per impairment. Applying or removing an impairment adds or deletes itsu32filters. A partition is netem's 100 % loss, with filters that take precedence over a condition's.ss -K, which resets the connections on both ends.fromtoto, drops each one's packets both ways by its addresses and ports, and destroys the sockets on thefromside.fromreconnects at once, whiletokeeps half-open connections until its keep-alive notices, as after a NAT gateway or a firewall forgot its connections. Long filter scripts run from a file in the sidecar.loss random 1% 25%) dropped almost no packet on Linux 7.1.reorder: trueopts out.offloads: auto|off|on). Otherwise netem drops and delays GSO super-packets: at 1 % loss, about nine segments per drop.PULSAR_CONTAINERS_LEAVE_RUNNING.--await-run-startoption, so the whole-run conditions are installed before they create their clients.awaitWorkloadsalso waits on the impairments' failure.cluster.brokers.bootstrap: alllists every broker in the workloads' service URL, so that a partitioned broker isn't the clients' only way in.cluster.remotesection starts a second cluster that shares the configuration store with the first, so that the namespacepublic/defaultreplicates the workload's topics to it.cluster.remote.brokersandcluster.remote.bookieschange them.cluster.remote.applicationssets their count, pods and environment. The run fails when one misses a message or receives one out of order.remote-topic-stats.csvhas the remote topics' stats andreplication-stats.csveach topic's replicators, once a second.pulsar-client.log.txtin each workload's output directory. Before, they were dropped, since the tools had no SLF4J binding.PULSAR_CLIENT_LOG_LEVELsets the level.network-summary.json;network-events.jsonlrecords every event as it happens.scenarios/network/, each describing what it models and what to look for:wan-clients,mobile-gateways,constrained-uplink,cross-zone-storage,slow-bookie,lossy-storage,constrained-consumers;bookie-partition,broker-partition,broker-isolation,metadata-partition,metadata-takeover,return-path-blackhole,connection-resets,consumer-reconnect-storm,silent-client-disconnect,silent-broker-disconnect,storage-outage,bookie-metadata-outage,zookeeper-outage;geo-replication, which adds the remote cluster with four remote applications and an hour's retention, andgeo-wan,geo-partition,geo-silent-disconnectandgeo-constrained-link, which extend it;failover-cluster, a two-broker, four-bookie cluster with E/W/A 3/3/2 that the fault overlays extend.docs/network-conditions.md, with what each overlay can be used for and a geo-replication section, entries in the scenario format and the README, and a section in the framework's agent guide on network and fault experiments: preparing the host, checking that the impairments acted, the correctness failures and the duplicates' classification, where the complete logs are, lining up the clocks, the JIT's effect on a fault's first occurrence, heap dumps and profiles of a fault, and geo-replication runs.What the scenarios are for
Each overlay models a network condition or a fault that production clusters meet, and checks Pulsar's correctness, stalls and recovery under it: the publish and end-to-end latency over WANs and lossy links, failover after a broker, a bookie or the metadata store becomes unreachable, the brokers' handling of connections that vanish without notice, consumers that fall behind, mass reconnections, and geo-replication over a WAN, a congested link and a link failure.
docs/network-conditions.mdlists what each one can be used for.Running them against master on
iot-telemetry-smallfound several problems in Pulsar, to be reported as separate issues: among them, stalls of unrelated producers when many Key_Shared consumers reconnect, a broker running out of heap while it holds the old consumers of connections that vanished, Key_Shared ordering violations in the same situation, slow producer failover after a broker loses its metadata session, bookies shutting down when they lose ZooKeeper because of the embedded AutoRecovery, and geo-replication losing messages after the connections between the clusters break.Verifying this change
This change added tests and can be verified as follows:
NetworkSettingsTest: parsing, endpoints, pairs, validation, overlaps, the band limit.NetworkImpairmentsTest: the impairments' state machine on a fake host: whole-run and timed impairments, missed and skipped ones, failures during the set-up and the run, resets, silent disconnections, and the cleanup, including after a partial set-up.TcCommandsTest: the generated commands, hexadecimal class IDs, queue sizes, and parsingip,ethtoolandtcoutput.NetworkReportTest: the report section.ClusterSettingsTest: the bootstrap setting and the remote cluster.RemoteApplicationsTest: the remote applications' workload and the containers' names.ProgressMonitorTest: the remote applications' line and the age of stale samples.MeasurementSecondsTest: the measurement's estimated length, which bounds the impairments' start times.RunReportTest: the Remote applications section.RemoteApplicationsTest: also that the launcher's container names match what the endpoints expand to, and that a remote cluster needs the topics inpublic/default.MeasurementControlTest:/run/start.ScenarioFilesTest: every network overlay on the small and the high-rate scenarios.DeviceSequenceTrackerTest: telling redelivered duplicates from messages persisted twice../gradlew :tests:performance:launcher:networkCheck, a new task, runsNetworkImpairmentsCheckagainst real containers withpingandiperf3. It covers a delay on one destination and none on others, a timed partition on the timeline, a silent disconnection in each direction, a timed silent disconnection of a target without connections, the jitter's order with and withoutreorder, 1 % loss (0.7–1.3 % measured) and a 20 Mbit/s rate, a reset, and the cleanup after each: no impairment left on the containers' interfaces or their host-side veths, and the offloads restored. It passes on Linux 7.1 with Docker 29.8.iot-telemetry-smallwith 20 ms between the gateways and the brokers raised the publish latency from about 1 ms to 41 ms at the full 1,000 msg/s, and every message was delivered in order.iot-telemetry-smallwithnetwork/geo-replicationdelivered every message to the four remote applications, in order, about 1 ms behind the first cluster's applications.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes