public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Jonas Theisen <j.theisen@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH http-server,apiclient,manager 00/09] async and streaming pull metric export
Date: Tue, 1 Dec 2026 11:13:52 +0100	[thread overview]
Message-ID: <94955cd5-2439-439a-bbdc-d1a27f689a9e@proxmox.com> (raw)
In-Reply-To: <20261130010113.2166775-1-t.lamprecht@proxmox.com>

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.
>
> <snip>

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 <j.theisen@proxmox.com>




  parent reply	other threads:[~2026-12-01 10:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  0:58 [PATCH http-server,apiclient,manager 00/09] async and streaming pull metric export Thomas Lamprecht
2026-11-30  0:58 ` [PATCH http-server 01/09] response: support deferred async API2 responses Thomas Lamprecht
2026-11-30  0:58 ` [PATCH http-server 02/09] proxy: strip chunked framing headers from decoded responses Thomas Lamprecht
2026-11-30  0:58 ` [PATCH http-server 03/09] response: support incremental streaming API2 responses Thomas Lamprecht
2026-11-30  0:58 ` [PATCH apiclient 04/09] add non-blocking AnyEvent API client Thomas Lamprecht
2026-11-30  0:58 ` [PATCH apiclient 05/09] add bounded AnyEvent request pool with backpressure and timeout Thomas Lamprecht
2026-11-30  0:58 ` [PATCH manager 06/09] api: metrics export: fetch remote nodes asynchronously Thomas Lamprecht
2026-11-30  0:58 ` [PATCH manager 07/09] api: metrics export: stream sorted metrics via incremental k-way merge Thomas Lamprecht
2026-11-30  0:58 ` [PATCH manager 08/09] api: metrics export: add unsorted pass-through streaming option Thomas Lamprecht
2026-11-30  0:58 ` [PATCH manager 09/09] test: add pull metric export test suite Thomas Lamprecht
2026-12-01 10:13 ` Jonas Theisen [this message]
2026-12-01 10:22 ` superseded: [PATCH http-server,apiclient,manager 00/09] async and streaming pull metric export Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94955cd5-2439-439a-bbdc-d1a27f689a9e@proxmox.com \
    --to=j.theisen@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal