From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 16CED1FF09F for ; Tue, 01 Dec 2026 11:14:00 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5D25C2135D; Tue, 01 Dec 2026 11:13:56 +0100 (CET) Message-ID: <94955cd5-2439-439a-bbdc-d1a27f689a9e@proxmox.com> Date: Tue, 1 Dec 2026 11:13:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH http-server,apiclient,manager 00/09] async and streaming pull metric export To: Thomas Lamprecht , pve-devel@lists.proxmox.com References: <20261130010113.2166775-1-t.lamprecht@proxmox.com> Content-Language: en-US From: Jonas Theisen In-Reply-To: <20261130010113.2166775-1-t.lamprecht@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796120032543 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.092 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SVORXY3W2SSCDK4KS64ZYZXMW5547EL3 X-Message-ID-Hash: SVORXY3W2SSCDK4KS64ZYZXMW5547EL3 X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 11/30/26 02:01, Thomas Lamprecht wrote: > GET /cluster/metrics/export runs inside pveproxy's three AnyEvent > workers and is polled regularly by Proxmox Datacenter Manager (PDM) via > /api2/extjs/cluster/metrics/export (often with history=1) as well as > external /api2/json/ and pvesh consumers. > > Today, the endpoint fetches every remote cluster node serially with > blocking PVE::APIClient::LWP calls, stalling the worker event loop for > all other clients while waiting on peer responses. On larger clusters > or history scrapes, decoding all remote metrics into Perl hashes before > sorting and compressing also drives worker memory into gigabytes and > blocks the loop during JSON encoding and gzip compression. > > This series replaces the synchronous serial fan-out with non-blocking > concurrent peer fetches and incremental streaming responses across three > repositories: > > - pve-http-server (patches 1-3): add deferred async and incremental > streaming API2 responses (PVE::APIServer::AsyncStream) with on-the-fly > compression and backpressure, plus chunked proxy response framing > fixes. > - pve-apiclient (patches 4-5): add PVE::APIClient::AnyEvent as a > non-blocking counterpart to LWP.pm with fingerprint pinning and raw > body access, plus a bounded-concurrency request pool > (PVE::APIClient::AnyEvent::Pool). > - pve-manager (patches 6-9): switch GET /cluster/metrics/export to > bounded async fan-out (16 peers per export, 32 per worker), stream > timestamp-sorted metrics incrementally without decoding each metric > into Perl hashes, add an opt-in unsorted=1 pass-through streaming > mode, and add a test suite. > > Default unsorted=0 preserves the existing global timestamp order and > /api2/extjs/ envelope, so existing PDM and API clients benefit without > changes. Rolling cluster upgrades work in any node order because peer > fetches continue calling GET /api2/json/cluster/metrics/export with > local-only=1. > > Measured on a single pveproxy worker in a mock harness (25 ms per-peer > latency, TLS with SHA-256 pinning, gzip, 16-peer cap; scenarios are > nodes x guests, hist10 = 10 history generations; /ping HOL = concurrent > /ping latency on the same worker): > > Scenario | Mode | Total | TTFB | VmHWM | /ping HOL > --------------------+---------------+--------+-------+----------+-------------- > 25x100 latest | Sync LWP | 980ms | - | 105 MiB | 952 ms (max) > (25,475 metrics) | K-way stream | 188ms | 118ms | 83 MiB | 7.9 ms (max) > | Pass-through | 154ms | 2.3ms | 81 MiB | 6.6 ms (max) > 25x100 hist10 | Sync LWP | 2146ms | - | 337 MiB | 2194 ms (max) > (254,750 metrics) | K-way stream | 827ms | 129ms | 98 MiB | 5.3 ms (max) > | Pass-through | 744ms | 6.7ms | 92 MiB | 5.3 ms (med) > 100x100 latest | Sync LWP | 4445ms | - | 180 MiB | 4128 ms (max) > (101,900 metrics) | K-way stream | 644ms | 401ms | 90 MiB | 13.3 ms (max) > | Pass-through | 463ms | 2.8ms | 81 MiB | 13.7 ms (max) > 100x1000 | Buffered | 5.1 s | - | 973 MiB | - > (1,001,900 metrics) | K-way stream | 2969ms | 360ms | 103 MiB | 10.5 ms (max) > | Pass-through | 2790ms | 7.5ms | 93 MiB | 5.5 ms (med) > > Repo (build-)dependencies: > pve-manager -> pve-http-server, pve-apiclient > > pve-http-server and pve-apiclient are independent of each other and must > both be released before pve-manager, with pve-manager's Build-Depends > and Depends bumped to the resulting package versions on apply. > > Tested this series on a 9 node cluster including varying connection failures and blocks between hosts. Also connected to PDM. Didn't notice anything off. Performance was not reliably tested since the cluster does not include a lot of metrics. Consider this Tested-by: Jonas Theisen