[
https://issues.apache.org/jira/browse/PHOENIX-8079?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Kyle Purtell updated PHOENIX-8079:
-----------------------------------------
Summary: Pherf Harness: Phase 3: Distributed Pherf (was: Pherf Harness:
Phase 3)
> Pherf Harness: Phase 3: Distributed Pherf
> -----------------------------------------
>
> Key: PHOENIX-8079
> URL: https://issues.apache.org/jira/browse/PHOENIX-8079
> Project: Phoenix
> Issue Type: Sub-task
> Components: harness, pherf
> Reporter: Andrew Kyle Purtell
> Assignee: Andrew Kyle Purtell
> Priority: Major
> Fix For: PHOENIX-8070
>
>
> This subtask adds a new Maven module, {{phoenix-pherf-distributed}}, to
> coordinate Pherf across multiple hosts so a fleet of worker processes
> operates as one logical load generator.
> A central controller accepts declarative test plans over a REST API, splits
> workload targets across long-lived agent processes, coordinates all assigned
> agents to start generating load at the same moment, collects periodic HDR
> latency interval streams in real time, and combines them into an aggregate
> fleet report, run bundle, and health verdict matching standalone Pherf
> artifact formats.
> Because controller-to-agent communication uses HTTP and JSON over the
> standard JDK HTTP server, the module adds zero third-party dependencies.
> Alongside the core module, this change adds a single container image that
> runs either the controller or agent role, a standalone Docker Compose
> topology, an integrated harness tier managed by {{px-pherf}}, the
> {{pherf-distributed}} harness driver, end-to-end fleet workload suites, and
> the harness host tier and overlay files.
> At runtime, the system runs two daemon processes: a central controller and a
> fleet of worker agents. The controller tracks the set of active agents along
> with all registered test definitions and run states, listening on port 8780
> for client REST API calls and port 8790 for agent connections. Each agent
> maintains two persistent outbound HTTP/1.1 connections to the controller, one
> for control coordination and one for telemetry streaming. This outbound-only
> pattern works through Kubernetes Services, load balancers, and service meshes
> without requiring the controller to resolve or connect to individual agent
> pod IPs. Because agent daemons stay resident across consecutive runs, the
> worker fleet stays warm and later runs avoid JVM startup and registration
> overhead.
> The transport layer avoids external RPC libraries or servlet containers so no
> additional dependencies are introduced. Deserialization ignores unknown
> fields so additive schema changes remain backward compatible, while breaking
> changes increment the URL endpoint version prefix. Within a deployment, the
> controller and all registered agents should run artifacts built from the same
> build.
> Coordination uses a level triggered reconciliation loop. On each poll, an
> agent reports its full current state, and the controller returns a single
> state transition directive computed from the difference between its target
> state and the agent's reported state. Duplicates are idempotent, and any lost
> reply is recalculated and sent again on the next poll. Each exchange acts as
> both a liveness heartbeat and a round-trip clock synchronization sample. If
> an agent does not poll within ten seconds, the controller evicts it from the
> active set. If an agent receives no controller reply within ten seconds, it
> terminates its active workload so an evicted or partitioned worker does not
> generating orphan load. When the controller is unreachable, the agent retries
> every second while suppressing repeated log noise, emitting one log entry on
> the initial failure and one INFO line when connectivity returns.
> Operational identity and data plane identity are kept separate. An agent's
> operational identity consists of its configured agent ID and a per-process
> start code. Data plane identity attaches to the logical assignment slot
> rather than the physical agent. For each slot, the controller
> deterministically computes a slice seed, a starting row offset, and a key
> prefix as a pure function of the run seed and slot index. Running a test plan
> produces the same database state regardless of which physical agents are
> picked from the fleet, and restarting an agent between runs does not change
> the records generated by any slot. Before starting a workload, the agent
> substitutes these slot parameters into staged scenario files via explicit
> slot tokens, letting each scenario define how they apply (such as setting the
> process offset of a co-generation walk or isolating the key prefix of a rule
> based workload).
> Workloads are structured as an ordered sequence of execution steps. Each step
> specifies a target scenario and its XML or SQL files, a required agent count,
> optional per-slot relative weights, optional fleet-wide totals for arrival
> rate, worker threads, row count, and duration, and optional Pherf properties
> scoped to the run or step.
> To split fleet-wide totals across participating slots, the controller uses
> the largest remainder method in exact integer arithmetic. Per-slot
> allocations sum exactly to the requested fleet total, and every slot stays
> within one unit of its ideal proportional share. Starting row offsets come
> from the prefix sums of allocated row counts, keeping slot key ranges
> disjoint while covering the entire target keyspace, including in multi-step
> plans where different steps use different agent counts.
> For process isolation, agents launch Pherf in a dedicated child JVM rather
> than running it in-process. This avoids Pherf static state leaking between
> runs, insulates the resident agent daemon from workload crashes, lets
> cancellation directives kill active workloads cleanly, and keeps heavy
> workload activity from starving the control plane heartbeat thread.
> Before issuing database operations, each assigned agent runs Pherf's offline
> {{-validate}} check on its rendered workload slice with the exact launch
> arguments scheduled for execution. During a plan's first step, every agent
> also validates its slices for all later steps so a misconfiguration anywhere
> in the plan aborts the run before traffic begins. Any validation or runtime
> failure on one agent fails the run immediately.
> Synchronizing workload traffic across the fleet at the same instant requires
> a two phase handshake. Once all slots in a step finish staging and
> preparation, the controller instructs every assigned agent to spawn its Pherf
> child JVM. Each child runs its configured warmup phase and then blocks at an
> execution start gate, a lightweight synchronization barrier added to
> {{phoenix-pherf}} by this subtask. When all participating slots report that
> their start gates are armed, the controller picks a release timestamp a short
> lead time ahead on its local clock and sends that target timestamp to each
> agent adjusted by the agent's estimated clock offset. The controller updates
> clock offset estimates continuously from control poll round trips using an
> NTP-style filter that picks the sample with the lowest round trip delay.
> After the gate opens and load generation begins, each slot reports its actual
> release timestamp, letting the controller compute the step's start skew as
> the spread across clock-normalized release times plus the uncertainty bounds
> of the offset estimates. Bulk data loads and legacy multitenant load profile
> workloads bypass the start gate.
> While a workload runs, each agent tails the {{HdrHistogram}} interval log
> written by its Pherf child process and sends every completed interval to the
> controller as a monotonically numbered telemetry frame carrying the
> cumulative operation count for each operation key and phase. The controller
> accepts a frame only when its sequence number immediately follows the last
> accepted frame for that slot, acknowledges the highest contiguous sequence
> number received, and relies on the agent to replay buffered frames past that
> watermark after a reconnect. Transient network drops therefore neither lose
> latency measurements nor double count intervals. If a frame's cumulative
> sample count disagrees with the controller's running tally, the controller
> detects the gap or duplication and fails the slot immediately. A slot
> transitions to the completed state only after the controller receives and
> acknowledges every telemetry frame through the final sequence number reported
> when the child process exits.
> As frames arrive from the fleet, the controller merges each interval from
> every slot into one aggregate histogram per operation key and execution
> phase. This fold matches a single recorder capturing all fleet operations
> directly across total sample count, latency percentiles, and maximum latency.
> The fleet health verdict verifies this explicitly, failing the telemetry
> integrity check if any merged histogram's total sample count differs from the
> sum of per-slot counts reported for that key. Controller heap usage stays
> constant regardless of run duration.
> When a run reaches a terminal state, the controller writes a self-contained
> run bundle to disk. The bundle holds the aggregate fleet latency report in
> standard version 1 Pherf latency JSON format (so Pherf's offline {{-analyze}}
> mode can inspect and compare fleet replicates without changes), a fleet-wide
> merged interval log, per-slot interval logs, the submitted test plan and
> final run status record, a fleet health verdict file following the standard
> Pherf verdict TSV schema, and a bundle manifest written last as the commit
> marker. A bundle is considered complete only when its manifest file is
> flushed and synced to disk, so any run directory without a manifest is
> identified as interrupted. In addition to the standard Pherf health checks,
> the fleet verdict checks synchronized start skew, missing or miscounted
> telemetry frames, and agent execution failures, and downgrades timing
> duration breaches to advisory for validation runs.
> Under the {{/v1}} prefix, the controller exposes a REST API to list
> registered agents, create reusable test definitions from JSON plans, launch
> runs of a registered test (such as successive replicates), poll run progress
> with per-slot status, fetch the aggregate fleet latency report, cancel an
> in-flight run, close a finished test, reset a faulted agent, and download run
> bundles via a manifest listing paired with per-file fetch endpoints,
> requiring only a standard HTTP client and JSON parser on the client side.
> Test definitions, submitted plans, and run status records are persisted in
> the controller state directory using crash safe atomic writes. After a
> controller restart, previously registered tests and finished runs reload
> intact for report queries, while any run that was in progress at the time of
> interruption is marked failed and reconnecting agents register under a new
> session after discarding unacknowledged telemetry buffers. An interrupted run
> can never be mistaken for a valid completed measurement.
> The state machine separates internal protocol violations from external
> workload failures. An agent that breaks the transport or telemetry contract
> (such as sending a malformed frame, reporting a discrepant cumulative sample
> count, or reporting completion without a final summary report) is quarantined
> in a faulted state and excluded from future work assignments until an
> operator resets it through the REST API. In contrast, an agent that
> accurately reports an external workload failure, such as a non-zero Pherf
> child exit caused by an injected database fault, fails the active run while
> staying healthy and eligible for subsequent fault-injection replicates.
> Throughout its lifetime, the controller holds an exclusive OS file lock on
> its state directory to prevent concurrent controller instances from
> corrupting shared state. The Kubernetes subtask relies on this bounded wait
> during rolling updates when a replacement controller pod starts initializing
> before the terminating pod releases the lock on their shared persistent
> volume claim. The lock-wait implementation, its two unit tests, and the
> accompanying README documentation reside in this patch.
> Both controller and agent roles share a single container image built on a
> digest-pinned JRE 17 base image. Containers run as an unprivileged non-root
> user with tini as PID 1 for clean signal forwarding to the daemon JVM and
> reliable reaping of exited Pherf child JVMs. A container entrypoint script
> handles startup, shutdown, and health probes for both roles; the environment
> variable contract is documented in the module README.
> For standalone deployments outside the harness, a Docker Compose manifest
> launches one controller and three agents, each with explicit memory limits
> and readiness health checks, pointed at the HBase cluster given by
> {{PHERF_ZOOKEEPER}}. Only the controller's REST port is published on the
> host, bound to 127.0.0.1.
> In the test harness, setting {{PX_PHERF=1}} enables the Distributed Pherf
> tier. With this flag set, {{px-cluster}} build compiles the distributed
> module and builds the pherf container image, and the Compose topology
> generator adds the controller and agent fleet as an on-demand role group.
> Fleet lifecycle operations are handled by {{px-pherf}}. Its run subcommand
> validates the target test plan, starts a cluster with the fleet tier enabled
> if no cluster is active, starts the fleet daemons, runs the requested
> workload suite, and tears down only the resources it created. In dry-run
> mode, it prints the exact command sequence a live run would execute and, when
> no active cluster exists, runs the full read-only bring-up preflight check so
> any topology exceeding engine memory capacity is rejected before starting
> containers. Setting {{PX_PHERF_TARGET=external}} directs the managed fleet to
> an external HBase cluster instead of a locally provisioned one.
> The {{pherf-distributed}} driver implements the harness driver interface.
> Running inside the controller container, it posts the rendered test plan to
> the controller REST API, polls until the run reaches a terminal state, copies
> the finalized controller bundle into the parent harness bundle directory, and
> extracts aggregate fleet metrics, the merged latency report, per-slot work
> allocations, and measured start skew. It also appends the fleet health
> verdicts directly to the harness verdict stream.
> The harness provides four built-in fleet workload suites: {{fleet}} runs a
> baseline open-loop distributed workload, {{fleet-rww}} performs deterministic
> co-generated read-what-you-wrote verification, {{fleet-rules}} runs a legacy
> rule based closed loop workload, and {{fleet-ab}} runs paired A and B
> replicate sets differing by one table DDL attribute before comparing their
> merged latency histograms with {{px-bundle analyze}}. A salted variant of the
> fleet table schema spreads regions across all active RegionServers so fault
> injection experiments on the default cluster topology always hit live fleet
> traffic regardless of which server is targeted.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)