Hi Avishek,
Thanks for the detailed reply, and nice work on the KIP. The motivation is
clear, and having the draft PR next to the page made it much easier to
review.
Since my last email I went through KIP-1404 and PR 24363 against the 4.4
branch and thought about where KIP-1267 fits. Answers to your two questions
first, then review comments on 1404, then how I plan to line 1267 up with
it.
*1. Separate KIPs *
Yes, two KIPs with a one-way dependency.
KIP-1404 is the broker side: who requested the remote read, the bounded key
(user, optional topic, optional client-id), TTL and max.keys, and the
request/byte counts the broker can see. No RSM change, so it can go first
and does not depend on anything in 1267.
KIP-1267 moves to the storage side in its next revision: what the plugin
actually did for that request (provider calls, retries, bytes transferred,
provider latency, cache hits), attributed to the same key. That needs a
backward-compatible RemoteStorageManager extension, which is a different
kind of change and is better discussed on its own. It will reuse your group
(remote-fetch-principal-metrics), your tags and tag flags, and your
remote.fetch.principal.metrics.* configs.
Merging would make 1404 wait on an SPI discussion it does not need.
One small ask so the boundary holds in both directions: 1404 stays on the
broker side as it is today (no RSM changes), and since I am committing to
drive the storage-layer part in 1267, its Future Work section points to
KIP-1267 for that. Then the SPI design is discussed in one thread.
On shared limits: agreed. I would write it into 1267 as a public rule ("a
broker tracks at most max.keys keys across both KIPs' attributes") and
leave how the implementation enforces it to the PRs. Kafka Metrics already
puts same-group, same-tags metrics on one MBean regardless of which class
registers them, so "same MBean" comes for free from the contract.
2. *How 1267 gets storage-level numbers*
You are right that the broker cannot derive them. One RemoteLogReader task
can be several index and segment calls, the plugin can retry or read ahead,
and a cache hit may touch the store zero times. So the numbers have to come
from the plugin. Plan for the revision:
- Default, context-aware overloads on RemoteStorageManager for
fetchLogSegment (both forms) and fetchIndex. The defaults delegate to the
existing methods, so current plugins are unchanged and simply report
nothing. RemoteLogMetadataManager already has default methods
(nextSegmentWithTxnIndex, isReady), so there is precedent. I will also look
at a single request-object method instead of overloads; two 3-arg
fetchLogSegment methods are legal but ugly.
- The context carries a broker-owned, no-op-by-default observer bound to
the KIP-1404 key admitted for that read. The plugin (or an SDK interceptor)
reports attempts, retries, outcomes, latency, bytes and, where the plugin
can define it, cache outcome through it. The plugin never creates
per-principal sensors, so cardinality stays under your max.keys.
- RemoteIndexCache passes the context on misses, and
ClassLoaderAwareRemoteStorageManager has to override the new overloads and
forward them; otherwise a plugin loaded from
remote.log.storage.manager.class.path never sees the context, because the
inherited default on the wrapper falls back to the old method.
- Precise definitions: whether a "request" is an SDK attempt, an HTTP
attempt or a completed operation; whether retries count; which byte
boundary is measured. Errors are a subset of requests. No pricing in Kafka.
- An explicit index-cache attribution rule (charge the triggering
principal, or a reserved broker key).
- A reference implementation plan (starting with LocalTieredStorage and
targeting a real RSM plugin), ideally with a plugin maintainer co-authoring
or reviewing the SPI, I would welcome a plugin maintainer as co-sponsor.
*3. Names*
To answer your first question directly: the current 1267 page proposes
kafka.server:type=RemoteFetchMetrics with RemoteFetchBytesPerSec,
RemoteFetchRequestsPerSec, RemoteFetchLatency and RemoteFetchErrorsPerSec,
tagged by client-id and topic (partition and error-type optional). In the
revision the broker-side request/byte series go away in favor of yours, so
no overlap with remote-fetch-byte-* / remote-fetch-request-*. 1267's
attributes sit on your group and tags with a remote-storage-provider-
prefix: request-rate/-total, byte-rate/-total, error-rate/-total (a subset
of requests), latency-avg/-max (plugin-observed provider latency, distinct
from the broker-side RemoteLogReaderFetchRateAndTimeMs timer), and, if
plugins can report it consistently, cache-hit-total. None of these names
exist in 4.4.0. If 1267 later needs finer breakdowns (for example segment
versus index operations), there would be additional attributes on the same
key, never new tags, so your key and cardinality contract are untouched.
4. *Review comments on KIP-1404*
Roughly in order of importance. None of them change the metric names, tags
or configs.
4.1 Fetch v4-10. FetchParams.clientMetadata is only populated for v11+
(KafkaApis gates it on versionId >= 11, because it exists for
preferred-replica selection). 4.4 still accepts v4-10, so those reads will
not be attributed. Old clients, but inside the supported protocol range.
The PR's config doc says so; the KIP page says no new KafkaApis plumbing is
needed and does not mention it. Filling in ClientMetadata for old versions
is not an option, since FetchParams.fetchOnlyLeader() and the
ReplicaSelector path key off its presence. Suggestion: a small internal
RemoteFetchRequester(KafkaPrincipal, clientId) in server-common, captured
in KafkaApis for every consumer Fetch and for ShareFetch, carried via
FetchParams (one new constructor; four non-test call sites in three
classes) and RemoteStorageFetchInfo. Neither is a public API. Keeping the
KafkaPrincipal rather than just its name also gives 1267 something to bind
the plugin context to later, on the broker side, without a second identity
type; the plugin itself would only see an opaque context, never the
principal.
4.2 Config table. All five settings are marked cluster-wide, but only
enable is in DynamicRemoteLogConfig in the PR. The prose under the table
already says the key-shape flags and the TTL are read at startup, and
max.keys is not covered either way. Operators who follow the table get
"Cannot update these configs dynamically". Suggest: fix the table; keep
topic.enable and client.id.enable static (changing tags changes
ObjectNames); decide ttl.ms and max.keys explicitly, either dynamic with
simple semantics (a new TTL applies to new keys; a smaller cap stops
admissions and never evicts) or read-only with the reason stated.
4.3 Bytes. The request definition is good. For bytes, "returned to the
fetch" is not quite right: DelayedRemoteFetch and DelayedShareFetch cancel
with cancel(false), so a running read completes and records bytes after the
client-facing operation has expired. Suggest: "records.sizeInBytes() of a
successful RemoteLogManager.read; logical record bytes, excluding index
transfer, provider overhead, retries and read-ahead; counted even if the
delayed fetch already expired." Also worth stating when per-principal
totals reconcile with the topic meter (no drops, expiry, disable or restart
in the interval), and that a Kafka Metrics Rate and a Yammer meter rate
will not match at a given instant.
4.4 Provenance. RemoteFetch{Requests,Bytes,Errors}PerSec came from the
KIP-405 implementation (KAFKA-14953 added them as RemoteReadRequestsPerSec
/ RemoteBytesInPerSec / RemoteReadErrorsPerSec; KAFKA-15236 renamed them).
KIP-963 added DelayedRemoteFetchMetrics/ExpiresPerSec and the
copy/delete/aux-state metrics; its table does not include the trio. The KIP
attributes them to KIP-963 in several places.
4.5 Lifecycle. The broker Metrics instance already sweeps expired sensors
every 30 s, and the quota and RLM sensors use SensorAccess with a fixed 1 h
expiry and no reaper. Worth naming that convention and saying what the
custom tracker adds (the max.keys cap, a configurable TTL, its own reaper).
Two PR-level points:
- disable sets a volatile flag and then clear()s; a reader that already
passed the flag check can re-insert a key. Bounded, and it self-heals
within TTL plus one sweep, but the KIP says disable removes all metrics. A
generation counter bumped under the lock, with stale completions treated as
no-ops, fixes it. Either way disable must not wait for in-flight reads:
reconfigure runs under the dynamic-config write lock.
- request and byte lookups are independent, so at capacity a read
refused at start can record bytes later if a slot frees (request-total 0).
Either a per-read context with completion in finally (call() catches
Exception, not Error), or say in the KIP that the split is tolerated, as it
is for quota sensors.
4.6 Disabled overhead and TTL bound. The reaper starts even when the
feature is disabled. Cheap (one idle daemon, tiered-storage brokers only),
but "no overhead" is too strong. ttl.ms accepts 1 ms and the sweep is
min(ttl, 30 s), so 1 ms means about a thousand sweeps per second. Either
atLeast(30000), or fix the TTL at 1 h like the quota sensors and drop the
config.
4.7 Tags. The PR sanitizes user, topic and client-id. Quota metrics
sanitize the user and pass client-id raw; JmxReporter quotes values when
needed. Suggest the same here. Topic is a no-op either way. For a blank
client-id, JmxReporter already drops empty tags from the ObjectName, so you
could keep the user attribution rather than skip the read. The trade-off is
that those MBeans then have a different ObjectName shape (no client-id key)
from populated ones, which JMX exporter rules need to allow for; skipping
the read avoids that at the cost of losing the data. Either is fine if the
KIP says which.
4.8 Security. With the default user-only key the exposure matches quota
metrics. With topic or client-id enabled it is new: which principal read
which topic from the remote tier. Worth scoping the text to that, noting
that ACLs do not cover JMX or exporters, and that on PLAINTEXT, or TLS
without client auth, every client is ANONYMOUS.
4.9 Internal readers. ShareGroupDLQRecordFetcher fetches with
CONSUMER_REPLICA_ID and empty clientMetadata; if the offset is tiered it
reaches the remote path with no requester. If you add a "dropped, no
identity" counter (I would suggest one, untagged, plus a "dropped at
capacity" one), exclude internal readers or give them a reserved requester.
Both counters would be new public metrics, so they belong in the Public
Interfaces section before the vote.
4.10 Motivation. "which principals are affected when remote reads fail or
slow down" reads as if there were per-principal error or latency metrics.
"which principals have remote-read activity during an incident" is what the
four attributes support.
4.11 Tests I would add: v4-10 and v11+; ShareFetch end to end; disable
while a read is blocked inside the plugin; disable racing a record;
refused-at-capacity then completes; special characters in user and
client-id checked on both the tag and the ObjectName; the
LocalTieredStorage test from the KIP with the reconciliation conditions
stated.
For the vote I would want the KIP-page items settled: 4.1 to 4.4, the
lifecycle and TTL statements in 4.5 and 4.6, and the wording in 4.8 and
4.10. The PR-behavior items can land before merge.
5.*Where 1267 goes*
Next revision: adopt your group, tags and configs; drop the broker-side
series; state the max.keys union rule; specify the RSM overloads, the
observer, and RemoteIndexCache and ClassLoaderAwareRemoteStorageManager
forwarding, with isolated-classpath tests; define provider request, byte,
latency and error semantics; keep pricing out of Kafka; include a reference
implementation plan.
Happy to pair on the requester context and the observer API once 1404's
shape settles, and to review the next PR revision.
Best regards,
Viquar Khan
https://www.linkedin.com/in/vaquar-khan-b695577/
On Sat, 28 Nov 2026 at 22:43, Avishek Das <[email protected]> wrote:
> Hello Viquar,
>
> Thanks for the quick and constructive reply, and for KIP-1267, which was
> the starting point for this work. I agree with the split: KIP-1404 covers
> who reads from remote storage (broker-side identity and volume), and
> KIP-1267 covers what those reads cost at the storage layer.
>
> Would you prefer to keep two KIPs with a clear dependency? I lean towards
> keeping them separate, since 1404 is small and can land first, but I'm open
> to either.
>
> One point I'd like to settle early: the number of requests made to S3 or
> GCS depends on the plugin. A single Kafka fetch can turn into several
> storage requests inside the plugin (for example the Aiven plugin splits it
> into chunk reads and index lookups, and may skip the store entirely on a
> cache hit). Because of that, the broker cannot compute storage request
> counts or cost from what it sees.
>
> In cases like this, where one Kafka fetch turns into a plugin-dependent
> number of S3 or GCS requests, how does KIP-1267 plan to get the
> storage-level numbers? Do you have an approach in mind?
>
> I'd be glad to align the two. Here is a concrete proposal I have in mind,
> and I'd welcome your thoughts:
>
> - Same key. KIP-1267 would use the same tags as KIP-1404: user (always),
> topic and client-id (optional, off by default). This lets operators join
> the two sets of metrics directly.
> - Same group and naming. Both KIPs would use kebab-case names in the
> Metrics registry, in the group remote-fetch-principal-metrics
> (kafka.server:type=remote-fetch-principal-metrics). Cost metrics from
> KIP-1267 would be extra attributes on the same MBean, so no new keys are
> created.
> - Shared limits. KIP-1267 would reuse the TTL and max.keys settings from
> KIP-1404, so there is one cardinality budget and no second set of
> configs.
> - No duplicate series. KIP-1404 keeps request and byte counts as seen by
> the broker. KIP-1267 adds only what the broker cannot see, such as
> storage
> requests, bytes transferred, or egress cost.
>
> Two questions: -
> - Which metric names and tags does KIP-1267 currently propose? I'd like
> to avoid any overlap with remote-fetch-byte-* and
> remote-fetch-request-*.
> - Would you prefer to keep two KIPs with a clear dependency, or merge
> them? I lean towards keeping them separate, since 1404 is small and can
> land first, but I'm open to either.
>
>
>
>
> On Sun, Nov 29, 2026 at 12:58 AM vaquar khan <[email protected]>
> wrote:
>
> > Hi Avishek,
> >
> > Thank you for putting together KIP-1404 and for referencing my earlier
> > proposal, KIP-1267 (KAFKA-20047).
> >
> > As the author of KIP-1267, I originally introduced the multi-tenant
> > remote-read attribution architecture to solve the exact visibility gap
> > around identifying noisy neighbors and attributing tiered storage fetches
> > beyond topic-level aggregates
> > https://lists.apache.org/thread/vvl5lpw64kvvgrr718pnztdltc2p6vb4
> > <[https://lists.apache.org/thread/vvl5lpw64kvvgrr718pnztdltc2p6vb4>
> >
> > Dividing the design between broker-side requester identity
> > (KafkaPrincipal, topic, and optional client-id in RemoteLogReader) in
> > KIP-1404 and storage-layer cost attribution in KIP-1267 is a clean
> > separation of concerns that prevents duplicate metric series.
> >
> > I would be happy to collaborate on aligning the tag conventions and
> metric
> > naming across both KIPs so operators can correlate broker-level principal
> > fetch volume with storage-tier egress costs.
> >
> > +1
> >
> > Best regards,
> >
> > Viquar Khan
> >
> > https://www.linkedin.com/in/vaquar-khan-b695577/
> >
> > On Sat, 28 Nov 2026 at 12:25, Avishek Das <[email protected]> wrote:
> >
> > > Hi all,
> > > Bumping this thread for review. I'd appreciate your feedback on
> KIP-1404.
> > >
> > > On Thu, Nov 26, 2026 at 4:52 PM Avishek Das <[email protected]>
> > wrote:
> > >
> > > > Hi all,
> > > >
> > > > I would like to start the discussion on KIP-1404: Per-Principal
> Remote
> > > > Storage Fetch Metrics.
> > > >
> > > > This is my first KIP. The implementation is already available as a
> > draft
> > > > PR, and it needs review. I know the usual order is KIP first, so
> please
> > > > treat the PR only as a reference for the design. I am happy to change
> > > > either one based on the discussion.
> > > >
> > > > KIP:
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/KIP-1404%3A+Per-Principal+Remote+Storage+Fetch+Metrics
> > > >
> > > > JIRA: https://issues.apache.org/jira/browse/KAFKA-21643
> > > >
> > > > PR (draft): https://github.com/apache/kafka/pull/24363
> > > >
> > > > Summary: KIP-1404 adds opt-in metrics (off by default) that show
> which
> > > > principal reads from remote (tiered) storage, and optionally which
> > topic
> > > > and client-id. Today the KIP-963 metrics are per topic only. The new
> > > > metrics are keyed by the authenticated principal, created only for
> > > > principals that actually read remote data, removed after a TTL of
> > > > inactivity, and bounded by a per-broker maximum. No protocol, client
> or
> > > > plugin changes are needed.
> > > >
> > > > Thanks in advance for your time and feedback.
> > > > --
> > > > Thanks,
> > > > *Avishek Das* <https://www.linkedin.com/in/imavishek/>
> > > > SMTS At Salesforce <https://www.linkedin.com/company/salesforce/>
> > > >
> > >
> >
>
>
> --
> Thanks again,
> Avishek
>