<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://kroxylicious.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kroxylicious.io/" rel="alternate" type="text/html" /><updated>2026-11-27T11:02:39+00:00</updated><id>https://kroxylicious.io/feed.xml</id><title type="html">Kroxylicious</title><subtitle>Network proxy framework for Apache Kafka</subtitle><entry><title type="html">Ask the proxy: an MCP server for Kroxylicious</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/23/mcp-poc.html" rel="alternate" type="text/html" title="Ask the proxy: an MCP server for Kroxylicious" /><published>2026-11-23T10:00:00+00:00</published><updated>2026-11-23T10:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/23/mcp-poc</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/23/mcp-poc.html"><![CDATA[<p>The Kroxylicious team (<a href="https://github.com/orgs/kroxylicious/people">https://github.com/orgs/kroxylicious/people</a>) recently held an innovation day, a chance to step away from the roadmap and play with concepts that might be worth adding to the proxy one day. <a href="https://github.com/k-wall">k-wall</a>, <a href="https://github.com/henryZrncik">henryZrncik</a>, <a href="https://github.com/AdityaThakur1998">AdityaThakur1998</a> and I decided to find out what it would mean to give Kroxylicious an MCP server, and what that would let us do.</p>

<p>What follows is a proof of concept and nothing more. None of it is production code, and part of the fun was giving ourselves permission to drop code in without worrying about auth, error handling or any of the things we’d normally insist on. We wanted to see how far we could get in a day, not ship something. The code we wrote is at <a href="https://github.com/MarkNSweep/kroxylicious/tree/mcp-poc">https://github.com/MarkNSweep/kroxylicious/tree/mcp-poc</a>.</p>

<p>There was a serious question underneath the play, though. Kroxylicious sits on the wire between Kafka clients and their clusters, so it already sees a lot of what’s going on. If an agent could ask the proxy what it knows, could it answer two questions users often ask: is the proxy healthy, and why isn’t my application working ?</p>

<h2 id="what-we-built">What we built</h2>

<p>The idea is simple. The proxy already has a runtime that knows its own state, its configuration and its metrics. An MCP server sitting alongside that runtime can expose those as tools, and an agent can call them to reason about what the proxy is seeing. Client applications carry on talking Kafka to the runtime as they always have. The agents talk MCP to the MCP server, and the MCP server asks the runtime for whatever the agent wants to know.</p>

<p><img src="/assets/blog/images/mcp-poc/kroxylicious-mcp-overview.svg" alt="Kroxylicious contains a runtime and an MCP server. Client applications connect to the runtime over the Kafka protocol. Agents connect to the MCP server over MCP. The MCP server reads state, configuration, metrics and exchange history from the runtime to answer the agents." /></p>

<p>The first step was to add MCP protocol support using Netty, and have it start alongside the proxy. There’s no authentication, as this is a proof of concept and we wanted to spend the day exploring rather than wiring up security. With the server running, we challenged ourselves to see whether an agent could answer questions about the proxy at all.</p>

<p>To make the answers worth having, we needed the proxy to record a bit more about what its clients were doing. We added a simple internal filter that records the client id an application uses when it makes requests, and exposed that through a tool. The purpose was to associate applications with connections, so activity could be correlated back to a named application rather than an anonymous socket. We also exposed the proxy’s existing metrics as tools, so the agent could read the same numbers an operator would look at.</p>

<p>By the end of the day the MCP server offered the following tools.</p>

<p>Proxy introspection:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">get_proxy_status</code> gets the current status, lifecycle state and uptime of the proxy.</li>
  <li><code class="language-plaintext highlighter-rouge">get_proxy_config</code> gets the current proxy configuration.</li>
  <li><code class="language-plaintext highlighter-rouge">list_virtual_clusters</code> lists the configured virtual clusters, gateways and target clusters.</li>
  <li><code class="language-plaintext highlighter-rouge">list_filter_definitions</code> lists the configured filter definitions and default filters.</li>
  <li><code class="language-plaintext highlighter-rouge">list_connected_clients</code> lists the client ids of currently connected clients, with the time each client’s <code class="language-plaintext highlighter-rouge">ApiVersions</code> request was seen.</li>
</ul>

<p>Metrics:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">get_metrics_summary</code> summarises the registered metrics, their types and labels, so the agent can discover what’s available.</li>
  <li><code class="language-plaintext highlighter-rouge">get_metric</code> gets the current value of one metric series by name and labels.</li>
  <li><code class="language-plaintext highlighter-rouge">get_connection_metrics</code> gets the client-to-proxy and proxy-to-server connection counts, active connection gauges, errors and client disconnects.</li>
  <li><code class="language-plaintext highlighter-rouge">get_message_metrics</code> gets the Kafka request and response counts and size distributions on both sides.</li>
  <li><code class="language-plaintext highlighter-rouge">get_reconfiguration_metrics</code> gets the reconfiguration outcomes, duration and per-cluster operation outcomes.</li>
  <li><code class="language-plaintext highlighter-rouge">get_virtual_cluster_lifecycle_metrics</code> gets the current state of each virtual cluster, time spent in each state and the transition counts.</li>
  <li><code class="language-plaintext highlighter-rouge">get_authentication_metrics</code> gets the client authentication outcomes by virtual cluster and mechanism.</li>
</ul>

<p>Diagnostics:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">get_client_exchanges</code> gets the last five request and response exchanges for every connection made by a named application. More on this one below, as it’s the tool that made the difference.</li>
</ul>

<h2 id="is-the-proxy-healthy-">Is the proxy healthy ?</h2>

<p>The first question we put to the agent was the obvious one.</p>

<blockquote>
  <p>what is the health of Kroxy</p>
</blockquote>

<p><strong>The agent replied</strong>:</p>

<p>The proxy is up and idle. I only have a summary view, so I can’t see the actual metric values.</p>

<ul>
  <li><strong>State:</strong> <code class="language-plaintext highlighter-rouge">STARTED</code></li>
  <li><strong>Clients:</strong> none connected.</li>
  <li><strong>Memory:</strong> about 24 MB of heap is committed out of a 2.6 GB maximum, and about 4.4 MB of that is free. That is normal for a JVM that has just started and has little load, because the heap grows on demand.</li>
  <li><strong>CPU:</strong> 9 processors are available.</li>
  <li><strong>JRE:</strong> version 27.</li>
</ul>

<p>That’s a reasonable answer from the handful of tools it had at that point. The agent read the state, noticed nothing was connected, and was honest about the fact that it only had a summary view of the metrics rather than the values themselves.</p>

<h2 id="why-isnt-my-application-working-">Why isn’t my application working ?</h2>

<p>The more interesting question is the diagnostic one, so we took a Kafka application that was failing and asked the agent to work out why. We’d set the application up to fail by giving it an invalid password for the SASL exchange, so the real answer was an authentication failure.</p>

<blockquote>
  <p>I have a Kafka application called producer which is failing to send messages to Kafka, why is that?</p>
</blockquote>

<p><strong>The agent answered</strong>:</p>

<p>I can’t say yet why the producer fails. The proxy shows no evidence that the producer ever reached it.</p>

<p><strong>What I verified from the proxy</strong></p>

<ul>
  <li>The proxy state is <code class="language-plaintext highlighter-rouge">STARTED</code>.</li>
  <li>Virtual cluster <code class="language-plaintext highlighter-rouge">demo</code> is <code class="language-plaintext highlighter-rouge">serving</code>. It has one gateway, <code class="language-plaintext highlighter-rouge">sni</code>, and uses direct routing. It never entered <code class="language-plaintext highlighter-rouge">failed</code>.</li>
  <li>There are no connected clients.</li>
  <li>The message metrics are empty, so no Kafka requests have been seen.</li>
  <li>The authentication metrics are empty, so no SASL attempts have been made.</li>
  <li>There is one connection metric, <code class="language-plaintext highlighter-rouge">client_to_proxy_errors</code>, and it is 0. It is tagged <code class="language-plaintext highlighter-rouge">virtual_cluster=""</code> and <code class="language-plaintext highlighter-rouge">node_id=bootstrap</code>. That tag set means a connection arrived without matching any virtual cluster.</li>
  <li>No filters are configured. Filters aren’t blocking the producer.</li>
</ul>

<p><strong>Likely causes</strong></p>

<p>The producer fails before it reaches the proxy. The cause is probably one of these:</p>

<ol>
  <li><strong>Wrong bootstrap address.</strong> The <code class="language-plaintext highlighter-rouge">sni</code> gateway is <code class="language-plaintext highlighter-rouge">sniHostIdentifiesNode</code>. It only accepts TLS connections whose SNI is <code class="language-plaintext highlighter-rouge">bootstrap.dev.kroxy.test:19192</code>. The producer must use that exact name and port. Using <code class="language-plaintext highlighter-rouge">localhost:9192</code> or the Kafka address <code class="language-plaintext highlighter-rouge">kafka.kroxy.test:9094</code> won’t work.</li>
  <li><strong>DNS can’t resolve the name.</strong> <code class="language-plaintext highlighter-rouge">bootstrap.dev.kroxy.test</code> and <code class="language-plaintext highlighter-rouge">broker-&lt;n&gt;.dev.kroxy.test</code> must both resolve to the proxy. The <code class="language-plaintext highlighter-rouge">broker-&lt;n&gt;</code> names matter because the proxy advertises them after the first metadata call. The symptom is that the producer bootstraps and then times out on metadata or on send.</li>
  <li><strong>The producer uses plaintext, or doesn’t trust the CA.</strong> The gateway requires TLS. The producer needs <code class="language-plaintext highlighter-rouge">security.protocol=SSL</code> and a truststore containing the CA that issued <code class="language-plaintext highlighter-rouge">/certs/tls.crt</code>. The certificate must also cover both the <code class="language-plaintext highlighter-rouge">bootstrap.dev.kroxy.test</code> and <code class="language-plaintext highlighter-rouge">*.dev.kroxy.test</code> names.</li>
  <li><strong>A named-groups mismatch.</strong> The gateway only allows <code class="language-plaintext highlighter-rouge">X25519MLKEM768</code> and <code class="language-plaintext highlighter-rouge">secp256r1</code>. A producer whose JVM supports neither group can’t complete the handshake. This is plausible, because the config is named <code class="language-plaintext highlighter-rouge">namedgroups</code>. A JRE older than 24 can’t offer <code class="language-plaintext highlighter-rouge">X25519MLKEM768</code>, so it would have to use <code class="language-plaintext highlighter-rouge">secp256r1</code>.</li>
  <li><strong>The producer isn’t running or isn’t pointed at this proxy.</strong> <code class="language-plaintext highlighter-rouge">list_connected_clients</code> is empty.</li>
</ol>

<p><strong>What I need</strong></p>

<ul>
  <li>The producer’s <code class="language-plaintext highlighter-rouge">bootstrap.servers</code> and <code class="language-plaintext highlighter-rouge">security.protocol</code> settings.</li>
  <li>The producer’s exception, such as a timeout or SSL handshake error.</li>
  <li>The producer’s Java version.</li>
</ul>

<p>With those I can narrow it to one cause.</p>

<p>This is a good answer in that it’s thorough and it’s honest, however it’s wrong. The agent reasoned that the application had never reached the proxy, as there was no record of it having done so, and went off down a list of connectivity causes. The real failure, an invalid SASL password, isn’t on the list. The agent couldn’t see it, as the proxy wasn’t keeping any record of the exchanges it had actually handled.</p>

<p>So we gave it that record. We added another internal filter, this one recording the last five request and response exchanges from each client, and exposed it through the <code class="language-plaintext highlighter-rouge">get_client_exchanges</code> tool. This filter would need a lot of work before anyone could take it seriously for production (holding request and response history per connection has obvious cost and lifecycle questions), but as this was a proof of concept it was all good, and it let us test the idea in an afternoon.</p>

<p>We asked again.</p>

<blockquote>
  <p>I have a Kafka application called myapp which is failing to send messages to Kafka, why is that?</p>
</blockquote>

<p><strong>This time the agent replied</strong>:</p>

<p><code class="language-plaintext highlighter-rouge">myapp</code> is failing SASL authentication on the <code class="language-plaintext highlighter-rouge">demo</code> virtual cluster due to invalid credentials.</p>

<h3 id="details-from-exchange-history">Details from exchange history</h3>

<ol>
  <li><strong>Handshake:</strong> <code class="language-plaintext highlighter-rouge">myapp</code> negotiates SASL mechanism <code class="language-plaintext highlighter-rouge">SCRAM-SHA-512</code>.</li>
  <li>
    <p><strong>Authentication failure:</strong> The proxy rejects the second <code class="language-plaintext highlighter-rouge">SASL_AUTHENTICATE</code> request with error code <code class="language-plaintext highlighter-rouge">58</code> (<code class="language-plaintext highlighter-rouge">SASL_AUTHENTICATION_FAILED</code>):</p>

    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-512
</code></pre></div>    </div>
  </li>
  <li><strong>Impact:</strong> The connection terminates immediately after authentication failure, preventing <code class="language-plaintext highlighter-rouge">myapp</code> from sending <code class="language-plaintext highlighter-rouge">PRODUCE</code> or metadata requests.</li>
</ol>

<h3 id="next-steps">Next steps</h3>

<p>Check the username and password configured in <code class="language-plaintext highlighter-rouge">myapp</code>’s SASL JAAS config or credential store and ensure they match the credentials registered for SCRAM-SHA-512 authentication.</p>

<p>That’s the answer we were after. With the exchange history available, the agent went straight to the cause, named the mechanism, quoted the error, and told the user where to look. The one extra tool is the whole difference between the two attempts. The agent’s reasoning was sound both times, it just needed the proxy to tell it what had happened.</p>

<p>We retried the health question too, now that there was more for the agent to read.</p>

<blockquote>
  <p>what is the health of kroxy?</p>
</blockquote>

<p><strong>The agent replied</strong>:</p>

<p>Kroxylicious is <strong>healthy and operational</strong>.</p>

<h3 id="status-summary">Status summary</h3>

<ul>
  <li><strong>Proxy state:</strong> <code class="language-plaintext highlighter-rouge">STARTED</code> (JRE 27, 9 available processors, ~39.8 MB heap allocated out of 2.6 GB max)</li>
  <li><strong>Virtual cluster (<code class="language-plaintext highlighter-rouge">demo</code>):</strong> <code class="language-plaintext highlighter-rouge">SERVING</code> (1.0)</li>
  <li><strong>Errors:</strong> <code class="language-plaintext highlighter-rouge">0</code> internal client-to-proxy errors, <code class="language-plaintext highlighter-rouge">0</code> proxy-to-server errors</li>
  <li><strong>Connections:</strong>
    <ul>
      <li>Active downstream: <code class="language-plaintext highlighter-rouge">0</code></li>
      <li>Active upstream: <code class="language-plaintext highlighter-rouge">0</code></li>
      <li>Total connections handled: <code class="language-plaintext highlighter-rouge">81</code> (all past disconnections resulted from normal client closes or auth failure teardowns)</li>
    </ul>
  </li>
</ul>

<p>With the connection metrics and exchange history to draw on, the health answer is richer than the first one. It can now talk about how many connections have been handled and account for how they ended, rather than just reporting that nothing is connected right now.</p>

<h2 id="what-we-learned">What we learned</h2>

<p>The thing that stood out is how closely the quality of the answer tracked the tools we gave the agent. The reasoning was capable throughout. What held it back on the first diagnostic attempt was that the proxy simply wasn’t recording the information needed to answer the question. As soon as it was, the agent found the problem on its own. Kroxylicious is in an unusual position here, as it sees both sides of every conversation, so the more of what it sees it’s willing to expose, the more an agent can do with it.</p>

<p>To recap, in one day we set out to explore what MCP could add to Kroxylicious, added an MCP server that starts with the proxy, wrote a couple of internal filters to record the client id and recent exchanges, and used an agent to answer the two questions users frequently ask: is the proxy healthy, and why isn’t my application working. None of it is production quality, and it was all the more enjoyable for not having to be.</p>

<h2 id="over-to-you">Over to you</h2>

<p>We’d like to know how interested people would be in adding MCP capabilities to the Kroxylicious project, and what problems you think it would help you solve. If an agent that could ask the proxy what it knows would be useful to you, we’d like to hear about it.</p>]]></content><author><name>Adam Pilkington</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="mcp" /><summary type="html"><![CDATA[The Kroxylicious team (https://github.com/orgs/kroxylicious/people) recently held an innovation day, a chance to step away from the roadmap and play with concepts that might be worth adding to the proxy one day. k-wall, henryZrncik, AdityaThakur1998 and I decided to find out what it would mean to give Kroxylicious an MCP server, and what that would let us do.]]></summary></entry><entry><title type="html">Kroxylicious release 0.26.0</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/11/19/release-0_26_0.html" rel="alternate" type="text/html" title="Kroxylicious release 0.26.0" /><published>2026-11-19T11:00:00+00:00</published><updated>2026-11-19T11:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/11/19/release-0_26_0</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/11/19/release-0_26_0.html"><![CDATA[<p>Kroxylicious 0.26.0 has hatched🐊!</p>

<p>0.26.0 picks up a critical OpenJDK security fix and resolves two high-severity vulnerabilities in the ACL authorizer. It also brings automatic downstream TLS certificate rotation, configurable post-quantum key exchange for both downstream and upstream TLS connections, client address visibility for filters, per-gateway PROXY protocol configuration, and container images for two new architectures. Take a look at <a href="https://github.com/kroxylicious/kroxylicious/blob/v0.26.0/CHANGELOG.md">all the changes</a>.</p>

<hr />

<h3 id="container-image-critical-openjdk-fix-rhsa-2026100567">Container Image: Critical OpenJDK Fix (RHSA-2026:100567)</h3>

<p>Kroxylicious’s container images install <code class="language-plaintext highlighter-rouge">java-21-openjdk-headless</code> from the UBI9 package repositories, so the 0.26.0 images incorporate Red Hat’s <a href="https://access.redhat.com/errata/RHSA-2026:100567">RHSA-2026:100567</a>, published the day before this release. That advisory is rated <strong>Critical</strong> and fixes nine CVEs in OpenJDK 21, including CVE-2026-114938, a remote code execution vulnerability via memory corruption on x86-64 systems with AVX-512 VBMI.</p>

<p>If you run the official Kroxylicious container images, upgrading to 0.26.0 picks up the fix. If you build your own images or run the proxy outside of our containers, make sure your JDK is patched independently.</p>

<hr />

<h3 id="security-advisories">Security Advisories</h3>

<h4 id="cve-2026-118952-principal-type-confusion-and-incomplete-prefix-matching-in-the-acl-authorizer">CVE-2026-118952: Principal Type Confusion and Incomplete Prefix Matching in the ACL Authorizer</h4>

<p><strong>Affected:</strong> Kroxylicious 0.18.0 through 0.25.1 when using the <code class="language-plaintext highlighter-rouge">kroxylicious-authorizer-acl</code> plugin with <code class="language-plaintext highlighter-rouge">like</code> (prefix) rules.</p>

<p><strong>Not affected:</strong> If you do not use the ACL authorizer, or you only use exact-match rules, you are not affected.</p>

<p><strong>Description:</strong> A <code class="language-plaintext highlighter-rouge">like</code> (prefix) rule written for one principal type (e.g. <code class="language-plaintext highlighter-rouge">Role</code>) could incorrectly match a principal of a different type that happens to share the same name prefix, and when rules had overlapping prefixes, a shorter, more restrictive rule could be silently skipped in favour of a longer one. In both cases, access could be granted that the rules file did not intend — with no indication that anything was wrong.</p>

<p><strong>Fix:</strong> Prefix matching now checks principal/resource type correctly and evaluates every applicable prefix, not just one, so rules are enforced as written.</p>

<p><strong>Advisory:</strong> <a href="https://github.com/kroxylicious/kroxylicious/security/advisories/GHSA-qvv3-6w3q-hgqc">GHSA-qvv3-6w3q-hgqc</a></p>

<h4 id="cve-2026-128424-overly-permissive-regex-unescaping-in-the-acl-authorizer">CVE-2026-128424: Overly Permissive Regex Unescaping in the ACL Authorizer</h4>

<p><strong>Affected:</strong> Kroxylicious 0.18.0 through 0.25.1 when using the <code class="language-plaintext highlighter-rouge">kroxylicious-authorizer-acl</code> plugin with <code class="language-plaintext highlighter-rouge">matching /…/</code> regex rules containing backslash escapes.</p>

<p><strong>Not affected:</strong> If you do not use the ACL authorizer, or your <code class="language-plaintext highlighter-rouge">matching</code> rules contain no backslash escapes, you are not affected.</p>

<p><strong>Description:</strong> The code that unquotes <code class="language-plaintext highlighter-rouge">matching /…/</code> literals stripped the backslash from every <code class="language-plaintext highlighter-rouge">\X</code> escape sequence, not just <code class="language-plaintext highlighter-rouge">\/</code> and <code class="language-plaintext highlighter-rouge">\\</code>. This turned intentionally-literal regex metacharacters such as <code class="language-plaintext highlighter-rouge">\.</code>, <code class="language-plaintext highlighter-rouge">\d</code>, <code class="language-plaintext highlighter-rouge">\w</code>, <code class="language-plaintext highlighter-rouge">\s</code>, and <code class="language-plaintext highlighter-rouge">\b</code> into their broader regex meaning — for example, a rule meant to match only the literal topic <code class="language-plaintext highlighter-rouge">orders.v1</code> was silently enforced as a pattern where <code class="language-plaintext highlighter-rouge">.</code> matched any character — so rules could grant access more broadly than the operator intended, with no indication anything was wrong.</p>

<p><strong>Fix:</strong> Unescaping is now restricted to the two sequences that should be literal, <code class="language-plaintext highlighter-rouge">\/</code> and <code class="language-plaintext highlighter-rouge">\\</code>; every other backslash escape passes through unchanged to the regex engine.</p>

<p><strong>Advisory:</strong> <a href="https://github.com/kroxylicious/kroxylicious/security/advisories/GHSA-x5xx-3j9w-x63g">GHSA-x5xx-3j9w-x63g</a></p>

<p>If you run the ACL authorizer with <code class="language-plaintext highlighter-rouge">like</code> or <code class="language-plaintext highlighter-rouge">matching</code> rules, upgrade to 0.26.0 and review your rules files for any that may have been relying on the old, overly-permissive behaviour.</p>

<hr />

<h3 id="automatic-downstream-tls-certificate-rotation">Automatic Downstream TLS Certificate Rotation</h3>

<p>A long-standing request (<a href="https://github.com/kroxylicious/kroxylicious/issues/104">#104</a>) is finally delivered: virtual cluster gateways now detect when their downstream TLS certificate or key material changes on disk and reload it automatically, with no proxy restart and no dropped connections. This is particularly useful alongside cert-manager or other automated certificate issuance pipelines.</p>

<h3 id="post-quantum-key-exchange-pqc">Post-Quantum Key Exchange (PQC)</h3>

<p>Following <a href="https://github.com/kroxylicious/design/blob/main/proposals/144-pqc-support.md">Design Proposal 144</a>, both downstream (client-facing) and upstream (cluster-facing) TLS gain new configuration to control post-quantum key exchange algorithms. Gateways and clusters can set a <code class="language-plaintext highlighter-rouge">namedGroups</code> attribute with <code class="language-plaintext highlighter-rouge">allowed</code> and <code class="language-plaintext highlighter-rouge">denied</code> lists — <code class="language-plaintext highlighter-rouge">allowed</code> also sets key exchange preference order — so you can opt in to PQC algorithms, or lock a connection down to only accept them. This isn’t enabled automatically; it’s an opt-in configuration you apply where you need it. Support for the PQC algorithms themselves comes from the JDK and varies by provider and version prior to Java 27.</p>

<h3 id="client-address-visible-to-filters">Client Address Visible to Filters</h3>

<p>Implementing <a href="https://github.com/kroxylicious/design/blob/main/proposals/139-expose-client-address-to-filters.md">Proposal 139</a>, <code class="language-plaintext highlighter-rouge">FilterContext</code> now exposes <code class="language-plaintext highlighter-rouge">clientAddress()</code>, <code class="language-plaintext highlighter-rouge">peerAddress()</code>, and <code class="language-plaintext highlighter-rouge">clientProxyProtocolContext()</code> to filters, so filter authors can make decisions based on where a connection actually originated — including through a PROXY protocol-aware load balancer. The <code class="language-plaintext highlighter-rouge">ProtocolLogger</code> filter has also been updated to include both addresses in its output.</p>

<h3 id="per-gateway-proxy-protocol-configuration">Per-Gateway PROXY Protocol Configuration</h3>

<p><strong>Breaking change:</strong> PROXY protocol configuration has moved from the top-level proxy configuration to each <code class="language-plaintext highlighter-rouge">virtualClusters[].gateways[]</code> entry (<a href="https://github.com/kroxylicious/kroxylicious/issues/5118">#5118</a>, <a href="https://github.com/kroxylicious/kroxylicious/pull/5263">#5263</a>). The <code class="language-plaintext highlighter-rouge">allowed</code> (auto-detect) mode has been removed, and <code class="language-plaintext highlighter-rouge">disabled</code> has been renamed <code class="language-plaintext highlighter-rouge">forbidden</code>, which is now the default. Move your <code class="language-plaintext highlighter-rouge">proxyProtocol</code> block inside each gateway that needs it, and rename <code class="language-plaintext highlighter-rouge">disabled</code> to <code class="language-plaintext highlighter-rouge">forbidden</code>.</p>

<h3 id="new-container-architectures">New Container Architectures</h3>

<p>Proxy, operator, and admission webhook container images are now also published for <code class="language-plaintext highlighter-rouge">linux/ppc64le</code> and <code class="language-plaintext highlighter-rouge">linux/s390x</code> (<a href="https://github.com/kroxylicious/kroxylicious/issues/4969">#4969</a>), in addition to the existing architectures. The proxy uses the NIO transport on these platforms.</p>

<hr />

<h3 id="other-changes-to-note">Other Changes to Note</h3>

<ul>
  <li>Maven 3.9.2+ is now required to build the project.</li>
  <li>Operator metrics have been migrated to the Java Operator SDK’s <code class="language-plaintext highlighter-rouge">MicrometerMetricsV2</code> names and labels; dashboards and alerts using the previous <code class="language-plaintext highlighter-rouge">operator_sdk_</code> metrics will need updating.</li>
</ul>

<p>See the <a href="https://github.com/kroxylicious/kroxylicious/blob/v0.26.0/CHANGELOG.md#0260">CHANGELOG</a> for the complete list of changes, deprecations, and removals.</p>

<h3 id="community-contributions">Community Contributions</h3>

<p>This release included commits from:</p>

<ul>
  <li><a href="https://github.com/AzazelSensei">Abdullah</a></li>
  <li><a href="https://github.com/MarkNSweep">Adam Pilkington</a></li>
  <li><a href="https://github.com/AdityaThakur1998">Aditya Thakur</a></li>
  <li><a href="https://github.com/carlesarnal">Carles Arnal</a></li>
  <li><a href="https://github.com/Divyanshkumar62">Divyansh Kumar</a></li>
  <li><a href="https://github.com/franvila">Francisco Vila</a></li>
  <li><a href="https://github.com/henryZrncik">henryZrncik</a></li>
  <li><a href="https://github.com/juliendcna">Julien Da Cunha</a></li>
  <li><a href="https://github.com/k-wall">Keith Wall</a></li>
  <li><a href="https://github.com/matheusandre1">Matheus André</a></li>
  <li><a href="https://github.com/ig-suyas">Naitik Singh</a></li>
  <li><a href="https://github.com/mapan1984">OuO</a></li>
  <li><a href="https://github.com/robobario">Robert Young</a></li>
  <li><a href="https://github.com/SamBarker">Sam Barker</a></li>
  <li><a href="https://github.com/tombentley">Tom Bentley</a></li>
  <li><a href="https://github.com/coder6955">Uday Vishnu Patil</a></li>
  <li><a href="https://github.com/2748109647">2748109647</a></li>
</ul>

<p>Thank you all, your hard work is massively appreciated!</p>

<h3 id="artefacts">Artefacts</h3>

<p>Download binary distributions and container images from the <a href="https://kroxylicious.io/download/0.26.0/">download</a> page.</p>

<h3 id="feedback">Feedback</h3>

<p>Drop by and say hello on <a href="https://kroxylicious.slack.com">Slack</a>, <a href="https://github.com/kroxylicious/kroxylicious/issues">GitHub</a>, or <a href="https://bsky.app/profile/kroxylicious.io">bsky</a>. You can also join us in person at a <a href="/join-us/community-call/">community call</a>.</p>]]></content><author><name>Keith Wall</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="releases" /><category term="releases" /><category term="kroxylicious-proxy" /><summary type="html"><![CDATA[Kroxylicious 0.26.0 has hatched🐊!]]></summary></entry><entry><title type="html">Post-quantum Kafka, part 1: controlling TLS named groups</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/19/post-quantum-named-groups.html" rel="alternate" type="text/html" title="Post-quantum Kafka, part 1: controlling TLS named groups" /><published>2026-11-19T09:00:00+00:00</published><updated>2026-11-19T09:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/19/post-quantum-named-groups</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/19/post-quantum-named-groups.html"><![CDATA[<p>This is the first post in a series that follows the delivery of post-quantum cryptography support in Kroxylicious, tracked by <a href="https://github.com/kroxylicious/kroxylicious/issues/5186">issue #5186</a> and designed in <a href="https://github.com/kroxylicious/design/blob/main/proposals/144-pqc-support.md">proposal 144</a>. Each post covers a capability as it’s delivered. Subsequent posts will follow the rest of that work as it is delivered.</p>

<p>This post covers the features in the 0.26 release, which add control over the TLS named groups negotiated on both sides of the proxy. That’s the groups negotiated between a downstream client and Kroxylicious, and the groups negotiated between Kroxylicious and an upstream Kafka cluster.</p>

<p><img src="/assets/blog/images/pqc-series/topology.svg" alt="A Kafka client, Kroxylicious and a Kafka cluster in a row. The client connects to Kroxylicious over the downstream TLS connection, and Kroxylicious connects to the Kafka cluster over the upstream TLS connection. Each connection negotiates its named group independently." /></p>

<h2 id="what-post-quantum-cryptography-is-and-why-it-matters-now">What post-quantum cryptography is, and why it matters now</h2>

<p>A large enough quantum computer running Shor’s algorithm breaks the public-key cryptography that TLS relies on. The key exchange that protects a TLS session today uses classical algorithms such as elliptic-curve Diffie-Hellman. Those algorithms are secure against classical computers and insecure against a cryptographically relevant quantum computer.</p>

<p>No such machine exists yet. The reason this matters now is ‘harvest now, decrypt later’. An adversary records encrypted traffic today and stores it. When a capable quantum computer arrives, they decrypt the stored traffic and recover the session keys, and with them the data. Any data with a long confidentiality lifetime is already exposed, as it’s being recorded today whilst the means to decrypt it is only a matter of time.</p>

<p>Post-quantum cryptography addresses this with algorithms that are secure against both classical and quantum computers. The first priority is the key exchange, as that’s what ‘harvest now, decrypt later’ targets. Protecting the key exchange with a post-quantum algorithm means traffic recorded today yields nothing decryptable later, even once a quantum computer exists.</p>

<p><img src="/assets/blog/images/pqc-series/harvest-now-decrypt-later.svg" alt="Harvest now, decrypt later. Encrypted traffic recorded today is stored, and years later a quantum computer arrives. Traffic protected by a classical key exchange is decrypted once the quantum computer exists, whilst traffic protected by a post-quantum key exchange stays unreadable." /></p>

<h2 id="named-groups-and-where-they-fit-in-the-tls-handshake">Named groups and where they fit in the TLS handshake</h2>

<p>A ‘named group’ identifies the algorithm and parameters used for the key exchange in a TLS handshake. In TLS 1.3 the client offers a list of supported named groups in its ‘ClientHello’, in preference order, along with a key share for the groups it expects to be chosen. The server picks one group that it also supports, and the key exchange proceeds with that group. When the client and server have no named group in common, the handshake fails.</p>

<p><img src="/assets/blog/images/pqc-series/handshake-named-groups.svg" alt="A TLS 1.3 handshake. The client sends a ClientHello listing its supported named groups in preference order with key shares. When a group is supported by both ends, the server replies with a ServerHello naming the chosen group and the key exchange proceeds. When no group is in common, the handshake fails." /></p>

<p>Two classical named groups appear throughout this post. ‘X25519’ is an elliptic-curve group and the common default on modern JDKs. ‘secp256r1’ is the NIST P-256 elliptic curve.</p>

<p>The post-quantum named group is ‘X25519MLKEM768’. It’s a hybrid, combining classical X25519 with ML-KEM-768, the post-quantum key encapsulation mechanism standardised as FIPS 203. The hybrid provides post-quantum protection for the key exchange whilst retaining the classical security of X25519, so a weakness later found in either component still leaves the other protecting the session.</p>

<p>Whether X25519MLKEM768 is available at all depends on your JDK vendor, for example the <a href="https://www.java.com/en/jre-jdk-cryptoroadmap.html">JRE and JDK cryptographic roadmap</a> shows Java 25 support as already available, whilst Java 21 support is targeted for 2027. This JDK dependency is central to the scenarios below, as the named group a connection can use is bounded by what the JVM on each end supports, not only by what Kroxylicious is configured to allow.</p>

<h2 id="controlling-named-groups-in-kroxylicious">Controlling named groups in Kroxylicious</h2>

<p>The 0.26 release adds a <code class="language-plaintext highlighter-rouge">namedGroups</code> block to the TLS configuration, alongside the existing controls for TLS protocol versions and cipher suites. It follows the same shape, an <code class="language-plaintext highlighter-rouge">allowed</code> list and a <code class="language-plaintext highlighter-rouge">denied</code> list.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">namedGroups</span><span class="pi">:</span>
  <span class="na">allowed</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">X25519MLKEM768</span><span class="pi">,</span> <span class="nv">X25519</span><span class="pi">,</span> <span class="nv">secp256r1</span><span class="pi">]</span>
</code></pre></div></div>

<p>The order of the <code class="language-plaintext highlighter-rouge">allowed</code> list is significant. The first entry is the most preferred, and the remaining entries are fallbacks in preference order. An endpoint that permits post-quantum with a classical fallback lists X25519MLKEM768 first, then the classical groups.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">namedGroups</span><span class="pi">:</span>
  <span class="na">allowed</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">X25519MLKEM768</span><span class="pi">]</span>
</code></pre></div></div>

<p>An <code class="language-plaintext highlighter-rouge">allowed</code> list with a single entry is a post-quantum-only endpoint. It offers no classical fallback, so a peer that cannot do X25519MLKEM768 has no group in common and the handshake fails.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">namedGroups</span><span class="pi">:</span>
  <span class="na">denied</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">X25519</span><span class="pi">]</span>
</code></pre></div></div>

<p>A <code class="language-plaintext highlighter-rouge">denied</code> list removes groups from the JDK’s default set rather than replacing it. Denying X25519 leaves the remaining default groups in their default preference order.</p>

<p>The <code class="language-plaintext highlighter-rouge">namedGroups</code> block is optional. When it’s unset, the JDK’s standard groups apply in the JDK’s default order. This is the behaviour on an upgrade from 0.25 or earlier, where no configuration mentions named groups.</p>

<p>The two walkthroughs that follow apply this configuration on each side of the proxy in turn. Both were recorded end to end, and the full videos are in the appendix.</p>

<h2 id="downstream-client-to-kroxylicious">Downstream: client to Kroxylicious</h2>

<p>The downstream connection is the one from a Kafka client to a Kroxylicious proxy. The <code class="language-plaintext highlighter-rouge">namedGroups</code> block sits in the gateway’s TLS configuration under <code class="language-plaintext highlighter-rouge">virtualClusters/gateways</code>. Kroxylicious is the TLS server for this connection, so the group that can be negotiated is bounded by both the JVM Kroxylicious runs on and what algorithms the client supports.</p>

<p><img src="/assets/blog/images/pqc-series/downstream-leg.svg" alt="The topology with the downstream connection highlighted. The Kafka client and Kroxylicious are in focus, joined by the downstream TLS connection. The Kafka cluster and the upstream connection are greyed out." /></p>

<p>The walkthrough was recorded with two terminals side by side. The left terminal shows the Kroxylicious configuration in use. The right terminal runs a tool that reports the named group negotiated when a TLS connection is made to the proxy.</p>

<h3 id="kroxylicious-on-java-21">Kroxylicious on Java 21</h3>

<p>The first four scenarios all run with Kroxylicious on Java 21, changing only the gateway’s <code class="language-plaintext highlighter-rouge">namedGroups</code> configuration between them.</p>

<p>With no <code class="language-plaintext highlighter-rouge">namedGroups</code> configured, the migration-from-0.25 case, the client negotiates X25519. The JDK’s default most-preferred group applies on both ends.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">virtualClusters</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">services</span>
    <span class="na">target</span><span class="pi">:</span>
      <span class="na">cluster</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">gateways</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">sni</span>
        <span class="na">sniHostIdentifiesNode</span><span class="pi">:</span>
          <span class="na">bootstrapAddress</span><span class="pi">:</span> <span class="s">bootstrap.kroxy.test:19192</span>
          <span class="na">advertisedBrokerAddressPattern</span><span class="pi">:</span> <span class="s">broker-$(nodeId).kroxy.test</span>
        <span class="na">tls</span><span class="pi">:</span>
          <span class="na">key</span><span class="pi">:</span>
            <span class="na">privateKeyFile</span><span class="pi">:</span> <span class="s">/certs/tls.key</span>
            <span class="na">certificateFile</span><span class="pi">:</span> <span class="s">/certs/tls.crt</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/default-gateway.png" alt="TLS handshake inspection showing that x25519 was negotiated" /></p>

<p>Adding a <code class="language-plaintext highlighter-rouge">denied</code> list for X25519 removes it from the default set, and the client then negotiates secp256r1, the next group in the default preference order.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">virtualClusters</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">services</span>
    <span class="na">target</span><span class="pi">:</span>
      <span class="na">cluster</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">gateways</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">sni</span>
        <span class="na">sniHostIdentifiesNode</span><span class="pi">:</span>
          <span class="na">bootstrapAddress</span><span class="pi">:</span> <span class="s">bootstrap.kroxy.test:19192</span>
          <span class="na">advertisedBrokerAddressPattern</span><span class="pi">:</span> <span class="s">broker-$(nodeId).kroxy.test</span>
        <span class="na">tls</span><span class="pi">:</span>
          <span class="na">key</span><span class="pi">:</span>
            <span class="na">privateKeyFile</span><span class="pi">:</span> <span class="s">/certs/tls.key</span>
            <span class="na">certificateFile</span><span class="pi">:</span> <span class="s">/certs/tls.crt</span>
        <span class="na">namedGroups</span><span class="pi">:</span>
          <span class="na">denied</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="s">x25519</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/x25519-denied.png" alt="TLS handshake inspection showing that when x25519 is denied then secp256r1 was negotiated" /></p>

<p>Setting an <code class="language-plaintext highlighter-rouge">allowed</code> list of <code class="language-plaintext highlighter-rouge">[X25519MLKEM768, X25519]</code> offers post-quantum first with a classical fallback. The client negotiates X25519, not X25519MLKEM768. The client is capable of post-quantum, however Kroxylicious is on Java 21, which does not offer X25519MLKEM768, so the handshake falls back to the first group the two ends share.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">virtualClusters</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">services</span>
    <span class="na">target</span><span class="pi">:</span>
      <span class="na">cluster</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">gateways</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">sni</span>
        <span class="na">sniHostIdentifiesNode</span><span class="pi">:</span>
          <span class="na">bootstrapAddress</span><span class="pi">:</span> <span class="s">bootstrap.kroxy.test:19192</span>
          <span class="na">advertisedBrokerAddressPattern</span><span class="pi">:</span> <span class="s">broker-$(nodeId).kroxy.test</span>
        <span class="na">tls</span><span class="pi">:</span>
          <span class="na">key</span><span class="pi">:</span>
            <span class="na">privateKeyFile</span><span class="pi">:</span> <span class="s">/certs/tls.key</span>
            <span class="na">certificateFile</span><span class="pi">:</span> <span class="s">/certs/tls.crt</span>
        <span class="na">namedGroups</span><span class="pi">:</span>
          <span class="na">allowed</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="s">X25519MLKEM768</span>
            <span class="pi">-</span> <span class="s">x25519</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/x25519-allowed.png" alt="TLS handshake inspection showing classical fallback when post-quantum not supported" /></p>

<p>Restricting the <code class="language-plaintext highlighter-rouge">allowed</code> list to <code class="language-plaintext highlighter-rouge">[X25519MLKEM768]</code> removes the fallback. Kroxylicious on Java 21 cannot offer X25519MLKEM768, so there’s no group in common and the client fails to connect.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">virtualClusters</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">services</span>
    <span class="na">target</span><span class="pi">:</span>
      <span class="na">cluster</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">gateways</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">sni</span>
        <span class="na">sniHostIdentifiesNode</span><span class="pi">:</span>
          <span class="na">bootstrapAddress</span><span class="pi">:</span> <span class="s">bootstrap.kroxy.test:19192</span>
          <span class="na">advertisedBrokerAddressPattern</span><span class="pi">:</span> <span class="s">broker-$(nodeId).kroxy.test</span>
        <span class="na">tls</span><span class="pi">:</span>
          <span class="na">key</span><span class="pi">:</span>
            <span class="na">privateKeyFile</span><span class="pi">:</span> <span class="s">/certs/tls.key</span>
            <span class="na">certificateFile</span><span class="pi">:</span> <span class="s">/certs/tls.crt</span>
        <span class="na">namedGroups</span><span class="pi">:</span>
          <span class="na">allowed</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="s">X25519MLKEM768</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/no-groups-in-common.png" alt="TLS handshake fails when there are no named groups in common" /></p>

<h3 id="kroxylicious-on-java-25">Kroxylicious on Java 25</h3>

<p>The final scenario keeps the same post-quantum-only configuration, <code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code>, and changes only the JVM. The Kroxylicious release is unchanged. On Java 25 the client negotiates X25519MLKEM768.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">virtualClusters</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">services</span>
    <span class="na">target</span><span class="pi">:</span>
      <span class="na">cluster</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">gateways</span><span class="pi">:</span>
      <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">sni</span>
        <span class="na">sniHostIdentifiesNode</span><span class="pi">:</span>
          <span class="na">bootstrapAddress</span><span class="pi">:</span> <span class="s">bootstrap.kroxy.test:19192</span>
          <span class="na">advertisedBrokerAddressPattern</span><span class="pi">:</span> <span class="s">broker-$(nodeId).kroxy.test</span>
        <span class="na">tls</span><span class="pi">:</span>
          <span class="na">key</span><span class="pi">:</span>
            <span class="na">privateKeyFile</span><span class="pi">:</span> <span class="s">/certs/tls.key</span>
            <span class="na">certificateFile</span><span class="pi">:</span> <span class="s">/certs/tls.crt</span>
        <span class="na">namedGroups</span><span class="pi">:</span>
          <span class="na">allowed</span><span class="pi">:</span>
            <span class="pi">-</span> <span class="s">X25519MLKEM768</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/X25519MLKEM768-allowed.png" alt="TLS handshake inspection showing post-quantum support" /></p>

<p>In summary, the outcome depends on the JVM, not the Kroxylicious release. The same configuration that fails to connect on Java 21 negotiates a post-quantum key exchange on Java 25.</p>

<table>
  <thead>
    <tr>
      <th>Kroxylicious JVM</th>
      <th><code class="language-plaintext highlighter-rouge">namedGroups</code></th>
      <th>Negotiated group</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Java 21</td>
      <td>unset</td>
      <td>X25519</td>
    </tr>
    <tr>
      <td>Java 21</td>
      <td><code class="language-plaintext highlighter-rouge">denied: [X25519]</code></td>
      <td>secp256r1</td>
    </tr>
    <tr>
      <td>Java 21</td>
      <td><code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768, X25519]</code></td>
      <td>X25519</td>
    </tr>
    <tr>
      <td>Java 21</td>
      <td><code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code></td>
      <td>none, connection fails</td>
    </tr>
    <tr>
      <td>Java 25</td>
      <td><code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code></td>
      <td>X25519MLKEM768</td>
    </tr>
  </tbody>
</table>

<h2 id="upstream-kroxylicious-to-kafka">Upstream: Kroxylicious to Kafka</h2>

<p>The upstream connection is the one from Kroxylicious to the Kafka cluster. The <code class="language-plaintext highlighter-rouge">namedGroups</code> block sits in the upstream TLS configuration under <code class="language-plaintext highlighter-rouge">clusterDefinitions</code>. Here Kroxylicious is the TLS client and Kafka is the server, so the group that can be negotiated is bounded by both the JVM Kroxylicious runs on and the JVM Kafka runs on.</p>

<p><img src="/assets/blog/images/pqc-series/upstream-leg.svg" alt="The topology with the upstream connection highlighted. Kroxylicious and the Kafka cluster are in focus, joined by the upstream TLS connection. The Kafka client and the downstream connection are greyed out." /></p>

<p>This walkthrough used the same two-terminal layout. The left terminal shows the Kroxylicious configuration. The right terminal shows the named group negotiated with the upstream Kafka, obtained by turning on TLS tracing for Kroxylicious with <code class="language-plaintext highlighter-rouge">-Djavax.net.debug=SSL</code> and filtering for the negotiated group. A producer sending a single message drove the upstream connection.</p>

<h3 id="kroxylicious-on-java-21-kafka-on-java-25">Kroxylicious on Java 21, Kafka on Java 25</h3>

<p>With no <code class="language-plaintext highlighter-rouge">namedGroups</code> configured, the migration-from-0.25 case, Kroxylicious negotiates X25519 with Kafka.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">clusterDefinitions</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">bootstrapServers</span><span class="pi">:</span> <span class="s">kafka.kroxy.test:9094</span>
    <span class="na">tls</span><span class="pi">:</span>
      <span class="na">trust</span><span class="pi">:</span>
        <span class="na">storeFile</span><span class="pi">:</span> <span class="s">/certs/ca.crt</span>
        <span class="na">storeType</span><span class="pi">:</span> <span class="s">PEM</span>

</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/upstream-x25519.png" alt="SSL debug showing x25519 negotiated with upstream" /></p>

<p>Adding a <code class="language-plaintext highlighter-rouge">denied</code> list for X25519 leads Kroxylicious to negotiate secp256r1 with Kafka, the next group in the default order.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">clusterDefinitions</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">bootstrapServers</span><span class="pi">:</span> <span class="s">kafka.kroxy.test:9094</span>
    <span class="na">tls</span><span class="pi">:</span>
      <span class="na">trust</span><span class="pi">:</span>
        <span class="na">storeFile</span><span class="pi">:</span> <span class="s">/certs/ca.crt</span>
        <span class="na">storeType</span><span class="pi">:</span> <span class="s">PEM</span>
      <span class="na">namedGroups</span><span class="pi">:</span>
        <span class="na">denied</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="s">x25519</span>
</code></pre></div></div>

<p><img src="/assets/blog/images/pqc-series/upstream-secp256r1.png" alt="SSL debug showing secp256r1 negotiated with upstream" /></p>

<p>Restricting the <code class="language-plaintext highlighter-rouge">allowed</code> list to <code class="language-plaintext highlighter-rouge">[X25519MLKEM768]</code> leaves no classical fallback. Kroxylicious on Java 21 cannot offer X25519MLKEM768, so there’s no group in common and Kroxylicious fails to connect to Kafka, even though Kafka on Java 25 could do it.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">clusterDefinitions</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">bootstrapServers</span><span class="pi">:</span> <span class="s">kafka.kroxy.test:9094</span>
    <span class="na">tls</span><span class="pi">:</span>
      <span class="na">trust</span><span class="pi">:</span>
        <span class="na">storeFile</span><span class="pi">:</span> <span class="s">/certs/ca.crt</span>
        <span class="na">storeType</span><span class="pi">:</span> <span class="s">PEM</span>
      <span class="na">namedGroups</span><span class="pi">:</span>
        <span class="na">allowed</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="s">X25519MLKEM768</span>
</code></pre></div></div>
<p>There’s no handshake inspection to show for this case. The upstream named group is read from the SSL trace, and when there’s no group in common the handshake fails before a group is chosen, so there’s nothing to capture. The connection simply fails.</p>

<h3 id="kroxylicious-on-java-25-1">Kroxylicious on Java 25</h3>

<p>The final scenario keeps <code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code> and changes only the Kroxylicious JVM to Java 25. Both ends can now do the post-quantum group, and Kroxylicious negotiates X25519MLKEM768 with Kafka.</p>

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">clusterDefinitions</span><span class="pi">:</span>
  <span class="pi">-</span> <span class="na">name</span><span class="pi">:</span> <span class="s">kafka</span>
    <span class="na">bootstrapServers</span><span class="pi">:</span> <span class="s">kafka.kroxy.test:9094</span>
    <span class="na">tls</span><span class="pi">:</span>
      <span class="na">trust</span><span class="pi">:</span>
        <span class="na">storeFile</span><span class="pi">:</span> <span class="s">/certs/ca.crt</span>
        <span class="na">storeType</span><span class="pi">:</span> <span class="s">PEM</span>
      <span class="na">namedGroups</span><span class="pi">:</span>
        <span class="na">allowed</span><span class="pi">:</span>
          <span class="pi">-</span> <span class="s">X25519MLKEM768</span>
</code></pre></div></div>
<p><img src="/assets/blog/images/pqc-series/upstream-X25519MLKEM768.png" alt="SSL debug showing X25519MLKEM768 negotiated with upstream" /></p>

<p>Similar to connections from downstream clients, the outcome depends on the JVM, not the Kroxylicious release. The same configuration that fails to connect on Java 21 negotiates a post-quantum key exchange on Java 25.</p>

<table>
  <thead>
    <tr>
      <th>Kroxylicious JVM</th>
      <th>Kafka JVM</th>
      <th><code class="language-plaintext highlighter-rouge">namedGroups</code></th>
      <th>Negotiated group</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Java 21</td>
      <td>Java 25</td>
      <td>unset</td>
      <td>X25519</td>
    </tr>
    <tr>
      <td>Java 21</td>
      <td>Java 25</td>
      <td><code class="language-plaintext highlighter-rouge">denied: [X25519]</code></td>
      <td>secp256r1</td>
    </tr>
    <tr>
      <td>Java 21</td>
      <td>Java 25</td>
      <td><code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code></td>
      <td>none, connection fails</td>
    </tr>
    <tr>
      <td>Java 25</td>
      <td>Java 25</td>
      <td><code class="language-plaintext highlighter-rouge">allowed: [X25519MLKEM768]</code></td>
      <td>X25519MLKEM768</td>
    </tr>
  </tbody>
</table>

<p>Kafka can run a post-quantum key exchange given a suitable JVM. Control over the named groups Kafka offers is proposed in <a href="https://cwiki.apache.org/confluence/spaces/KAFKA/pages/451974516/KIP-1376+Support+setting+TLS+named+groups">KIP-1376</a>.</p>

<h2 id="recap">Recap</h2>

<p>The 0.26 release of Kroxylicious lets users control the TLS named groups negotiated on both sides of the proxy, through a <code class="language-plaintext highlighter-rouge">namedGroups</code> block with <code class="language-plaintext highlighter-rouge">allowed</code> and <code class="language-plaintext highlighter-rouge">denied</code> lists on the downstream gateway and the upstream cluster configuration. The order of the <code class="language-plaintext highlighter-rouge">allowed</code> list sets the preference order, and leaving the block unset keeps the JDK’s defaults, so an upgrade from 0.25 or earlier changes nothing.</p>

<p>Listing X25519MLKEM768 in the <code class="language-plaintext highlighter-rouge">allowed</code> list is what asks for a post-quantum key exchange. Whether that’s negotiated then depends on what is supported at each end of the connection. On Java 25 both the downstream and the upstream connection negotiate X25519MLKEM768. On Java 21 the post-quantum group is not yet available, so a configuration that permits a classical fallback negotiates a classical group, and a post-quantum-only configuration fails to connect. Java 21 support is scheduled for a backport in the first half of 2027.</p>

<h2 id="appendix-the-recordings">Appendix: the recordings</h2>

<p>The downstream walkthrough, client to Kroxylicious used a two-terminal layout. The left terminal shows the Kroxylicious configuration in use. The right terminal runs a tool that reports the named group negotiated when a TLS connection is made to the proxy.</p>

<iframe width="720" height="405" src="https://www.youtube-nocookie.com/embed/WvwZw478hlY" title="Kroxylicious Downstream PQC" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>

<p>The upstream walkthrough, Kroxylicious to Kafka used a two-terminal layout. The left terminal shows the Kroxylicious configuration. The right terminal shows the named group negotiated with the upstream Kafka, obtained by turning on TLS tracing for Kroxylicious with <code class="language-plaintext highlighter-rouge">-Djavax.net.debug=SSL</code> and filtering for the negotiated group. A producer sending a single message drove the upstream connection.</p>

<iframe width="720" height="405" src="https://www.youtube-nocookie.com/embed/mLXXbhgTEI4" title="Kroxylicious Upstream PQC" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>]]></content><author><name>Adam Pilkington</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="security" /><category term="tls" /><category term="pqc" /><summary type="html"><![CDATA[This is the first post in a series that follows the delivery of post-quantum cryptography support in Kroxylicious, tracked by issue #5186 and designed in proposal 144. Each post covers a capability as it’s delivered. Subsequent posts will follow the rest of that work as it is delivered.]]></summary></entry><entry><title type="html">Partition Weaving: Stretching the seams of a topic</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/03/partition-weaving-stretching-the-seams-of-a-topic.html" rel="alternate" type="text/html" title="Partition Weaving: Stretching the seams of a topic" /><published>2026-11-03T23:00:00+00:00</published><updated>2026-11-03T23:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/03/partition-weaving-stretching-the-seams-of-a-topic</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/03/partition-weaving-stretching-the-seams-of-a-topic.html"><![CDATA[<p>This is the fifth post in a series about routing in Kroxylicious, and it covers the last of the four patterns <a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> named: <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">connection switching</a>, <a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html">stream branching</a>, <a href="/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html">topic weaving</a> and partition weaving. Like the rest of the series, this is design-level thinking rather than a description of something shipped, and we haven’t tried any of it.</p>

<p>Partition weaving is a cautionary tale. My first reaction was “that’s a really neat idea”. The more I looked at it, the harder it got. It is clearly part of the design space the Routing API opens up, which is why it’s in the series, and it may well be possible. But it is a lot of effort to go to, and I haven’t found a use case that justifies it to me. If you have one, I’d like to hear about it.</p>

<p>Back at the sorting office from Post 4, the sorter picked a chute from the label on the parcel. Here every parcel carries the same label, <code class="language-plaintext highlighter-rouge">orders</code>, and the sorter has to read the house number as well. That number is the one thing it can never reassign once it’s printed.</p>

<h2 id="one-topic-two-clusters">One topic, two clusters</h2>

<p>Take the scenario from Post 1: a risk engine in us-east, hardcoded to read a topic called <code class="language-plaintext highlighter-rouge">orders</code>, and an EU team producing to <code class="language-plaintext highlighter-rouge">orders-eu</code> on a local cluster. The router presents both as one <code class="language-plaintext highlighter-rouge">orders</code> topic with 32 partitions. Partitions 0 to 15 are the <code class="language-plaintext highlighter-rouge">orders</code> partitions on us-east. Partitions 16 to 31 are partitions 0 to 15 of <code class="language-plaintext highlighter-rouge">orders-eu</code> on eu-west. A consumer that asks for partition 20 gets partition 4 of <code class="language-plaintext highlighter-rouge">orders-eu</code> and never knows. I’ll call the numbers the client sees <em>virtual</em>, in the same sense as a virtual cluster, and the partitions and topics that actually exist on a backing cluster <em>physical</em>. Partition 20 is virtual, and partition 4 of <code class="language-plaintext highlighter-rouge">orders-eu</code> is the physical partition behind it.</p>

<p>Producers pick a partition by hashing the record key and taking the remainder after dividing by 32, so every record with a given key lands in the same partition, every time. Each cluster keeps its own offsets, so offset 54 only means something within its own partition.</p>

<p><img src="/assets/blog/images/routing-series/partition-ranges.svg" alt="The client sees one topic, orders, with 32 partitions numbered 0 to 31. The router sends partitions 0 to 15 unchanged to the orders topic on us-east, and partitions 16 to 31 to partitions 0 to 15 of the orders-eu topic on eu-west, subtracting 16 from the partition number." /></p>

<p>The difficulty lives in one place: once we’ve numbered the partitions, we can’t re-number them. Records stay in the partition they were written to, and the numbers we expose in <code class="language-plaintext highlighter-rouge">Metadata</code> are the only way a client can address them. Change the count, or what a number points at, and the data can’t follow. Clients keep using the old addresses and read or write the wrong place.</p>

<h2 id="what-would-you-use-it-for">What would you use it for?</h2>

<p>The best case I have is a migration, for moving a very large topic between clusters. The runtime gives you nothing for it today. None of the other cases are much better, and I’ve set each against the solution that would usually beat it.</p>

<p><strong>Moving a very large topic a piece at a time.</strong> Replicate one range of partitions to the new cluster with something that preserves offsets, repoint that range, watch for a while, and repeat. This is connection switching with a finer lever, and it brings the problems from <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> with it, per range instead of all at once: committed offsets have to mean the same thing on the new cluster, and idempotent producers’ sequence state stays behind. Compare it with connection switching for the whole topic, which is stateless and already exists. A range at a time buys you a canary, and it only seems worth building for a topic you are properly nervous about moving.</p>

<p><strong>A topic bigger than a cluster.</strong> Clients see one topic with N partitions, keys hash as normal, and per-key ordering holds. But <a href="/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html">topic weaving</a> already spreads topics across clusters. Partition weaving only helps when a single topic outgrows what one cluster will hold or serve, and I’d want to look at that topic’s design before building anything to accommodate it.</p>

<p><strong>The name-bound consumer.</strong> This is the risk engine above. Most consumers can subscribe to more than one topic, and where this one can’t, replicating <code class="language-plaintext highlighter-rouge">orders-eu</code> into the consumer’s cluster does the same job. The weave saves you the replica. In exchange the consumer reads the EU partitions across the link on every fetch.</p>

<p><strong>Data residency by key.</strong> This is the one people will suggest, and it fits worst. The default partitioner hashes keys without knowing where anything lives, so residency would need a custom partitioner that sends EU keys to EU partitions. Producers that already know the layout could write to separate topics, and topic weaving would stitch those together without any of this.</p>

<p>That’s everything I’ve found, and I’d be glad to be wrong about it. If you have another idea, I’d like to hear about it.</p>

<h2 id="the-layout-is-declared-not-discovered">The layout is declared, not discovered</h2>

<p>Everything else depends on where the partition layout comes from. For topic weaving the map could follow the clusters, because topics appearing and disappearing is something clients cope with. A partition count is different. A partition number is the only handle a client has on a record, and changing the handle without moving the data breaks all sorts of things.</p>

<p>Suppose the router discovered the layout by asking the clusters. If eu-west became unreachable, the router would find only 16 partitions and report a topic with 16 partitions. Every keyed record produced in that window would hash into 0 to 15, to the wrong partition, with no error anywhere. So I’d declare it. A woven topic is an ordered list of constituents, each a route, a physical topic and a partition count, held in the router’s configuration or a catalogue. Three consequences follow:</p>

<ul>
  <li><strong>The numbering has to be contiguous.</strong> The default partitioner picks a number from 0 to N-1 using the count. A hole is a partition the producer will try to use and can’t find.</li>
  <li><strong>An unreachable constituent still counts.</strong> Its partitions stay in the <code class="language-plaintext highlighter-rouge">Metadata</code> response, reported with an error and no leader, the way a broker reports a partition whose leader is offline. N doesn’t shrink because a cluster is down.</li>
  <li><strong>The declared count wins.</strong> Kafka lets someone add partitions to the physical topic behind a constituent. The extra partitions stay invisible until the layout says otherwise.</li>
</ul>

<p>Every proxy instance must give the same identity the same answer, as in Post 4. Because the layout is configuration, every instance has the same list, so there’s no state to share.</p>

<p>Changing it is where the care goes. The rule is that a virtual partition number must keep meaning the same log. Appending a constituent to the end satisfies that: existing numbers don’t move and the new ones are simply new. It does grow N, which changes where keyed records land, exactly as adding partitions to any Kafka topic does. Data already written stays where it is. If the new constituent is on a cluster the router has no route to yet, <code class="language-plaintext highlighter-rouge">numRoutes</code> changes too, and every virtual node ID moves with it, a coordinated reconnect for all clients of that VKC. A rolling update is tolerable for an append. An instance that hasn’t picked up the change returns errors for the new partitions, and clients retry. Reordering, removing, resizing or relocating a constituent is a migration, and no amount of careful rollout makes it anything else. The piecemeal migration above is one of those, so it needs a deliberate cutover and not a config push.</p>

<h2 id="two-ways-to-number-them">Two ways to number them</h2>

<p>The first is <strong>ranges</strong>, which is what the picture shows. Constituent <em>i</em> starts at the sum of the partition counts before it. A virtual partition <code class="language-plaintext highlighter-rouge">p</code> falls in the range <code class="language-plaintext highlighter-rouge">[start_i, start_i + count_i)</code> and maps to physical partition <code class="language-plaintext highlighter-rouge">p - start_i</code>. The inverse adds <code class="language-plaintext highlighter-rouge">start_i</code> back. In the example, virtual 20 is <code class="language-plaintext highlighter-rouge">eu-west</code> / <code class="language-plaintext highlighter-rouge">orders-eu</code> partition 4. Constituents can have different counts, and appending to the end leaves everything before it alone.</p>

<p>The second is <strong>interleaving</strong>, and it’s the tempting one, because it’s the same arithmetic we use to map broker IDs to virtual node IDs. With K constituents of equal size, virtual <code class="language-plaintext highlighter-rouge">p</code> goes to constituent <code class="language-plaintext highlighter-rouge">p mod K</code> as physical partition <code class="language-plaintext highlighter-rouge">p div K</code>.</p>

<p>Both are stateless. Interleaving isn’t saving anything the declared list hasn’t already saved, because the router needs that list to know the routes anyway.</p>

<p>Think of numbering the houses on a street. Ranges build new houses at the far end, so number 5 is still the same house. Interleaving renumbers every house whenever one is built, but the letters already on the doormat stay where they were, and the post, addressed by number, now arrives at the wrong door.</p>

<p>The numbers say the same thing:</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th>Ranges</th>
      <th>Interleaved</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Virtual 5 with K = 2</td>
      <td>constituent 0, partition 5</td>
      <td>constituent 1, partition 2</td>
    </tr>
    <tr>
      <td>Virtual 5 after a third constituent joins (K = 3)</td>
      <td>constituent 0, partition 5</td>
      <td>constituent 2, partition 1</td>
    </tr>
  </tbody>
</table>

<p>(Constituents are numbered from 0, and the ranges column assumes the first holds at least 6 partitions.)</p>

<p><img src="/assets/blog/images/routing-series/partition-range-management.svg" alt="Virtual partition 5 under the two numbering schemes, before and after a third constituent joins. With ranges, it stays on partition 5 of constituent 0 both times. With interleaving, it is partition 2 of constituent 1 with two constituents, and partition 1 of constituent 2 with three, so the same virtual number now reads from a different log." /></p>

<p>Interleaving moves every virtual partition when K changes. The data hasn’t moved. Committed offsets sit in <code class="language-plaintext highlighter-rouge">__consumer_offsets</code> keyed by the physical topic and partition, and earlier records were placed by an earlier hash. After the change the same virtual number reads from a different log. In Post 2 the same formula was safe because node IDs are re-learned from the next <code class="language-plaintext highlighter-rouge">Metadata</code> response. Partition identity is stored, so it can’t be re-learned. Ranges are only growable at the end, but at least they know what that means.</p>

<p>Re-numbering isn’t a quirk of weaving. Changing the partition count of a normal Kafka topic is already a risky business: a key whose hash is 50 lands in partition 18 of 32 and partition 2 of 48. Weaving doesn’t make that any worse, but it does make an inadvertent change much more likely. Changing the configuration is a much more serious activity than it appears.</p>

<h2 id="where-the-numbers-appear">Where the numbers appear</h2>

<p>Partition numbers turn up in nearly every RPC that names a partition. I’m sticking to produce and consume, which is the data path, and leaving the admin APIs out. These are the requests where the router has to translate:</p>

<table>
  <thead>
    <tr>
      <th>Request</th>
      <th>Where the partition number is</th>
      <th>What the router does</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Metadata</code> response</td>
      <td>Each partition’s index, and its leader as a node ID</td>
      <td>Emits virtual 0 to N-1. Sets each leader to a virtual node on the owning route, with an error for an unreachable constituent</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Produce</code></td>
      <td>The partition index under each topic</td>
      <td>Maps virtual to (route, physical topic, physical partition) and rewrites the response the other way</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">Fetch</code></td>
      <td>The partition under each topic, and the partitions to drop in the forgotten-topics list of an incremental fetch</td>
      <td>The same translation. The session state is kept on both sides, as in the <a href="/blog/kroxylicious-proxy/2026/05/21/topic-routing.html">topic routing proof of concept</a></td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">ListOffsets</code></td>
      <td>The partition index</td>
      <td>The same translation. Consumers use it to find the start or end of a partition</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">OffsetCommit</code>, <code class="language-plaintext highlighter-rouge">OffsetFetch</code></td>
      <td>The partition index under each topic</td>
      <td>Splits by owning route, with the boss and standalone commits from Post 4</td>
    </tr>
  </tbody>
</table>

<p><code class="language-plaintext highlighter-rouge">Produce</code>, <code class="language-plaintext highlighter-rouge">Fetch</code> and <code class="language-plaintext highlighter-rouge">ListOffsets</code> never need to be split. A client sends each of them to the leader of the partitions involved. With the node ID mapping from Post 2 every virtual node belongs to exactly one route, so a client that follows the <code class="language-plaintext highlighter-rouge">Metadata</code> it was given sends a frame whose partitions all live on one cluster. The router rewrites the coordinates and forwards the whole frame. The requests that do get torn apart are <code class="language-plaintext highlighter-rouge">Metadata</code>, which merges several answers into one, and the offset requests, because a group has a single coordinator whichever clusters its partitions are on.</p>

<p>Offsets, leader epochs and the record batches themselves belong to the physical partition and pass through untouched. Rewriting a partition number doesn’t touch the batch, so unlike rewriting a producer ID it costs no CRC recalculation.</p>

<p>A complete list would be longer. These are the ones that, if wrong, a client notices.</p>

<h2 id="topic-ids">Topic IDs</h2>

<p>There’s a second identifier that needs the same care, and it applies to topic weaving as much as to this pattern. <a href="/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html">Post 4</a> renamed topics without mentioning it, so the right place for it is wherever you weave.</p>

<p>Kafka gives each topic a UUID at creation, and a topic deleted and recreated under the same name gets a new one. That’s the point. A late fetch for the old topic can’t read the new log. Fetch has taken the ID instead of the name since Kafka 3.1. Produce followed in 4.1, and <code class="language-plaintext highlighter-rouge">OffsetCommit</code> and <code class="language-plaintext highlighter-rouge">OffsetFetch</code> can use it from version 10. <code class="language-plaintext highlighter-rouge">ListOffsets</code> still uses names. The router writes the <code class="language-plaintext highlighter-rouge">Metadata</code> response, so it chooses the UUID the client sees. When the client sends that UUID back in a <code class="language-plaintext highlighter-rouge">Produce</code> or <code class="language-plaintext highlighter-rouge">Fetch</code>, the router has to find the physical topic, and the physical topic’s own UUID is the one it must send upstream.</p>

<p>I’d treat the two sides differently:</p>

<ul>
  <li><strong>Client side: derived.</strong> The router computes the ID for a virtual topic from its name and something that says which incarnation it is. A generation number alongside the layout is one way to do that. Every instance computes the same value, with nothing stored. Going the other way, from a UUID back to a topic, you can’t invert a hash. The router builds a table at startup by computing the ID for every topic it declares. The result must avoid the all-zero UUID, which the protocol uses to mean “no ID”. Kafka’s own generator also skips a few reserved values and any ID whose string form contains a dash, and it would be sensible to follow suit.</li>
  <li><strong>Broker side: learned.</strong> The physical ID comes from the backing cluster’s <code class="language-plaintext highlighter-rouge">Metadata</code> response, discovered in-band as in Post 2. If it goes stale, the broker answers <code class="language-plaintext highlighter-rouge">UNKNOWN_TOPIC_ID</code> and the router refreshes. The broker’s own protection against stale topics stays intact on this leg.</li>
</ul>

<p><img src="/assets/blog/images/routing-series/topicIds.svg" alt="The client topic ID is derived by the router from the declared layout and its generation, so no instance needs to store it. The client sends Produce and Fetch requests with that ID to the router. The router swaps in the physical topic ID, which it learned from the backing cluster's Metadata response, and sends the request on. If the physical ID is stale, the cluster answers UNKNOWN_TOPIC_ID and the router refreshes its Metadata." /></p>

<p>That’s the opposite of a producer ID. The client-facing ID can be rebuilt from the declared layout by any instance, and the physical ID can be re-learned from the cluster. Nothing that can’t be recomputed has to survive a restart.</p>

<p>What you lose is the client-facing guarantee. The client’s protection against a delete-and-recreate is only as good as the generation. Nobody really wants to delete and recreate a woven topic at will, so I wouldn’t build anything to evolve client IDs automatically. Whoever does it is doing a migration, and bumping the generation is how they say so. It needs managing, for topic weaving as well as for this.</p>

<p>The alternative is to avoid IDs altogether. The proposal notes that a router can cap the versions it advertises, for example <code class="language-plaintext highlighter-rouge">PRODUCE</code> at 12, so clients use names. It calls that “an implementation simplification rather than a fundamental necessity”. The cost is exactly the guarantee above, and it’s a choice about what the client leg promises.</p>

<h2 id="producing">Producing</h2>

<p>A producer writing through the weave picks a partition from 0 to 31 as it would for any topic. The router sends it wherever that number lives. For keyed records the hash decides, so a producer in eu-west has no reason to land on the eu-west partitions. For unkeyed records the client spreads load across available partitions, which includes the ones across the ocean. Writing through the weave gives you no locality unless something outside the router arranges it.</p>

<p>Arranging it means a custom partitioner that knows which numbers are local, and that puts the layout the router hides back into the client. The weave exists for the consumer you can’t touch, the vendor’s risk engine, while the producers are yours to change. If you can change a producer’s <code class="language-plaintext highlighter-rouge">partitioner.class</code>, you could change its topic name as well. So the producers that gain from partition weaving are, in practice, the ones that don’t use it. In Post 1’s scenario the EU team writes straight to <code class="language-plaintext highlighter-rouge">orders-eu</code>, and the weave serves readers only.</p>

<h2 id="consuming">Consuming</h2>

<p>Consumer groups work as they did in <a href="/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html">Post 4</a>, with one change of granularity. Membership goes to the boss, and the group leader works out the assignment from the merged <code class="language-plaintext highlighter-rouge">Metadata</code>, so every member sees <code class="language-plaintext highlighter-rouge">orders</code> with 32 partitions and may be handed some from each cluster. Offsets split inside a topic now, not between topics. Commits for the partitions on the boss go with the member’s ID and generation. Commits for the rest go as standalone commits. All of Post 4’s caveats come along, including that fencing is partial and the new group protocol isn’t covered. A woven topic that gains a constituent changes its partition count, and subscribed consumers rebalance as they would for any topic that gained partitions.</p>

<p><img src="/assets/blog/images/routing-series/consumer-groups-v1.svg" alt="A group member sends its group membership requests and its offset commits for the woven topic to the router. The router sends membership requests to the boss cluster, which is the group coordinator. It sends commits for the partitions on the boss cluster there too, with the member ID and generation. Commits for the partitions on the other cluster go there as standalone commits with generation minus one and no member ID, with the group ID prefixed and the partitions renumbered." /></p>

<p>Standalone commits bring a hazard of their own. They land in the other clusters’ <code class="language-plaintext highlighter-rouge">__consumer_offsets</code>, and the <code class="language-plaintext highlighter-rouge">group.id</code> namespace there is shared with every other application on the cluster. If one of them uses the same group ID, the commit is either rejected because that group has live members, or it quietly overwrites that application’s offsets. So the router prefixes the group ID on the way to those clusters, and strips it again on the way back. Yes, yes, we could coordinate group names across the clusters instead. Then we’re back on the same conference bridge at 2am, arguing about which team owns which name.</p>

<p>Two smaller points. An <code class="language-plaintext highlighter-rouge">OffsetFetch</code> for every topic returns offsets under physical names, so the router has to translate or hide them, particularly if a group also reads <code class="language-plaintext highlighter-rouge">orders-eu</code> directly. And an unreachable constituent is reported the way a broker reports a partition whose leader is offline, which is the shape clients already expect. I’d start there and not invent something new. We haven’t tested it with real clients.</p>

<p>A <code class="language-plaintext highlighter-rouge">read_committed</code> consumer doesn’t need any producer ID translation. The batch headers, the commit and abort markers and the aborted-transaction list for a partition all come from one cluster and agree with each other, so they pass through as in Post 4.</p>

<h2 id="identity-and-transactions">Identity and transactions</h2>

<p>Producer IDs add nothing new. Sequence numbers are counted per producer and partition, and a partition lives on one cluster, so the producer ID map from Post 4 covers it unchanged. I called the place that map lives a boss cluster. The requirement is a durable store that every instance can see, and a boss cluster is one way to get one. One producer ends up holding different identities on different partitions of the same topic, which is harmless for each partition and not something any client I know of depends on.</p>

<p>Transactions are where the escape hatch closes. In topic weaving you could keep related topics on one cluster. Here a single topic’s partitions span clusters, and a transactional producer chooses a partition by key without knowing which cluster owns it. It has no way to build a transaction that stays on one side. Post 4’s two attempts failed with two clusters involved, and here the client can’t even tell that it involves two. The router can at least fail loudly by rejecting transactional writes to a woven topic. Kafka Streams with exactly-once semantics is again the usual way to be running transactions without knowing it.</p>

<h2 id="egress-ingress-or-does-it-matter">Egress, ingress, or does it matter?</h2>

<p>The answer is much as it was for topic weaving. Co-locating the proxy with one of the clusters puts the proxy in that cluster’s failure domain. The client side keeps backing cluster failures isolated, and if you adopt a durable store like the boss, putting the proxy near it shortens the paths that use it.</p>

<p>One difference is that a single topic’s reads now cross whatever links join the clusters. Where the proxy sits decides which consumers pay for the long hop. No placement makes every consumer local, because a consumer in a group gets partitions from both sides.</p>

<h2 id="know-when-to-pick-a-different-chute">Know when to pick a different chute</h2>

<p>If your problem is moving a workload, use <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">connection switching</a>. If your topics have distinct homes, <a href="/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html">topic weaving</a> hides the clusters without hiding the partitions. If your problem is locality or disaster recovery, replicate. Weaving gives you unified access, not local copies. If you need atomic writes across clusters, no proxy can help, and with partition weaving you can’t even tell where the seam is.</p>

<p>The cost of getting this wrong is silent. The number a client hashes against must mean the same log forever, the layout can’t be discovered, and the one thing that would justify it, moving a big topic carefully, is a job for a migration you plan. I’d only reach for partition weaving if you already know which of those you’re buying.</p>

<hr />

<p>That’s the four patterns. Each one asks the router to understand a little more of the protocol than the last, and partition weaving is where I think the cost outruns the benefit, for now. I’d be glad to be shown otherwise.</p>

<p>If this is the sort of problem you’re wrestling with, or you have a use case that makes partition weaving look worthwhile, come and talk to us on <a href="https://github.com/kroxylicious/kroxylicious">GitHub</a>, <a href="https://kroxylicious.slack.com">Slack</a>, or <a href="https://bsky.app/profile/kroxylicious.io">Bluesky</a>.</p>]]></content><author><name>Sam Barker</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="routing" /><summary type="html"><![CDATA[This is the fifth post in a series about routing in Kroxylicious, and it covers the last of the four patterns Post 1 named: connection switching, stream branching, topic weaving and partition weaving. Like the rest of the series, this is design-level thinking rather than a description of something shipped, and we haven’t tried any of it.]]></summary></entry><entry><title type="html">Topic Weaving: One client, many clusters</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html" rel="alternate" type="text/html" title="Topic Weaving: One client, many clusters" /><published>2026-11-02T23:00:00+00:00</published><updated>2026-11-02T23:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/11/02/topic-weaving-one-client-many-clusters.html"><![CDATA[<p>This is the fourth post in a series about routing in Kroxylicious. <a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> introduced the Routing API and named four patterns for using it: <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">connection switching</a>, <a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html">stream branching</a>, topic weaving and partition weaving. This post covers the third, topic weaving. Like the rest of the series, it is design-level thinking rather than a description of something shipped, and we haven’t tried it in practice.</p>

<p>Kafka clusters accumulate. Teams get their own cluster for isolation, another spins up for a different region, a third appears because somebody hit a partition limit and it was quicker to provision hardware than fight for headroom. The data teams feel it first: every pipeline that crosses a cluster boundary needs its own bootstrap config, its own credentials, its own mental model of which topic lives where. A data engineer building a join across two domains has to know which physical cluster each topic lives on — not because it’s relevant to their problem, but because Kafka makes it unavoidable.</p>

<h2 id="a-cluster-is-whatever-the-metadata-says-it-is">A cluster is whatever the metadata says it is</h2>

<p>A Kafka client starts with a list of bootstrap addresses and picks one to talk to. It sends a <code class="language-plaintext highlighter-rouge">Metadata</code> request there and gets back a list of brokers, the topics it asked about, and for every partition of those topics, the broker that leads it. From then on it connects directly to those brokers and sends each request to the right one. Everything the client believes about the cluster comes from <code class="language-plaintext highlighter-rouge">Metadata</code> responses.</p>

<p>The proxy sits in the middle and speaks Kafka, so it gets to write that response. A Virtual Kafka Cluster (VKC) is the stable address clients connect to, and until recently all the proxy did with the response was swap the broker addresses for its own. The brokers and topics still came from one real cluster. The Routing API changes who answers. It lets a router, a component you plug into the proxy, decide where each request goes and build the response from whatever it likes. The proxy supplies the plumbing; the router supplies the policy. Nothing says the answers have to come from the same cluster, and the client takes the response at face value.</p>

<p>That’s topic weaving. The client connects to a single VKC, but the namespace behind it is stitched together from topics on several real clusters. Topic A lives on cluster 1, topic B lives on cluster 2, and the router holds the map. Connection switching and stream branching both treat the cluster as the unit of routing: you’re deciding <em>where</em> traffic lands. Weaving decides <em>which topics</em> exist, where they live, and which applications can see them. The platform team encodes that once, in the routing layer, instead of every pipeline carrying its own copy.</p>

<p>The railway metaphor has served us well but it runs out of track here. Think of a sorting office instead. Parcels arrive addressed to a virtual destination — <code class="language-plaintext highlighter-rouge">orders</code>, <code class="language-plaintext highlighter-rouge">payments</code>, <code class="language-plaintext highlighter-rouge">inventory</code> — and the sorter routes each one down the right chute to its actual cluster. Every backing cluster is a peer — every write counts. That’s also why there are sharp edges. A transaction requires a coordinator, and a coordinator can only see its own cluster. If you need to write atomically to <code class="language-plaintext highlighter-rouge">orders</code> and <code class="language-plaintext highlighter-rouge">inventory</code> and they live on different clusters, the sorting office can’t help you.</p>

<p>The sorting office also has to solve a naming problem. One parcel is addressed <code class="language-plaintext highlighter-rouge">orders</code>. Fine — except this is an office that handles international mail, and two different countries have sent you a parcel addressed <code class="language-plaintext highlighter-rouge">orders</code>. The sorter can’t just route one of them, because both exist. Choosing is policy, and it belongs to whoever runs the office. The parcel doesn’t get a vote.</p>

<h2 id="what-the-client-knows">What the client knows</h2>

<p>A VKC already keeps the real cluster from the client: clients dial the proxy, never the brokers. What the patterns change is what stands behind that address, and how much of it the client can see.</p>

<p><strong>Connection switching</strong> makes the choice of cluster dynamic. The client still sees one cluster. The proxy can change which real one is behind it.</p>

<p><strong>Stream branching</strong> adds connections the client never sees. They may go to other clusters, or to another topic or broker on the same one. The client has one stream, and nothing is allowed to break that.</p>

<p><strong>Topic weaving</strong> hides the <em>seams</em>. The <code class="language-plaintext highlighter-rouge">MetadataResponse</code> lists brokers from every backing cluster. The client connects to all of them (via the proxy!), sends them requests, and takes their answers at face value. It just believes they belong to one cluster.</p>

<p>The client really is talking to several clusters. Some of what it carries with it, like a producer ID or an open transaction, was issued by one cluster and means nothing to the others. How much that matters depends on what you’re doing with it.</p>

<h2 id="whose-map-is-it-anyway">Whose map is it anyway?</h2>

<p>All of this hangs on one fact: every router owns a map — the <code class="language-plaintext highlighter-rouge">Metadata</code> response the client ends up seeing. The proxy supplies the plumbing to send a request down a route and get the answer back, and that’s all it does. It doesn’t merge anything. Splitting a request across clusters and stitching the replies together are the router’s job, and so is deciding what goes in the map.</p>

<h3 id="the-map-is-per-identity">The map is per identity</h3>

<p>A realisation from drafting a weaving router: nothing says two clients have to get the same <code class="language-plaintext highlighter-rouge">Metadata</code> response. In sorting office terms, labels are applied at the counter, for whoever is standing there. The same physical <code class="language-plaintext highlighter-rouge">orders</code> can go out as <code class="language-plaintext highlighter-rouge">london_orders</code> to one customer, as plain <code class="language-plaintext highlighter-rouge">orders</code> to another, and not at all to a third who has no business seeing it. The router can give each identity its own view of the namespace — different topic sets, different names for the same physical topic, or a completely different slice of the backing clusters. This is the same machinery that covers RBAC and multi-tenancy: a topic can be visible to one identity and absent for another. What no map can do is move a topic. It only says where one is.</p>

<p>One constraint follows directly: <strong>every proxy instance must give the same identity the same answer</strong>. If two instances return different maps for the same identity, topics appear and disappear depending on which instance answered. A static config satisfies this for free. The router has to know who is asking, so this also depends on authentication being in place.</p>

<h3 id="where-the-map-comes-from">Where the map comes from</h3>

<p>The simplest source is a table you write down: <code class="language-plaintext highlighter-rouge">orders</code> is visible from cluster A, <code class="language-plaintext highlighter-rouge">payments</code> from cluster B. That’s a static, client-facing map. The config says what <em>should</em> be visible from each backing cluster, but it can’t invent a topic. If <code class="language-plaintext highlighter-rouge">payments</code> doesn’t exist on B, it doesn’t appear, because the router can only show what the cluster actually has. The trouble is that it’s static. Clusters drift. Somebody creates a topic the map has never heard of and it stays invisible until a human edits the config. Somebody deletes one and it quietly vanishes from the client’s view.</p>

<p>A rule lets the map follow the clusters instead. The simplest is a prefixing router. Say each of the clusters has an <code class="language-plaintext highlighter-rouge">orders</code> topic. The router gives every cluster a prefix and applies it to whatever that cluster reports, so the client sees <code class="language-plaintext highlighter-rouge">london_orders</code>, <code class="language-plaintext highlighter-rouge">tokyo_orders</code> and <code class="language-plaintext highlighter-rouge">newyork_orders</code>. Nobody has to tell it about a new topic, because it never had a list. The rule has to be deterministic, though: <code class="language-plaintext highlighter-rouge">orders</code> from the “London” cluster must be <code class="language-plaintext highlighter-rouge">london_orders</code> today, tomorrow, after every restart, and on every proxy instance.</p>

<p>The rule has to run in both directions. The prefix goes on in <code class="language-plaintext highlighter-rouge">Metadata</code> responses. It comes off again in every request that names a topic, and the router uses it to pick the cluster. The brokers never hear of <code class="language-plaintext highlighter-rouge">london_orders</code>. It could be argued that the topic name now leaks the physical reality, since it says which cluster the topic lives on. That may be intentional and is perfectly reasonable when it is. From the client’s point of view it’s a naming convention, not a routing decision.</p>

<p>A catalogue service is the same idea with the rule replaced by a lookup. It says which physical topic on which cluster is known to an identity as what, so the names don’t have to follow a pattern at all, and it can change at runtime. Either way the router translates in both directions.</p>

<h3 id="when-names-collide">When names collide</h3>

<p>This is where the sorting office comes into its own. When two clusters both have an <code class="language-plaintext highlighter-rouge">orders</code>, and each label has to mean one topic, the sorter has three choices. It can pick a winner and only ever hand out cluster A’s <code class="language-plaintext highlighter-rouge">orders</code>, leaving B’s off the counter. It can give each a distinct label — <code class="language-plaintext highlighter-rouge">london_orders</code> and <code class="language-plaintext highlighter-rouge">tokyo_orders</code>. Or it can refuse the ambiguity and hand out neither. Which is right depends on policy. The router makes the call. The proxy has no opinion.</p>

<p>A fourth choice is to put <code class="language-plaintext highlighter-rouge">orders</code> on both and let the label cover two addresses. That’s a different kind of office, because the sorter now has to work out which address each individual parcel belongs to. It’s partition weaving, the final pattern in the series.</p>

<h3 id="writing-to-the-map">Writing to the map</h3>

<p>Everything so far has been about reading the map, and reading is aggregation. Each cluster reports what it has and the router combines the answers into one view. The clusters are the source of truth, and the router only decides which of their answers to show. Writes run the other way, and there is no source of truth to consult. A client calls <code class="language-plaintext highlighter-rouge">CreateTopics</code> for <code class="language-plaintext highlighter-rouge">X</code>: one request, which the router has to turn into work for some of the clusters. One, several or none. Neither the request nor the clusters say which. That’s disaggregation, and the answer can only come from policy. There’s no automatically correct one, and each option has a price:</p>

<ul>
  <li><strong>A default cluster.</strong> Simple and predictable. But one cluster risks becoming a hotchpotch of disjointed topics, and nothing about where the data ought to live gets a say.</li>
  <li><strong>A rule on the name.</strong> <code class="language-plaintext highlighter-rouge">london_orders</code> goes to London. No state, and the map follows for free. But the name is the placement, so moving a topic means renaming it, and a name that doesn’t fit the convention needs somewhere to go.</li>
  <li><strong>A catalogue.</strong> Placement is decided centrally and names can be anything. But a create is now two steps, update the catalogue and create the topic, and either can fail and leave the other behind.</li>
  <li><strong>Every cluster.</strong> The name exists everywhere, which is convenient for reads. It doesn’t share any data, since each cluster still holds its own. But the create is now a dual write, the problem from <a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html">stream branching</a>. If it works on A and fails on B, the topic half exists, and the router has to decide what to tell the client.</li>
  <li><strong>Refuse.</strong> The platform team owns the topology and nothing surprising appears. But anything that creates topics for itself, Kafka Streams being the usual suspect, stops working.</li>
</ul>

<p>All of these are legitimate. Which is right depends on who owns the topics and how much you trust the clients, so it’s the router’s call and the proxy has no opinion.</p>

<p>The one rule is that a write has to agree with the map. If the create lands on cluster B but the map says <code class="language-plaintext highlighter-rouge">X</code> lives on A, or doesn’t mention <code class="language-plaintext highlighter-rouge">X</code> at all, the client is told it worked and then can’t find its topic. A prefix rule gets this for free, because the prefix already says where <code class="language-plaintext highlighter-rouge">X</code> goes. A table or a catalogue has to be updated as part of the create, and that’s the router’s job too.</p>

<p><code class="language-plaintext highlighter-rouge">DeleteTopics</code>, <code class="language-plaintext highlighter-rouge">CreatePartitions</code> and <code class="language-plaintext highlighter-rouge">AlterConfigs</code> are the same question with a different verb: how many clusters, and which. Once the topic exists the map answers it.</p>

<h2 id="what-a-weaving-router-has-to-do">What a weaving router has to do</h2>

<p>Whichever way the map is built, the router has three jobs:</p>

<ul>
  <li><strong>Metadata.</strong> Ask every backing cluster, keep the topics the map shows this identity, and return the lot as one response.</li>
  <li><strong>Produce and fetch.</strong> Group the topics in a request by the cluster they belong to, send the pieces in parallel, and merge the replies into one.</li>
  <li><strong>Enforce the map.</strong> Apply the same rules to every request that names a topic, not just <code class="language-plaintext highlighter-rouge">Metadata</code>. Hiding a topic from a response isn’t enough if a <code class="language-plaintext highlighter-rouge">Produce</code> can still name it.</li>
</ul>

<h2 id="broker-ids-collide-too">Broker IDs collide too</h2>

<p>Topic names aren’t the only thing two clusters can have in common. Many Kafka clusters number their brokers from 0 or 1, so cluster A has a broker 2 and so does cluster B. It’s the Platform 2 problem from <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> again: put both in one <code class="language-plaintext highlighter-rouge">MetadataResponse</code> and the client has two different brokers answering to the same number. Broker 2 is Broker 2, remember.</p>

<p>The good news is that nobody writing a router has to deal with it. The runtime does, at every route boundary, with the same bijection as before: <code class="language-plaintext highlighter-rouge">downstreamId = (upstreamId * numRoutes) + routeIndex</code>. With two routes, broker 2 on route 0 becomes 4 and broker 2 on route 1 becomes 5, and requests are mapped back again on their way upstream. A router never sees the formula, only the IDs on its side of the boundary.</p>

<p>That last part is what allows us to compose routers into a DAG, and thus manage the complexity. What a router calls node 4 might be a real broker, or it might be a virtual node presented by another router further along. It neither knows nor cares. The IDs the client uses are the downstream side of the first router it meets; everything upstream of that is somebody else’s business, with its own mapping at its own boundary. They compose without anyone having to coordinate.</p>

<p>For weaving, that makes merging a non-event. Each route’s <code class="language-plaintext highlighter-rouge">Metadata</code> arrives already mapped into the router’s ID space, so the broker lists can be concatenated without a thought for collisions. It’s a bigger deal than it was for connection switching, where the client only ever saw one cluster’s brokers at a time. Here every cluster’s brokers are live at once. The constraint from <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> comes along too: change the number of routes and every ID moves.</p>

<p>Node IDs are the easy case. They’re a pure function of where a broker lives, so the runtime can translate them with arithmetic and no memory. Not everything the client carries around is that obliging.</p>

<h2 id="producer-ids-are-not-node-ids">Producer IDs are not node IDs</h2>

<p>A producer ID looks like the same problem. It’s an integer, a cluster hands it out, and the client carries it around and hands it back. So why not map it the same way? Because a node ID is spatial and a producer ID is temporal. A node ID is a coordinate: the proxy can lie about it as much as it likes, because no broker ever sees the lie, and if the proxy forgets its mapping it rebuilds the same one from the next <code class="language-plaintext highlighter-rouge">Metadata</code> response. A producer ID is a claim to be a particular live producer. The broker tracks it, uses it to discard retried batches, and fences anyone who presents it with a stale epoch. Lose the mapping and you can’t recompute it, because the identity was negotiated rather than derived.</p>

<p>That matters because every idempotent producer has one, and idempotence is the default. Each cluster issues its own <code class="language-plaintext highlighter-rouge">(producer ID, epoch)</code> pair, and the pair from cluster A means nothing to cluster B. The router has to give the client one identity and keep a map to the rest.</p>

<p>It also costs more than node IDs did. The producer ID is inside the checksummed part of a record batch, so rewriting it means decoding the batch, changing the header and recomputing the CRC. Weaving gives up zero-copy on the produce path.</p>

<h3 id="where-the-map-lives">Where the map lives</h3>

<p>The map has to survive a proxy restart and be visible to every proxy instance, because a client holds one connection per partition leader and those can land on different instances. So it needs a store, and building a consensus layer into the proxy is the wrong answer.</p>

<p>Kafka already has durable, replicated storage, so use it. Pick one cluster to be the <strong>boss</strong>. On it, keep a compacted topic keyed by the client’s producer ID, whose value maps each backing cluster to the <code class="language-plaintext highlighter-rouge">(producer ID, epoch)</code> it issued. When the client calls <code class="language-plaintext highlighter-rouge">InitProducerId</code>, the router initialises a producer on every backing cluster, writes the map to the boss, waits for the ack, and only then replies. Any instance that sees an unfamiliar producer ID reads the topic to find the map, and caches it from then on.</p>

<p>The map is small and changes only at init or when an epoch is bumped, so none of this is on the produce path. The sequence numbers are the part you’d expect to be hard, and they turn out not to be. They’re counted per producer and partition, a partition lives on exactly one cluster, and weaving sends each client batch upstream as exactly one batch for the same partition. The router passes the sequence through untouched. Only the producer ID and epoch are rewritten. As long as every cluster’s producer is initialised together, the counts start in step and stay there, so nothing needs storing per batch. An epoch bump follows the same rule. The client re-sends <code class="language-plaintext highlighter-rouge">InitProducerId</code> with its current ID and epoch, and the router has to bump every cluster and update the map, because the client resets its sequence numbers for all partitions at once.</p>

<p>That doesn’t make it free:</p>

<ul>
  <li><strong>The boss is a dependency.</strong> If it’s down, no new producer can start. Existing producers carry on from each instance’s cache, but a restarted instance has to read the topic before it can serve them.</li>
  <li><strong>Initialising everywhere is eager.</strong> One backing cluster being unavailable blocks new producers on all the others, including ones that would never have written to it.</li>
  <li><strong>The map needs cleaning up.</strong> Every short-lived producer leaves a key that compaction keeps until something removes it.</li>
</ul>

<p>We haven’t built this.</p>

<h3 id="consuming-is-the-easy-side">Consuming is the easy side</h3>

<p>A consumer never hands a producer ID back to a broker. A <code class="language-plaintext highlighter-rouge">read_committed</code> consumer sees the one cluster’s ID in the batch headers, the commit and abort markers and the aborted-transaction list of a fetch response, and all three come from the same cluster for the same partition. They already agree with each other, so the router passes them through. The one rule is for anything that rebuilds fetch batches: preserve the producer ID, epoch and control-batch flags, and keep the aborted list consistent.</p>

<h2 id="consumer-groups-need-a-coordinator-too">Consumer groups need a coordinator too</h2>

<p>Fetching is independent per partition, so the router can send each piece of a <code class="language-plaintext highlighter-rouge">Fetch</code> to the cluster that owns it. A consumer group is the part that isn’t. As a reminder, this is how the classic group protocol runs:</p>

<ol>
  <li><code class="language-plaintext highlighter-rouge">FindCoordinator</code> for the <code class="language-plaintext highlighter-rouge">group.id</code> returns the broker that coordinates the group.</li>
  <li>Each consumer sends <code class="language-plaintext highlighter-rouge">JoinGroup</code> to the coordinator, with its subscription as opaque bytes. The coordinator hands out member IDs and elects one member as the leader.</li>
  <li>The leader divides the partitions among the members and sends the result back in <code class="language-plaintext highlighter-rouge">SyncGroup</code>. The coordinator passes each member its share.</li>
  <li>From then on <code class="language-plaintext highlighter-rouge">Heartbeat</code> keeps the membership alive and <code class="language-plaintext highlighter-rouge">OffsetCommit</code> records progress in the coordinator’s <code class="language-plaintext highlighter-rouge">__consumer_offsets</code>. Any change in membership starts a new generation and sends everyone back to step 2.</li>
</ol>

<p>All of that state lives on one broker, in one cluster.</p>

<p>The obvious answer is to fan membership out to every cluster. Each cluster’s coordinator would then run its own copy of the group, with its own member IDs, generation and leader, and decide for itself when a member has gone quiet. Nothing keeps those copies in step. If cluster B decides a member has gone quiet and A doesn’t, B starts a rebalance and A doesn’t, and the client’s one membership is something two clusters disagree about.</p>

<p>There’s a way out, because nothing in a consumer group has to be atomic. An <code class="language-plaintext highlighter-rouge">OffsetCommit</code> reports success or failure per partition, so there is no point of no return to line up. Pick one cluster to be the boss for membership, and split the offsets by topic:</p>

<ul>
  <li><strong><code class="language-plaintext highlighter-rouge">FindCoordinator</code></strong> for a group answers with the boss’s coordinator. Every proxy instance has to give the same answer, so derive it from something the router knows, like the <code class="language-plaintext highlighter-rouge">group.id</code> or the principal. Nothing needs storing.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">JoinGroup</code>, <code class="language-plaintext highlighter-rouge">SyncGroup</code>, <code class="language-plaintext highlighter-rouge">Heartbeat</code> and <code class="language-plaintext highlighter-rouge">LeaveGroup</code></strong> go to the boss and nowhere else. The coordinator treats each member’s subscription as opaque bytes, and the group leader works out the assignment client-side from the merged <code class="language-plaintext highlighter-rouge">Metadata</code>. It doesn’t matter that the boss has never heard of some of the topics.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">OffsetCommit</code> and <code class="language-plaintext highlighter-rouge">OffsetFetch</code></strong> are split by topic, like <code class="language-plaintext highlighter-rouge">Produce</code>. The boss rejects topics it doesn’t have, and the other clusters have never seen the member. So the router sends their share as standalone commits, with no member ID and generation -1, which a cluster accepts for a group with no active members. An <code class="language-plaintext highlighter-rouge">OffsetFetch</code> that asks for every topic goes to every cluster, and the replies are merged.</li>
</ul>

<p>This works because the boss is never asked about anything that isn’t its own. Membership names no topics, and the offsets it receives are for topics it hosts.</p>

<p>The single boss is cheaper than fanning out, but not free:</p>

<ul>
  <li><strong>The boss is a dependency.</strong> If its cluster is down, no group can join or rebalance, even one that only reads topics elsewhere.</li>
  <li><strong>Fencing is partial.</strong> The boss checks the generation, but a standalone commit to another cluster isn’t checked, so a zombie consumer can still commit offsets there.</li>
  <li><strong>The group is in pieces.</strong> Another cluster shows offsets and no members, and offsets expire on each cluster separately. Lag tooling has to ask through the proxy.</li>
  <li><strong>The new protocol is out.</strong> With KIP-848’s <code class="language-plaintext highlighter-rouge">ConsumerGroupHeartbeat</code>, the broker computes the assignment itself, so the boss would have to resolve topics it doesn’t have.</li>
</ul>

<p>If you’d rather not depend on this, keep each group’s topics on one cluster, or use <code class="language-plaintext highlighter-rouge">assign()</code> and store the offsets yourself.</p>

<h2 id="transactions-stop-at-the-cluster-boundary">Transactions stop at the cluster boundary</h2>

<p>A transactional producer starts by sending <code class="language-plaintext highlighter-rouge">FindCoordinator</code> for its <code class="language-plaintext highlighter-rouge">transactional.id</code>, then <code class="language-plaintext highlighter-rouge">InitProducerId</code> to whichever broker the answer names. From then on that coordinator tracks the transaction, and when the producer commits it writes the commit or abort markers to the partitions involved. The coordinator, its transaction log and those markers all belong to one cluster.</p>

<p>Consumer groups got away with a single coordinator because nothing in them had to be atomic. A transaction is the opposite: its whole purpose is that several writes land together or not at all.</p>

<p>A coordinator can only see its own cluster, so the obvious answer is to give the client one everywhere. The router fans <code class="language-plaintext highlighter-rouge">InitProducerId</code> out to every backing cluster and starts a transaction on each. As the client registers partitions and produces, the router sends each call to the cluster that owns the topic, using the producer ID and epoch that cluster issued. The client holds one producer ID and the router holds the mapping to the rest. That mapping has to survive a router restart and be visible to every proxy instance, so it needs the kind of store described <a href="#where-the-map-lives">above</a>. That’s real work, but it’s work you can do.</p>

<p>It falls over at commit. The client sends one <code class="language-plaintext highlighter-rouge">EndTxn</code> and the router has to turn it into one per cluster. On each cluster, commit is a point of no return: once the coordinator has written its decision, it will commit, whatever else happens. Until then it is free to refuse, and each cluster decides for itself. Cluster 1 can pass the point of no return while cluster 2 says no. None of the ways cluster 2 can say no are transient. The transaction may have timed out, since each cluster runs its own clock from the first partition added there. A zombie may have bumped the producer epoch. The ACLs may differ. Then <code class="language-plaintext highlighter-rouge">orders</code> has its records and <code class="language-plaintext highlighter-rouge">inventory</code> doesn’t, and whatever the client is told is wrong for one of them.</p>

<p>A state store doesn’t rescue this. It can remember that the router meant to commit cluster 2, but it can’t make cluster 2 agree. Reordering the commits doesn’t help either, because whichever goes first can’t be undone.</p>

<p>So stop negotiating and do what worked for consumer groups: pick a boss, and let its coordinator run every transaction. The client’s <code class="language-plaintext highlighter-rouge">InitProducerId</code>, <code class="language-plaintext highlighter-rouge">AddPartitionsToTxn</code> and <code class="language-plaintext highlighter-rouge">EndTxn</code> all go there, while the records still go to whichever cluster owns the topic. Commit is now a single decision on a single coordinator, so the atomicity problem is gone.</p>

<p>It doesn’t survive the first write to another cluster. The consumer group boss was never asked about another cluster’s topics, but here the client registers each partition with the coordinator before it writes to it. The boss’s coordinator doesn’t recognise <code class="language-plaintext highlighter-rouge">inventory</code>’s partitions, because they aren’t in its cluster. It refuses them, and the transaction never gets as far as commit.</p>

<p>Both attempts fail for the same reason. Somewhere there has to be a moment when every cluster has promised to commit before any of them does, and Kafka’s transaction protocol has no such step.</p>

<h2 id="what-to-do-today">What to do today</h2>

<p>The router can at least fail loudly. It has to answer <code class="language-plaintext highlighter-rouge">FindCoordinator</code> before it knows what the transaction will touch, so it picks using something it does know, like the <code class="language-plaintext highlighter-rouge">transactional.id</code> or the authenticated principal (the <a href="/blog/kroxylicious-proxy/2026/05/21/topic-routing.html">topic routing proof of concept</a> used the principal). It then rejects a write that strays onto a different cluster. An error in development beats a half-committed transaction in production.</p>

<p>Does it matter for your deployment? Transactions are fine within a cluster, so this is not a blanket ban on using them. The question is whether any single transaction needs to touch topics that live on different clusters. If your router keeps <code class="language-plaintext highlighter-rouge">orders</code> and <code class="language-plaintext highlighter-rouge">inventory</code> together, a transaction across them should work as it always did. But transactions may be more pervasive than a first glance suggests. Kafka Streams uses them to provide exactly-once semantics, so an application that never mentions a transaction can still be running one. If that sounds like your estate, check where the topics it reads and writes live before you weave.</p>

<h2 id="kip-939-might-add-the-missing-step">KIP-939 might add the missing step</h2>

<p><a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-939%3A+Support+Participation+in+2PC">KIP-939</a> is the obvious objection to leaving it there. It’s accepted, it’s about two-phase commit, but has not landed in Kafka yet. It lets Kafka take part in somebody else’s two-phase commit: a producer can prepare a transaction, and a prepared transaction isn’t aborted by the timeout while it waits for an external coordinator to decide. That is the promise our two attempts were missing.</p>

<p>In principle the router could be that coordinator. It would start a transaction on each backing cluster, wait for all of them to prepare, record the decision, and then tell each one to commit. The client would still believe it was talking to a single coordinator. The hard part is the middle step. Someone has to durably record the decision between “everyone prepared” and “everyone committed”, and survive a crash in the gap. A router that does that needs a durable log of its own, recovery after a restart, and a way to stop two proxy instances disagreeing about the outcome. That is the consensus layer from <a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a>, and the Kafka community has just spent years moving from ZooKeeper to KRaft so that nobody has to run a second consensus system alongside Kafka. Whether asking a proxy to bring its own is acceptable depends on your constraints — it is not something we are planning to do.</p>

<p>That said, this is where the boss earns a second job. The decision log could live in a compacted topic on the same cluster that holds the producer ID map, with nothing new to deploy. The recovery logic is still yours to write.</p>

<p>That gets harder still when the client is already a coordinator. A stream processor like Flink can run its own two-phase commit across Kafka and other systems. Put a weaving router in front of Kafka and Flink sees one participant, while the router has to act as a coordinator for the clusters behind it: two-phase commit nested inside two-phase commit. The KIP describes a flat arrangement of one coordinator and its participants, and says nothing about a participant in the middle.</p>

<h2 id="picking-a-boss">Picking a boss</h2>

<p>The producer ID map is the first time we have reached for a <strong>boss</strong> cluster, but the underlying problem keeps recurring.</p>

<p>Reads aggregate naturally. Every cluster reports what it has, and the router combines the answers into a single view. Writes and state do not aggregate, because there is no existing reality across the clusters to consult. When a client creates a topic, negotiates an identity, or coordinates a decision, the router cannot ask the backing clusters for an answer that does not exist yet. It has to make a choice, and it has to remember what it chose. That memory must survive proxy restarts and be shared across a fleet of proxy instances without inventing a new consensus layer. The Kafka-native answer is to pick one cluster to host that shared state: a <strong>boss</strong> cluster.</p>

<p>None of the boss cluster roles are tested. They make sense in principle, but they split on what the cluster is asked to do:</p>

<table>
  <thead>
    <tr>
      <th>Problem</th>
      <th>Job</th>
      <th>In principle?</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Topic creation (<code class="language-plaintext highlighter-rouge">CreateTopics</code>)</td>
      <td>Default cluster for new topics (or catalogue store)</td>
      <td>Works, with the hotchpotch caveat</td>
    </tr>
    <tr>
      <td>Producer ID mapping</td>
      <td>Registry in a compacted topic</td>
      <td>Works</td>
    </tr>
    <tr>
      <td>Consumer groups</td>
      <td>The boss’s coordinator runs membership; offsets are split by topic</td>
      <td>Works in principle (classic protocol only)</td>
    </tr>
    <tr>
      <td>Transactions</td>
      <td>The boss’s coordinator runs every transaction</td>
      <td>Fails (remote content)</td>
    </tr>
    <tr>
      <td>Distributed commit (KIP-939)</td>
      <td>Decision log for two-phase commit</td>
      <td>Feasible, untested</td>
    </tr>
  </tbody>
</table>

<p>The test for whether a boss works is whether the content it is asked to hold or decide is <strong>local</strong> to its cluster or <strong>remote</strong>.</p>

<p>Local content is anything that lives on the boss itself. Proxy bookkeeping in internal topics is the clearest case: the proxy writes its state there and reads it back, and the brokers on the boss are just durable storage for bytes. A newly created topic that the boss hosts is local too, and so is consumer group membership, because it names no topics. Remote content is anything the boss would have to answer for on behalf of another cluster. A transaction coordinator on the boss can track and commit writes to its own partitions, but it rejects writes to partitions on other clusters because they do not exist in its metadata.</p>

<p>Where that boss cluster lives is a separate choice:</p>

<ul>
  <li><strong>One of the data clusters.</strong> The cheapest option: no extra infrastructure to deploy or monitor. But you couple the control plane of all your clusters to one of them. If that data cluster goes down or undergoes maintenance, administrative operations and new producers stall across the entire mesh.</li>
  <li><strong>A small dedicated cluster.</strong> Isolates the router’s state and blast radius from tenant data traffic. If a data cluster fails, only its own topics are affected. The cost is the operational overhead of running one more Kafka cluster.</li>
</ul>

<h2 id="egress-ingress-or-does-it-matter">Egress, ingress, or does it matter?</h2>

<p>The question from <a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> returns: should the proxy sit on the client side of the link (egress) or in front of the brokers (ingress)? <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> covered this for connection switching; the answer for topic weaving is similar in shape but lands in a different place.</p>

<p>Co-locating the proxy with an arbitrary data cluster puts them in the same failure domain. If that cluster has an outage, the proxy instances go down with it—cutting off access to healthy topics on all the other clusters too.</p>

<p>Client-side egress avoids that coupling. When an individual backing cluster goes down, the proxy stays alive. It returns partition-level errors for the affected cluster while continuing to serve produce and fetch traffic to every other cluster normally. For most topologies, keeping backing cluster failures isolated makes client side the safer default.</p>

<p>That doesn’t make client side categorically better. If you adopt the boss pattern, co-locating the proxy fleet with the boss cluster has a compelling advantage: <strong>latency</strong>.</p>

<p>Every new producer initialisation, transaction prepare, or catalogue lookup involves the boss. Putting the proxy next to the boss turns those round-trips into local network hops rather than cross-link calls. You accept that the proxy shares a failure domain with the boss—but if the boss is down, those control operations were going to stall anyway.</p>

<p>If you don’t use a boss, or if isolating data-cluster outages is paramount, client side is the natural home. If you do use a boss and want fast admin and init paths, co-locating with it is well worth considering.</p>

<h2 id="know-when-to-pick-a-different-chute">Know when to pick a different chute</h2>

<p>Every pattern in this series trades protocol simplicity for operational flexibility. Topic weaving sits near the top of that trade, which makes knowing when <em>not</em> to use it just as important as knowing how it works.</p>

<p>If your problem is moving a whole workload, use <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">connection switching</a>. A blue/green cutover, a cluster migration, or insulating a legacy application from infrastructure churn only needs the router to throw points at connection time. It is completely stateless, involves zero metadata fabrication or PID rewriting, and adds no moving parts. If all the mail is going to the same city, you don’t need a sorting office.</p>

<p>If your problem is data locality or disaster recovery, use <strong>replication</strong>. MirrorMaker 2, KIP-1279 Cluster Mirroring, or your vendor’s replication engine copy the committed log asynchronously after the fact. Topic weaving lets a client in London reach a topic in Tokyo without configuring a second bootstrap address, but the network packets still cross the ocean on every fetch. If you need local read latency or an independent replica that survives a regional outage, replicate the bytes. Weaving provides unified access; replication provides local copies.</p>

<p>If your problem is tapping an auxiliary stream, use <a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html">stream branching</a>. Forking a produce stream to feed a staging cluster, an audit topic, or a PII-scrubbed shadow works best when the branch is best-effort and can tolerate the odd gap or duplicate.</p>

<p><strong>Topic weaving</strong> is the right choice when topics have distinct, legitimate homes across multiple clusters—by team, by tenant, or by compliance boundary—and you want clients to interact with them as a single coherent estate. It eliminates multi-client boilerplate in application code and hides physical cluster sprawl behind a clean virtual catalogue.</p>

<p>The boundary is clear: topic weaving works as long as each topic lives entirely on one backing cluster. If your producers need atomic cross-topic transactions across cluster boundaries, no proxy can fix that; those topics must share a physical cluster. And if even a single topic cannot live on one cluster—if you need its partitions split across different physical environments—you have reached the edge of topic weaving.</p>

<hr />

<p>Topic weaving gives you a single logical cluster stitched from whole topics scattered across many physical backends. The client gets one bootstrap address, one cluster view, and zero awareness of the seams behind it. The proxy takes care of the routing table, broker ID collisions, and (with a boss) producer identities.</p>

<p>Which leaves one final question. If we can weave whole topics together to build a virtual catalogue, why stop at whole topics? Kafka’s real unit of storage, throughput, and parallelism isn’t the topic—it’s the partition. Next: <strong>partition weaving</strong>.</p>

<p>If this is the sort of problem you’re wrestling with, or if topic weaving looks like something you could use, come and talk to us on <a href="https://github.com/kroxylicious/kroxylicious">GitHub</a>, <a href="https://kroxylicious.slack.com">Slack</a>, or <a href="https://bsky.app/profile/kroxylicious.io">Bluesky</a>.</p>]]></content><author><name>Sam Barker</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="routing" /><summary type="html"><![CDATA[This is the fourth post in a series about routing in Kroxylicious. Post 1 introduced the Routing API and named four patterns for using it: connection switching, stream branching, topic weaving and partition weaving. This post covers the third, topic weaving. Like the rest of the series, it is design-level thinking rather than a description of something shipped, and we haven’t tried it in practice.]]></summary></entry><entry><title type="html">Stream Branching: Mind the gap</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html" rel="alternate" type="text/html" title="Stream Branching: Mind the gap" /><published>2026-10-29T03:00:00+00:00</published><updated>2026-10-29T03:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html"><![CDATA[<p><a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> introduced the Routing API: instead of a fixed pipe from client to cluster, the proxy interprets the Kafka protocol and can route traffic wherever you need it to go. <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> covered <strong>connection switching</strong> — the simplest use of that capability, where the proxy picks <em>which</em> cluster a client connects to at connection time, and can switch it without the client noticing.</p>

<p>This post is about the next pattern: <strong>stream branching</strong>. Where connection switching makes routing decisions that last a connection’s lifetime, stream branching goes further — the router can invent additional connections the client never asked for, and send traffic down them alongside or instead of the primary. We’ll look at what that buys you, the golden rule (the mainline is the source of truth, branch lines are best effort), where it breaks, and when to get off the train.</p>

<p>If it helps to have a mental model: think of a railway network — Post 1 introduced it and we’ll keep riding it. The client’s stream is the express running down the mainline. At each station, the stationmaster can inspect passing traffic, re-route it to a different platform, or dispatch a whole new but very similar train down branch lines to other destinations — all without stopping the express or telling the passengers anything changed (they might notice however).</p>

<h2 id="the-express-doesnt-wait">The express doesn’t wait</h2>

<p>There is one golden rule in stream branching. Everything else in this post follows from it:</p>

<blockquote>
  <p><strong>The mainline is the source of truth. Branch lines are best effort.</strong></p>
</blockquote>

<p>The simplest possible branch is a pure duplication router. The client produces to the primary cluster; the router silently sends an identical copy to a second cluster. The client sees only the primary’s acknowledgement and has no idea the second write happened.</p>

<p><img src="/assets/blog/images/routing-series/naive-dr.svg" alt="A producer sends a Produce request to the router. The router forwards it on the mainline to the primary cluster and, on a branch, to a DR cluster that receives an identical copy. The ProduceResponse returned to the producer carries only the primary cluster's verdict." /></p>

<p>Yes, I know this looks like a DR solution, it’s really not. By definition the branch is a best-effort copy; the DR cluster can have holes and duplicates that the primary doesn’t — <a href="#mind-the-gap">Mind the gap</a> goes into the gory details. You can’t trust it for failover — the only way to verify nothing’s missing is to compare both copies, and if both copies are online you don’t need to fail over. If you need reliable replication to a DR cluster, use MirrorMaker 2 or <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-1279%3A+Cluster+Mirroring">KIP-1279</a> cluster mirroring — they were designed and built for that job.</p>

<p>Cloning a feed to a staging environment is the trivial example, even though audit and telemetry are the more likely reasons to branch in practice. You get a complete-ish copy of production traffic to test against real-shaped data, and the odd missing record doesn’t affect whether your code works. It’s also the branch you’d most expect to have a bad day, and that is exactly what the golden rule is for.</p>

<p>And why would staging have a bad day? Your staging cluster is big enough for your production load, right? No, I thought not. As described in <a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a>, routers exist in a DAG; each node has a filter chain, a composable pipeline of steps that can inspect and transform requests as they pass through. Add a sampling filter on the staging branch that drops 90% of produce requests and forwards the rest. The mainline is untouched; staging gets a 10% sample; nobody had to change any application code.</p>

<p>Speaking of filter chains: your production data is full of PII that can’t touch staging. Add a redaction filter after the sampler — no point scrubbing records you’re about to throw away. The filters compose.</p>

<p><img src="/assets/blog/images/routing-series/staging-branchline.svg" alt="A producer sends a Produce request to the router. The router forwards it on the mainline to the primary cluster. On a branch, it samples 10% of records, redacts them, and writes them to a staging cluster. The ProduceResponse returned to the producer carries only the primary cluster's verdict." /></p>

<p>So far we have talked about taking the original record and forwarding it somewhere. That’s powerful, but why stop there? Filters can observe, transform, or act on requests — and what’s the use in observing a record without making that observation visible somewhere? We are all Kafka fans here, so of course we send our telemetry via Kafka too. A branch can derive some interesting information from the produce request and send it merrily on its way to the telemetry cluster.</p>

<p><img src="/assets/blog/images/routing-series/telemetry-branchline.svg" alt="A producer sends a Produce request to the router. The router forwards it on the mainline to the primary cluster. On a branch, it derives telemetry from the records and writes that to a telemetry cluster. The ProduceResponse returned to the producer carries only the primary cluster's verdict." /></p>

<p>The branch writes belong to the router, not the client. The client didn’t send them, never sees their responses, and has no idea they exist. The router opens its own connections to branch targets, dispatches its own copy of the request to each, and decides what to do when they fail.</p>

<p>That’s the normal contract: branch writes are fire-and-forget from the client’s perspective. A filter <em>could</em> stall the <code class="language-plaintext highlighter-rouge">ProduceResponse</code> until a branch acks, but that just buys you the latency hit without any kind of atomicity guarantee. <a href="#mind-the-gap">Mind the gap</a> explains why.</p>

<h2 id="replica-routing-per-request-dispatch">Replica routing: per-request dispatch</h2>

<p>So far we’ve focused on produce requests. Branching on the fetch side took me a while to realise the value of, but there are two cases worth a look.</p>

<p>The first is a branch driven by the response: the primary’s <code class="language-plaintext highlighter-rouge">FetchResponse</code> goes back to the client, and the router also sends a small record of what was read (per-consumer bytes, lag, an audit trail of who read what) down a branch line. The catch is that a delivered fetch isn’t a processed one, and a refetch counts the same records twice. If you need to know the group member really acked, tap its <code class="language-plaintext highlighter-rouge">OffsetCommitRequest</code> as well: the request says what the member claims to have processed, and the <code class="language-plaintext highlighter-rouge">OffsetCommitResponse</code> says whether the broker accepted it.</p>

<p>The second is a shadow fetch: the router sends its own read-only fetch to a candidate cluster, say to validate a passive site is in sync with the active site. The client only cares about the primary’s response. The router can compare the shadow response with the primary and summon help if they aren’t identical. We don’t need to check every response; a sample would work well here. It needs the offsets to line up between the two clusters, and the shadow must never be allowed to hold up the mainline. Both are forgiving in a way the produce side isn’t. Neither is a copy of the client’s data, so there’s no ghost or MIA (missing in action) batch to reconcile.</p>

<p>Branching isn’t the only thing worth doing on the fetch side though. Sometimes the better move is to change where the fetch goes — not to a different cluster, but to a different broker on the same one. That’s a substitution, not a branch: one stream, better-routed.</p>

<p>Kafka supports rack awareness, and if you’re running in the cloud you really do want it on — egress costs can be punishing. But to get it working you have to ensure every application uses <code class="language-plaintext highlighter-rouge">client.rack</code> with the correct values. If you’re anything like me, you hate playing config whack-a-mole. A layer 7 proxy, one that understands the Kafka protocol, can centralise this.</p>

<p>There’s one subtle obstacle though: even if a filter can see that a <code class="language-plaintext highlighter-rouge">FetchRequest</code> belongs in <code class="language-plaintext highlighter-rouge">eu-west-1a</code>, knowing that isn’t enough. The client dialled broker 1 in <code class="language-plaintext highlighter-rouge">eu-west-1c</code>, so all its traffic must flow there. A filter could stamp a <code class="language-plaintext highlighter-rouge">rack_id</code> onto fetches from a misconfigured client. If the brokers are running <code class="language-plaintext highlighter-rouge">RackAwareReplicaSelector</code> the client will be pointed at a nearby replica, at the cost of an additional round trip now and again to redirect it. That only works if someone has configured the brokers for it. A router needs neither the brokers’ help nor the client’s. Given its own idea of which broker lives in which rack, it can send the fetch straight to a nearby replica, with no redirect. The Routing API makes that possible: the backend connection is no longer fixed at connection time, it can be chosen per request. We can now redirect the fetch to the broker in the appropriate rack rather than the one the client asked for.</p>

<p>A <code class="language-plaintext highlighter-rouge">FetchRequest</code> payload just says “partition 3, from offset N”. The broker ID is encoded by <em>which connection</em> the client sends it on — that’s the seam a custom router can exploit. When the <code class="language-plaintext highlighter-rouge">FetchRequest</code> arrives on the broker 1 connection, the router inspects the partition’s replica set, sees that broker 3 is in the same AZ and fully caught up, and asks the runtime to dispatch it down the route for what it calls broker 3 instead — the runtime handles the rest:</p>

<p><img src="/assets/blog/images/routing-series/replica-routing.svg" alt="A consumer in availability zone A sends a Fetch request to a Kroxylicious proxy in the same zone. The proxy sends it to broker 3, a replica in zone A, instead of broker 1, the leader in zone C, which never sees the request. This avoids the cross-zone network charge." /></p>

<p>The router can do what it thinks is best here: it can honour a client rack, ignore it, or invent one if the client didn’t set it. A router doesn’t need to trust what the client says about its own location; it can route correctly regardless. The request payload is untouched, the original broker never receives the fetch, and the cross-AZ charge never reaches the invoice. What makes that possible: the proxy can hold two backend sockets — one to the leader, one to the local replica — and choose between them per request. To the client, that’s still one broker on one cluster.</p>

<p>One constraint the dispatcher can’t escape: <strong>proxy placement</strong>. If the proxy is in <code class="language-plaintext highlighter-rouge">eu-west-1b</code> and the consumer is in <code class="language-plaintext highlighter-rouge">eu-west-1a</code>, pulling from a broker in <code class="language-plaintext highlighter-rouge">eu-west-1a</code> still costs a cross-AZ hop to reach the proxy first. There’s no hyperspace jump. For replica routing to pay off, the proxy fleet needs to be co-located with the clients it serves. You will know this already from the post on <a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">connection switching</a>.</p>

<p>One more constraint, this time from the protocol. Normally a fetch session lives on the broker that created it, so an incremental fetch only makes sense to that broker. If the router sends a partition’s fetches to a different broker than last time, the new broker has never heard of the session. The Java client treats that as recoverable. It falls back to a full fetch and carries on, but each change costs a failed round trip. So pick a replica and stick with it unless you have a good reason to move.</p>

<p>There’s room to go further. Someone might want to explore using out-of-band telemetry — OTel metrics, say — to route fetches based on broker load within the set of in-sync replicas in the same AZ. Proximity routing alone already solves a real, expensive problem; load-aware routing within that constraint is an open question worth exploring.</p>

<h2 id="cheap-branching-is-not">Cheap, branching is not</h2>

<p>Routing decisions themselves are cheap — inspecting a header, picking a route, forwarding bytes. Substitution patterns like replica routing stay in that lane: one request, one response, different route, minimal overhead.</p>

<p>Inventing new requests is where we start incurring noticeable costs. Every branch is additional traffic on the wire, and if a filter needs to inspect or transform record content, you’re paying CPU and memory costs too — decompress the batch, deserialise every record, do your work, re-serialise, recompress. On a busy topic with <code class="language-plaintext highlighter-rouge">zstd</code> batches that’s real CPU, inline on the proxy, for every batch that takes the branch. Size your proxy fleet for the most expensive station on the line, not for the mainline.</p>

<p>Branching can have other awkward memory effects. The client’s request/response is over as soon as the mainline acks, but the router may need to hold on to the request after it has sent the response to the client. Depending on the router, it could need to keep it until every related branch is done. So the memory pressure can, and likely will, outlast the exchange the client sees, and the slower the branch, the longer it stretches. It’s obvious, but worth stating: more branches means more to hold, for longer.</p>

<p>Keep it self-contained. Every station handles each batch on its own, acting on each request and response as it passes. Joins, windows, and aggregations over time need state that survives restarts, rebalances, and late data — Kafka Streams and Kafka Connect exist to manage exactly that. A router that starts accumulating state across batches has become a badly built stream processor, and badly built stream processors are how senior engineers get paged at 3am.</p>

<h2 id="egress-ingress-or-does-it-matter">Egress, ingress, or does it matter?</h2>

<p><a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Post 2</a> asked whether the proxy belongs on the client side of the link (egress) or the broker side (ingress), and for DR the answer was egress: a proxy that dies with the primary can’t flip anything. That argument carries over unchanged, and probably matters more. Stream branching adds a second question: what is the branch local to? The protocol doesn’t care where the proxy sits, but the branch target is usually closer to one end of the link than the other. The rule of thumb: all else being equal, put the proxy close to the thing you’re branching to.</p>

<p>Your topology will have opinions of its own:</p>

<ul>
  <li><strong>Staging</strong> sits next to production, so the proxy goes at the broker end and the shadow never crosses the link. <strong>Audit</strong> goes there too: if the brokers are only reachable through the proxy, nobody can opt out of being audited.</li>
  <li><strong>Telemetry</strong> can go either way. If the observability stack lives with the clients, so does the proxy.</li>
</ul>

<p>Redaction follows the trust boundary instead. Say your telemetry feed goes to in-house storage with the IP addresses intact, and a copy goes to a third-party anomaly detector minus the PII. The scrubbing has to happen before the copy leaves your domain, so the proxy goes wherever that exit is. Flip it round and redact what an untrusted client is allowed to read, and the proxy lands at the broker end. Same filter, opposite ends of the link.</p>

<p>Replica routing isn’t really an ingress or egress question at all. The consumer, the proxy and the replica it fetches from all need to share an AZ, otherwise the cross-AZ hop just moves to a different leg. That’s the <strong>proxy placement</strong> constraint from earlier, and it holds whichever end of the link the proxy sits at.</p>

<h2 id="mind-the-gap">Mind the gap</h2>

<p>Stream branches generally take the form of a dual write, and dual writes are like juggling with knives. Fine as long as you catch the hilt, painful if you catch the blade.</p>

<h3 id="there-is-no-undo">There is no undo</h3>

<p>A Kafka log only ever appends. When a batch lands on one cluster and fails on the other, nothing can take the successful write back. That leaves the branch out of step with the primary in two ways, and we’ll need names for them:</p>

<ul>
  <li>An <strong>MIA (missing in action) batch</strong> is one the primary has and the branch doesn’t. The branch is behind, and has a hole.</li>
  <li>A <strong>ghost batch</strong> is one the branch has and the primary doesn’t. The branch is ahead, and if the client retries it becomes a duplicate on the branch.</li>
</ul>

<p>There are three ways to sequence the branch write, and it is worth understanding what each one actually buys you.</p>

<p>The simplest is <strong>fire-and-forget</strong>: one produce request in, one mainline produce request out, plus however many branch copies you want to send. This is a best-efforts pattern, and the edge cases are more common than a casual inspection might imply.</p>

<p>To mitigate some of those, there is <strong>dispatch on ack</strong>. The router captures a copy of the client’s produce request on arrival and forwards the mainline request. When the ack comes back from the mainline broker, the router replies to the client and then dispatches the branch copies asynchronously. Because the branch only ever receives batches after the mainline has committed them, ghost batches are eliminated — with one caveat: if the primary committed but the ack was lost in transit, the client retries, the mainline deduplicates, and the router dispatches a second branch copy on the second ack. The mitigations aren’t universal:</p>

<ul>
  <li><strong>Acks are per partition.</strong> A produce response can be a partial success; what do we dispatch then? Everything? Just the ones that worked? It all depends on what is going to the branch. If your branch is generating an audit trail or telemetry of successful writes, dispatching only the successes is exactly what you want. The router simply decomposes the original request and rebuilds a new batch containing only the successful partitions on the fly.</li>
  <li><strong>Duplicates are still possible.</strong> The client might still retry, if for any reason the ack the proxy sent never reaches the client. The client will retry, the mainline broker will discard the duplicates and ack again, and the router dispatches a second branch copy (because it gets the acks). No ghost was involved, and the branch still ends up with a duplicate.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">acks=0</code> has nothing to trigger on.</strong> Those producers never get a response, so we have nothing to dispatch on. Fire-and-forget is likely fine here, however.</li>
</ul>

<p>The obvious next step is to wait for the branch acks too before replying to the client. It doesn’t work. The primary has already accepted the batch, so you have to send that ack to the client regardless — there is no rolling it back. All that’s happened is the client waited longer to receive the same ack it would have got anyway, and the failed branch write is still there to deal with. This holds whether you used fire-and-forget or dispatch on ack as the trigger.</p>

<p>We can lay out what each of the first two patterns does with the tables below. To keep them readable I’m dealing in whole requests and ignoring partial successes.</p>

<p><strong>Fire-and-forget</strong></p>

<table>
  <thead>
    <tr>
      <th>Primary</th>
      <th>Branch</th>
      <th>Client sees</th>
      <th>Branch ends up with</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>✅</td>
      <td>✅</td>
      <td>Success</td>
      <td>A copy. The happy path.</td>
    </tr>
    <tr>
      <td>✅</td>
      <td>❌</td>
      <td>Success</td>
      <td>An MIA batch: a hole</td>
    </tr>
    <tr>
      <td>❌</td>
      <td>✅</td>
      <td>Error, so it retries</td>
      <td>A ghost batch now, and a duplicate after the retry</td>
    </tr>
    <tr>
      <td>❌</td>
      <td>❌</td>
      <td>Error, so it retries</td>
      <td>Whatever the retry produces</td>
    </tr>
  </tbody>
</table>

<p><strong>Dispatch on ack</strong></p>

<table>
  <thead>
    <tr>
      <th>Primary</th>
      <th>Branch</th>
      <th>Client sees</th>
      <th>Branch ends up with</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>✅</td>
      <td>✅</td>
      <td>Success</td>
      <td>A copy. The happy path.</td>
    </tr>
    <tr>
      <td>✅</td>
      <td>❌</td>
      <td>Success</td>
      <td>An MIA batch: a hole</td>
    </tr>
    <tr>
      <td>❌</td>
      <td>⛔</td>
      <td>Error, so it retries</td>
      <td>Nothing — the branch write wasn’t dispatched</td>
    </tr>
    <tr>
      <td>❌</td>
      <td>❌</td>
      <td>Error, so it retries</td>
      <td>Whatever the retry produces</td>
    </tr>
  </tbody>
</table>

<p>The MIA batch is the one people expect: the branch falls behind and nobody tells the client. The ghost batch is the one that catches people out. In the ghost case the primary returned an error (or the ack timed out), so the client was told the batch failed, but the branch write already went through. If the client gives up, the ghost stays on the branch for good. If it retries, the primary ends up with one copy, deduplicating the retry if the first attempt had actually landed. The branch receives the retry as a fresh write from the router, so unless the router has done the extra work described below, the ghost becomes a duplicate the primary doesn’t have.</p>

<p>So in normal running the branch both loses data <em>and</em> duplicates it, independently of the primary. If that makes you uncomfortable, good — it should. Copy fidelity is why everyone wants Kafka; dual writes trade it away. That’s a legitimate trade-off for the right use case, but it needs to be a conscious one.</p>

<h3 id="backpressure-drop-or-block">Backpressure: drop or block?</h3>

<p>So if we aren’t holding back the client’s ack until the branch has acked, can we just ignore the branch? Not quite. The primary is healthy, staging is struggling, and unsent branch writes are piling up in the proxy. We can’t buffer forever: we’re a proxy, not an AI datacentre, and RAM is finite. Running out of it takes the mainline down with the branch. So we monitor the backlog, and when it grows we have two choices:</p>

<ul>
  <li><strong>Drop.</strong> Throw away branch writes until the branch catches up. The mainline is unaffected; the branch gets a hole. This is the right default for nearly every branching use case, and it’s what “best effort” actually means in practice. Note that if the branch is an idempotent producer, dropping a batch forces the router to discard that branch PID (or bump the producer epoch) and pay the re-init penalty before the next write can go through — many auxiliary branch pipelines intentionally use <code class="language-plaintext highlighter-rouge">enable.idempotence=false</code> or <code class="language-plaintext highlighter-rouge">acks=1</code> to allow lossy drops without stalling the sequence.</li>
  <li><strong>Block.</strong> Stop reading from the client until the branch drains. The branch stays more complete, but the mainline now slows to match it. You’ve coupled the two clusters and still don’t have a fidelity guarantee, so this is a hard trade to justify. If you have a use case that needs it, do get in touch and tell us about it.</li>
</ul>

<p>Whichever you choose, keep an eye on the queue. A branch that’s quietly falling behind looks just like a healthy one right up until someone needs it, so export queue depth and drop counts as metrics and you’ll see the trouble coming.</p>

<h3 id="partitions-dont-have-to-line-up">Partitions don’t have to line up</h3>

<p>The client picked a partition using the <em>primary</em> topic’s partition count, and the branch topic doesn’t have to agree. If it does, partition <em>n</em> simply maps to partition <em>n</em> and per-key ordering comes along for free. If it doesn’t, the router is now repartitioning: somebody has to decide where each record lands, and the branch’s ordering is only as good as that decision. Derived streams, like an audit feed keyed by user rather than by order, will usually end up here. That’s fine, as long as you meant it.</p>

<h3 id="multiple-connections-make-multiple-problems">Multiple connections make multiple problems</h3>

<p>Kafka producers use idempotent delivery by default. The broker deduplicates retried writes using a Producer ID (<code class="language-plaintext highlighter-rouge">PID</code>) assigned at initialisation plus a per-partition sequence number on every batch. Same PID, same sequence number — the batch was already committed, discard it quietly. The client never needs to know. Everything below assumes an idempotent client, which is the default. A non-idempotent client sends no sequence numbers at all. If you’ve turned that off, you already know what you’ve signed up for — branching doesn’t make it worse, but it can’t help either.</p>

<p><strong>Pass the client PID.</strong> The client negotiated its PID with the primary cluster; the router passes it through unchanged, exactly as in connection switching. Every write carrying the client’s identity goes to the cluster that issued it. Nothing to map, nothing to invent, nothing to lose. Not having to translate it is a large part of what separates branching from weaving — once one client identity has to be valid on several clusters simultaneously, the proxy is translating something far less forgiving than a node ID. That’s a problem we cover in more depth in weaving posts.</p>

<h4 id="the-router-is-its-own-producer-on-the-branch">The router is its own producer on the branch</h4>

<p>The branch cluster’s identity is something the router created. The client doesn’t know the branch cluster exists and nothing downstream will ever try to resume or share that identity. The router sends its own <code class="language-plaintext highlighter-rouge">InitProducerIdRequest</code> to the branch cluster and owns that identity start to finish. This is safe <em>because</em> the client can’t see it — an identity the client can’t see is one the client can’t collide with. It also means the client’s batches can’t simply be forwarded down the branch. The router has to build each branch batch itself, stamped with its own PID and epoch and a fresh checksum.</p>

<p>Order matters too. Anything that binds a batch’s body to its headers, such as encryption that authenticates the batch identity, has to be applied to the batch exactly as the broker will persist it. Change the headers afterwards and the binding no longer holds, probably in unrecoverable ways. The binding can happen at any node in the DAG, but once it has, nothing downstream may change the batch or the records in it. The runtime can’t readily police conflicting manipulations, so it’s up to whoever writes the configuration to get the order right.</p>

<p>To the branch cluster, the router is just another idempotent producer. For each PID and partition, the branch broker remembers the last few batches it accepted, discards any it has already seen, and rejects anything that isn’t the next one in line. It’s the same check the primary applies to the client.</p>

<h4 id="filters-that-change-the-batch-count-break-the-numbering">Filters that change the batch count break the numbering</h4>

<p>Supporting idempotent producers on a branch line is no different from supporting them anywhere else in the filter chain, though the problems are much more obvious here. A filter that adds or removes batches breaks the numbering, so it has to manage the sequence itself.</p>

<p>That’s hard on the mainline, where the client’s PID outlives the connection. Say the client sends 100 batches and a filter forwards a sample of 10, numbered 0 to 9. The network drops and the client reconnects with batch 101, sequence 100. The broker is expecting sequence 10, but a stateless filter has no idea it ever sent ten. Getting that right means keeping the sequence somewhere that survives the connection, a KV store say, and the runtime won’t do that for you.</p>

<p>The branch line has the same problem and a much cheaper way out. The PID is ours, and we’re best-effort publishers, so we can skip the external state: a new connection gets a new branch PID, the filter starts again from zero, and we accept a duplicate or a hole around a reconnect. If that isn’t good enough, the fix is the same as on the mainline, state kept outside the proxy.</p>

<p>Gaps matter in the other direction too. If the router uses a sequence number for a branch batch that is then dropped or fails for good, the next batch for that PID and partition no longer lines up, and the branch broker rejects it. A “hole” can really be a stall: everything after it on that PID is refused until the router starts again with a fresh PID.</p>

<h4 id="one-client-many-connections-many-branch-identities">One client, many connections, many branch identities</h4>

<p><strong>Branch PIDs are tied to a connection.</strong> The router’s branch PID lasts only as long as the client connection it was negotiated for. Unless something outside the proxy remembers it, it’s gone when the connection closes, and the next connection negotiates a fresh one. And the client has one PID but several connections: a producer opens one to each broker that leads a partition it writes to, and in a horizontally scaled proxy fleet those connections can land on different proxy instances. The routers serving those connections can’t coordinate with each other, so each one negotiates its own PID with the branch cluster. One client identity on the primary becomes several unrelated identities on the branch.</p>

<p>That’s harmless while each partition’s traffic stays on one connection. It stops being harmless when the traffic moves — and in Kafka, traffic moves routinely:</p>

<ul>
  <li><strong>Reconnects.</strong> A network blip, an idle timeout, a broker restart, a proxy rolling upgrade: anything that drops the client’s connection drops the branch identity with it. The client reconnects and resends its in-flight batches — some of which had already reached the branch under the old PID. They arrive under a new PID, and the branch accepts them all as fresh writes. Reconnecting to the same proxy instance doesn’t help, because the old connection’s state is already gone.</li>
  <li><strong>Leadership changes:</strong>
    <ol>
      <li>A partition’s leader moves from broker 1 to broker 2.</li>
      <li>The client retries its last in-flight batch to broker 2, using the same PID it used with broker 1.</li>
      <li>The connection to broker 2 has its own router, with its own branch PID.</li>
      <li>The mainline broker has already seen that batch from that PID, so it discards the duplicate.</li>
      <li>The branch broker has never seen this router’s PID, so it accepts the batch. It’s a duplicate, but nothing marks it as one.</li>
    </ol>
  </li>
</ul>

<p>Both are the same failure. The client’s retries for a partition move from one branch identity to another, and the branch can only deduplicate within a single identity. The mainline is unaffected — its PID belongs to the client, which holds it across every connection, every proxy instance, and every reconnect, so the primary recognises retries and discards the ones it has already committed.</p>

<p>You could fix this inside one process by letting the routers share a PID cache. But nobody<sup id="fnref:single-proc"><a href="#fn:single-proc" class="footnote" rel="footnote" role="doc-noteref">1</a></sup> runs a single proxy process in production, and across processes there’s nothing to share. For that you need an external state store.</p>

<p>The runtime is stateless, so none of this is fixed for you. A filter that wants to resume the same branch identity after any of these has to bring its own state store, and that’s on you. It fixes the duplicates but not the ghosts and MIA batches:</p>

<table>
  <thead>
    <tr>
      <th>What happens</th>
      <th>Stateless</th>
      <th>With a state store</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Ghost batch, then the client retries</td>
      <td>Duplicate on the branch</td>
      <td>The retry maps to the same branch sequence, so the branch discards it</td>
    </tr>
    <tr>
      <td>Client reconnects and resends in-flight batches</td>
      <td>Duplicates</td>
      <td>One copy</td>
    </tr>
    <tr>
      <td>Leadership change moves the partition to another connection</td>
      <td>Duplicates</td>
      <td>One copy</td>
    </tr>
    <tr>
      <td>Proxy restarts or rolls</td>
      <td>Duplicates</td>
      <td>One copy</td>
    </tr>
    <tr>
      <td>Ghost batch, and the client gives up</td>
      <td>The ghost stays</td>
      <td>The ghost stays</td>
    </tr>
    <tr>
      <td>MIA batch (dropped, or permanently failed)</td>
      <td>A hole</td>
      <td>A hole</td>
    </tr>
    <tr>
      <td>Router dies between the branch write and the state store update</td>
      <td>Not applicable</td>
      <td>Record first, then send: a hole. Send first, then record: a duplicate</td>
    </tr>
  </tbody>
</table>

<p>A state store takes the duplicates away and adds a dependency on the hot path, and it leaves the ghosts and MIA batches where they were. Without one, leadership changes, reconnects, and rolling upgrades are routine, so duplicates on the branch are a normal part of running stream branching, not an edge case you’ll rarely see.</p>

<p>One thing may help. <a href="https://cwiki.apache.org/confluence/spaces/KAFKA/pages/406624038/KIP-1313+Client+instance+ID+in+all+request+headers">KIP-1313</a> (accepted, not yet released) puts a client instance ID in every request header, which gives a router a stable identifier to key its state on across connections and proxy instances. It’s an identifier, not a branch PID, so the router still has to manage the branch PID itself.</p>

<p>Use shadow data for observability, not for accounting. If someone needs to reconcile the branch against the primary to the last record, the answer is replication, not branching.</p>

<h3 id="transactions-dont-branch">Transactions don’t branch</h3>

<p>A transaction belongs to one cluster. The coordinator, the transaction log and the commit and abort markers all live there, so a branch on another cluster has nothing to take part in.</p>

<p>The router can see that a batch is transactional, because it’s marked as such. What it can’t see from the produce stream is the transaction’s state: whether it’s open, which one it is, and how it ends. That lives with the coordinator, and the commit and abort markers are written by the broker, not sent by the client. The router can copy the records but not the verdict.</p>

<p>That leaves two bad options for a transactional branch:</p>

<ul>
  <li><strong>Strip the transactional flag</strong> and write the branch batches as plain idempotent writes. This throws away the semantics consumers rely on. There’s no commit or abort to say where a transaction ends, so records from transactions the primary later aborts are visible on the branch immediately. A <code class="language-plaintext highlighter-rouge">read_committed</code> consumer there reads data that, as far as the primary is concerned, never happened.</li>
  <li><strong>Run a shadow transaction</strong> on the branch: the router starts its own transaction against the branch cluster’s coordinator and tries to follow the primary’s. It can’t be faithful. The branch transaction is a separate transaction with its own producer ID, epoch and timeout, so it can commit or abort independently of the primary’s. What a <code class="language-plaintext highlighter-rouge">read_committed</code> consumer sees on the branch needn’t match what it would see on the primary. Post 1 said it bluntly and it still holds: the Kafka protocol has no cross-cluster transaction coordinator, and routing can’t invent one.</li>
</ul>

<p>Cloning a transaction doesn’t work, but that doesn’t make branching during transactions pointless. The branch sees everything, committed or not. If whatever reads the branch can live with that, it’s fine. If it can’t, routing isn’t the solution you’re looking for: you need replication.</p>

<h2 id="know-when-to-get-off-the-train">Know when to get off the train</h2>

<p>Staging shadows and derived telemetry are the sweet spot: stateless, auxiliary, where the odd gap or duplicate is a curiosity rather than a crisis. If you need the derived stream to be stateful — joins, windows, sessionisation — Kafka Streams or a Connect pipeline will serve you better; they were built to manage state across restarts and rebalances, a proxy wasn’t. If you need a complete, ordered, offset-consistent copy on another cluster, use replication: MirrorMaker 2, KIP-1279, or your vendor’s equivalent reads the committed log after the fact and doesn’t have the asymmetric failure modes above. If you need writes across clusters to be atomic, the answer is the same — no amount of clever routing changes what the protocol can and can’t coordinate.</p>

<p>The distinction between mainline and branch isn’t incidental, it’s the whole contract. Keep it legible and stream branching is a cheap way to build streams nobody had to produce. Let it blur and you’ve scheduled a conversation nobody will enjoy.</p>

<hr />

<p>Both flow patterns are now covered. Connection switching picks the track. Stream branching adds branch lines. Next we leave the railway for the sorting office: <strong>topic weaving</strong>, where the router no longer just directs streams but decides which topics exist, where they live, and what they’re called. Producer identity comes up again there, and this time the client <em>does</em> know about every cluster involved.</p>

<p>If you’re branching streams already, or want to and have hit a gap this post didn’t cover, find us on <a href="https://github.com/kroxylicious/kroxylicious">GitHub</a>, <a href="https://kroxylicious.slack.com">Slack</a>, or <a href="https://bsky.app/profile/kroxylicious.io">Bluesky</a>.</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:single-proc">
      <p>Except on localhost during a Friday demo. <a href="#fnref:single-proc" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Sam Barker</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="routing" /><summary type="html"><![CDATA[Post 1 introduced the Routing API: instead of a fixed pipe from client to cluster, the proxy interprets the Kafka protocol and can route traffic wherever you need it to go. Post 2 covered connection switching — the simplest use of that capability, where the proxy picks which cluster a client connects to at connection time, and can switch it without the client noticing.]]></summary></entry><entry><title type="html">Kroxylicious release 0.25.1</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/20/release-0_25_1.html" rel="alternate" type="text/html" title="Kroxylicious release 0.25.1" /><published>2026-10-20T11:00:00+00:00</published><updated>2026-10-20T11:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/20/release-0_25_1</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/20/release-0_25_1.html"><![CDATA[<p>Kroxylicious 0.25.1 has been released with critical security fixes.</p>

<p>This is a security-focused patch release addressing one vulnerability in Kroxylicious and multiple vulnerabilities in Netty.</p>

<hr />

<h3 id="security-advisories">Security Advisories</h3>

<h4 id="cve-2026-105941-ssrf-in-azure-key-vault-kms-provider">CVE-2026-105941: SSRF in Azure Key Vault KMS Provider</h4>

<p><strong>Affected:</strong> Kroxylicious when using the Record Encryption filter configured with the Azure Key Vault KMS provider.</p>

<p><strong>Not affected:</strong> If you are not using the Record Encryption filter, or if you are using Record Encryption with a different KMS provider (AWS KMS, HashiCorp Vault, Thales CipherTrust Manager, etc.), you are not affected by this vulnerability.</p>

<p><strong>Description:</strong> The Azure Key Vault KMS provider deserializes the <code class="language-plaintext highlighter-rouge">vaultName</code> field from Encrypted Data Encryption Keys (EDEKs) embedded in Kafka records without proper validation, creating a Server-Side Request Forgery (SSRF) vulnerability.</p>

<p>A malicious actor with write access to a Kafka topic can craft a record containing a specially constructed EDEK that causes the proxy to direct Key Vault HTTP requests—including Azure bearer token Authorization headers—to an attacker-controlled server. An attacker in possession of a stolen bearer token can then use it directly against the real Azure Key Vault to decrypt any EDEK, enabling full decryption of Kafka records protected by the Record Encryption filter.</p>

<p>The root cause is a trust boundary confusion: the proxy’s configuration strictly validates vault names at startup, but the vault name embedded in EDEKs is validated only with an <code class="language-plaintext highlighter-rouge">isBlank()</code> check, allowing special characters like <code class="language-plaintext highlighter-rouge">.</code>, <code class="language-plaintext highlighter-rouge">/</code>, and <code class="language-plaintext highlighter-rouge">#</code> that bypass the URL parsing and redirect requests to attacker-controlled hosts.</p>

<p><strong>Fix:</strong> The Azure Key Vault KMS provider now validates the <code class="language-plaintext highlighter-rouge">vaultName</code> field in EDEKs using the same strict pattern applied to the configured vault name, preventing maliciously crafted vault names from being used.</p>

<p><strong>Advisory:</strong> <a href="https://github.com/kroxylicious/kroxylicious/security/advisories/GHSA-5j25-p663-ww5r">GHSA-5j25-p663-ww5r</a></p>

<hr />

<h3 id="netty-security-updates">Netty Security Updates</h3>

<p>Kroxylicious 0.25.1 upgrades Netty from 4.2.18.Final to <strong>4.2.19.Final</strong>, which addresses 16 security vulnerabilities.
Details of all fixed vulnerabilities are available in the <a href="https://github.com/netty/netty/releases/tag/netty-4.2.19.Final">Netty 4.2.19.Final release notes</a>.</p>

<hr />

<h3 id="download">Download</h3>

<p>Download binary distributions and container images from the <a href="https://kroxylicious.io/download/0.25.1/">download</a> page.</p>

<h3 id="feedback">Feedback</h3>

<p>Drop by and say hello on <a href="https://kroxylicious.slack.com">Slack</a>, <a href="https://github.com/kroxylicious/kroxylicious/issues">GitHub</a>, or <a href="https://bsky.app/profile/kroxylicious.io">bsky</a>. You can also join us in person at a <a href="/join-us/community-call/">community call</a>.</p>]]></content><author><name>Keith Wall</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="releases" /><category term="releases" /><category term="kroxylicious-proxy" /><summary type="html"><![CDATA[Kroxylicious 0.25.1 has been released with critical security fixes.]]></summary></entry><entry><title type="html">Connection Switching: Identity without commitment</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html" rel="alternate" type="text/html" title="Connection Switching: Identity without commitment" /><published>2026-10-19T03:00:00+00:00</published><updated>2026-10-19T03:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html"><![CDATA[<p><a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> introduced the Routing API and the fundamental shift it brings: a Virtual Kafka Cluster (VKC) is no longer a fixed pipe wired to a single physical cluster on boot. It’s a stable identity. What actually lives behind it is now the proxy’s problem, not the client’s.</p>

<p>We called the first pattern <strong>Connection Switching</strong>.</p>

<p>Connection switching makes the smallest possible change to Kafka protocol semantics. A connection to a VKC is still a connection to exactly one physical cluster — no fan-out, no merging, no weaving. The broker on the other end behaves like any Kafka broker, because it is one. What the proxy adds is a single degree of freedom: <em>which</em> cluster. Think of it in DNS terms: we transform a hardwired A record into a CNAME. The client has a stable name; where the traffic actually lands is entirely up to the proxy.</p>

<p>Post 1 framed it as throwing the lever before the train departs: the routing decision is made once at connection time, and after that it’s a straight run to the destination. That’s still the right picture. This post is about what you, as stationmaster, have to do so that the trains switch tracks cleanly — and why some passengers will notice the scenery changed.</p>

<h2 id="what-you-can-do-with-it-and-the-dream-it-sets-up">What you can do with it (and the dream it sets up)</h2>

<h3 id="the-single-front-door-tenant--workload-dispatch">The single front door: Tenant &amp; workload dispatch</h3>

<p>Workload contention is one of Kafka’s classic growing pains. It starts quietly: a few teams sharing a cluster, everything fine. Then the analytics team kicks off their end-of-month backfill and the latency-sensitive payment service starts missing SLOs. The broker’s I/O is not infinite, and the batch job’s freight train doesn’t yield to the passenger express.</p>

<p>The obvious fix — separate clusters for separate workload tiers — runs straight into the coordination problem. Spinning up dedicated hardware is the easy part. Migrating the workloads means issuing new bootstrap addresses, which means finding every application team, convincing them this is their problem too, waiting for their next deployment window, and hoping nobody hardcoded the old address somewhere. Do it for twenty teams and you’ve bought yourself a multi-week project, a spreadsheet of who’s done and who isn’t, and at least one Friday evening incident when the team who said they were done turned out not to be.</p>

<p>With connection switching, you skip all of that. Everyone bootstraps at <code class="language-plaintext highlighter-rouge">kafka.corp.internal:9092</code>. When a client connects, the router inspects the authentication context — who is knocking on the door? — and dispatches to the right cluster behind the scenes:</p>

<ul>
  <li>High-throughput production services get routed to dedicated, high-IOPS NVMe brokers.</li>
  <li>Heavy batch analytics jobs get dispatched to the spinning rust cluster.</li>
  <li>General application traffic stays on the shared tier.</li>
</ul>

<p>To be clear: this only affects trains being dispatched going forward. Any freight already at the old yard still needs to be cleared — by hook or by crook. Consume it directly from the old backing cluster, replicate it across with MirrorMaker, or accept that some historical data lives in a different place for a while. Connection switching solves the coordination nightmare going forward. The historical tail is still yours to manage.</p>

<h3 id="kafka-doesnt-do-cnames">Kafka doesn’t do CNAMEs</h3>

<p>Swapping a CNAME is how the rest of the world handles this. Update the record, wait for the TTL to expire, done — clients follow along without noticing.<sup id="fnref:1"><a href="#fn:1" class="footnote" rel="footnote" role="doc-noteref">1</a></sup></p>

<p>Kafka can’t do that. Kafka connections are persistent and long-lived. Flipping a DNS record does nothing to existing TCP connections; clients will happily keep talking to the old brokers until something drops their socket. Even after the DNS TTL expires and the new record propagates, existing clients don’t disconnect. Instead, they only trickle over to the new cluster as individual applications happen to restart, redeploy, or hit network blips over the following hours or days.</p>

<p>Swapping a CNAME gives you the illusion of a clean cutover, but in the words of Admiral Ackbar: <em>“It’s a trap.”</em> You haven’t executed a cutover; you’ve stumbled into an unplanned active-active deployment. Some portion of your producers and consumers are still writing to Cluster A while the rest commit to Cluster B, leaving your data consistency and offset state caught in the middle.</p>

<p>Connection switching gives you the clean cutover DNS promises, but with the coordination Kafka actually needs. The bootstrap and broker endpoints remain stable. When you flip the route target, the proxy severs existing downstream connections in a single, coordinated cut. Every client hits its built-in reconnect loop at the same time, re-establishes connections to the stable proxy endpoints, receives the metadata map for the new cluster, and carries on—moving all traffic from Cluster A to Cluster B without spending hours trapped in an unintended active-active limbo.</p>

<p>Let’s be realistic: getting clients to point at a new cluster isn’t the hardest part of a migration or DR scenario. Data consistency is what keeps Kafka operators awake at night — topic replication, offset mapping, replication lag, and consumer state. Connection switching doesn’t solve any of that (that’s still on you and your replication tooling). But what it <em>does</em> do is take client endpoint coordination off the critical path. You don’t have to chase twenty application teams into a midnight maintenance window just to change their configs.</p>

<p>When executing a planned migration or a DR failover:</p>

<ul>
  <li><strong>The data plane is handled out-of-band:</strong> Topics and offsets are synced beforehand via active replication (MirrorMaker 2, <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-1279%3A+Cluster+Mirroring">KIP-1279</a> cluster mirroring, or your vendor’s equivalent), or recovered from storage volume snapshots.</li>
  <li><strong>The connection cutover is a control-plane flip:</strong> The proxy updates its route target to the secondary cluster and closes existing downstream connections. Clients reconnect to the stable bootstrap address, issue a fresh <code class="language-plaintext highlighter-rouge">MetadataRequest</code> against the new target, and resume. The Kafka client’s standard reconnect loop is the recovery mechanism; no application-level coordination is required.</li>
  <li><strong>Rollback is fast:</strong> If the secondary cluster misbehaves under live load, you can revert the routing target in seconds — with a few bonus state management headaches.</li>
</ul>

<p>Whether you’re doing a planned blue/green transition or invoking DR in an emergency, connection switching means the cutover itself doesn’t involve herding cats.</p>

<h2 id="how-the-proxy-makes-it-work">How the proxy makes it work</h2>

<p><a href="/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html">Post 1</a> established that Kafka clients care intensely about broker identity: <em>Broker 1 is Broker 1</em>. When a client bootstraps, it asks for a cluster map and manages direct connections to each broker at the address advertised for its <code class="language-plaintext highlighter-rouge">NodeId</code>.</p>

<p>If you’ve ever used a modern public transit map or navigated an airport terminal, you know that nobody navigates by real geography. Harry Beck’s famous 1931 London Underground map—the inspiration for virtually every subway schematic and transit diagram that followed—worked because travelers don’t care about winding tunnels or true physical distances. They only care about topology: which station connects to which, and where you change trains.</p>

<p>Kafka clients operate on the exact same premise. They have no concept of physical infrastructure; their entire mental model of the world is the schematic map handed to them in a <code class="language-plaintext highlighter-rouge">MetadataResponse</code>. As long as that map is internally consistent, they’re happy.</p>

<p>To swap the physical reality behind that schematic without breaking client expectations, the proxy runtime has to solve two concrete problems:</p>

<ol>
  <li><strong>Drafting the map on the fly:</strong> The proxy needs to know which upstream brokers exist. Rather than surveying the network ourselves and hardcoding it into configuration — I work hard at being lazy — we just look at the map the client is already requesting and learn it in-band.</li>
  <li><strong>The Platform 2 problem:</strong> Tell someone to board “the train on Platform 2” at King’s Cross without qualification, and one person is on the mainline concourse waiting for the Edinburgh express while the other is three escalators down on the Piccadilly Line. If Cluster A and Cluster B both contain a “broker 2” (and they almost certainly will), we must deterministically translate node IDs so the client never boards the wrong train.</li>
</ol>

<p>Here’s what’s actually happening under the hood.</p>

<h3 id="topology-discovery-happens-in-band">Topology discovery happens in-band</h3>

<p>What’s the point of being a Layer 7 protocol proxy if you don’t take advantage of the protocol? Kafka already advertises the broker layout as part of every <code class="language-plaintext highlighter-rouge">MetadataResponse</code>—so the proxy simply listens in.</p>

<p>Doing discovery in-band means we don’t need background polling loops, synthetic health checks, or separate privileged admin credentials to keep an out-of-band cluster map warm. When a route’s topology is unknown, discovery inherits the client’s authenticated connection, and the proxy harvests the broker layout from the traffic that flows through.</p>

<p>Topology state is cached per-router and shared across all connections using that router — so a second connection to the same virtual cluster benefits from what the first one already discovered. The cache is append-only: entries are added as they’re learned, never removed. That matters for safety more than it might seem. A low-privilege connection might get a filtered <code class="language-plaintext highlighter-rouge">MetadataResponse</code> covering only the topics it can see; an append-only cache means it can only <em>contribute</em> knowledge, never silently evict entries that a higher-privilege connection established. And before the security researchers start slinging CVEs — the cache isn’t allowed anywhere near an authorisation decision. Brokers enforce ACLs on every request regardless; a misdirected frame gets an error, not someone else’s data.</p>

<p>When a client connects with a request and the proxy doesn’t yet know the topology — on first connection — it discovers it on demand. This is why you don’t need to specify all the upstream brokers in config. The proxy synthesises a <code class="language-plaintext highlighter-rouge">MetadataRequest</code> and sends it upstream over the client’s authenticated connection, uses the response to populate its topology cache, and then forwards whatever the client sent as normal.</p>

<p>This is all proven technology from the pre-routing world, but routing throws us a curve ball.</p>

<h3 id="when-is-2--2">When is 2 != 2?</h3>

<p>When broker 2 on cluster A and broker 2 on cluster B are both hidden behind the same router. Welcome to the Platform 2 problem: telling someone to board “the train on Platform 2” is ambiguous when both the mainline railway and the deep Underground line share the same front doors. Without translation, two completely different destinations collide under the same number.</p>

<p>A single connection only ever references a single cluster at a time. However many clusters are behind the proxy, the IDs in the <code class="language-plaintext highlighter-rouge">MetadataResponse</code> must paint a single coherent picture. We can’t give the client an identity crisis by presenting N different addresses for node 2. The ID space the client sees must be stable: if NodeId 4 meant cluster A’s broker 2 before the cutover, it can’t silently start meaning cluster B’s broker 2 after it.</p>

<p>The proxy has always rewritten broker addresses in <code class="language-plaintext highlighter-rouge">MetadataResponse</code> frames — that’s how clients end up talking to the proxy rather than the real brokers. Routing adds a wrinkle: we’re no longer dealing with a single upstream ID space. There’s one downstream space facing the client, and a separate upstream space per physical cluster behind the proxy.</p>

<p>In the pre-routing world that was a trivial identity mapping (not that we identified it as such): Broker 2 upstream was Broker 2 downstream; only the advertised socket address changed.</p>

<p>Routing breaks that simplicity by introducing <strong>multiple upstream ID pools</strong>. That would be trivial if those pools were provably disjoint — if Cluster A only ever used IDs <code class="language-plaintext highlighter-rouge">0..99</code> and Cluster B used <code class="language-plaintext highlighter-rouge">100..199</code>. But in the real world, almost every Kafka cluster starts numbering its brokers from 0 or 1.</p>

<p>To keep the runtime’s shared topology cache unambiguous and to prevent collisions across a cutover, we have to collapse multiple upstream ID pools into a single downstream space:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>                                                    ◄──(cluster A IDs)──► [ broker1.cluster-a, broker2.cluster-a, ... ]
[ Client ] ◄──(downstream IDs)──► [ Router ]
                                                    ◄──(cluster B IDs)──► [ broker1.cluster-b, broker2.cluster-b, ... ]
</code></pre></div></div>

<p>The proxy solves this with a stateless and deterministic mapping function applied at each step in the routing DAG — technically speaking, a bijection. No database lookup, no distributed coordinator — just integer arithmetic:</p>

<p><code class="language-plaintext highlighter-rouge">downstreamId = (upstreamId * numRoutes) + routeIndex</code></p>

<p>If Cluster A is route index 0 and Cluster B is route index 1 across two routes:</p>
<ul>
  <li>Broker 2 on Cluster A becomes virtual Node ID <code class="language-plaintext highlighter-rouge">(2 * 2) + 0</code> = <strong>4</strong></li>
  <li>Broker 2 on Cluster B becomes virtual Node ID <code class="language-plaintext highlighter-rouge">(2 * 2) + 1</code> = <strong>5</strong></li>
</ul>

<p>Requests flowing upstream have their node IDs translated from downstream to upstream; responses flowing downstream have them translated back. The mapping is strictly one-to-one in both directions, so every downstream ID resolves to exactly one physical broker and route with zero ambiguity.</p>

<p>Two things follow from this that are specific to connection switching and worth saying plainly.</p>

<p><strong>Routers must present coherent clusters.</strong> For a router to be a “connection switch” it has to present a single coherent cluster as if the client was connected directly to the backing cluster. Even if it is maintaining an active connection to the hot spare for liveness purposes, it has to ensure the cluster the client sees only contains nodes from the active one. If the backing cluster has 3 nodes, so must the client-facing one. The runtime ensures a complete ID space across all configured routes. What the router puts in the <code class="language-plaintext highlighter-rouge">MetadataResponse</code> is its business — for connection switching, that’s one cluster, full stop. As a rule of thumb: if you find yourself wanting to merge <code class="language-plaintext highlighter-rouge">MetadataResponse</code>s, you’re not doing connection switching any more.</p>

<p><strong>The ID space is virtual.</strong> That’s not a bug, it’s intentional — and worth knowing. A client is talking to nodes mapped in the downstream address space. This means that a client thinks it’s talking to node 4, but the proxy is translating that to node 2 once it’s been through the router. In normal operation you’ll never notice. It only becomes salient when you are trying to map logs between clients and brokers, because each end of the exchange has a different view of identity.</p>

<p>Unlike most of the routing API — which gives you the mechanism and expects you to supply the logic — this is one the runtime just handles. The mapping just happens at every route boundary whether your router thought about it or not. Routers work entirely in virtual ID space; the mapping isn’t even exposed to them.</p>

<p>Because the mapping is purely local to each router, routers compose cleanly without coordinating with each other. A router doesn’t need to know what the rest of the graph looks like or whether an upstream target is a physical cluster or another router in the DAG. The runtime handles the integer translation transparently on the wire, leaving custom routers to work with clean <code class="language-plaintext highlighter-rouge">VirtualNode</code> handles and focus solely on routing decisions.</p>

<p>There is one constraint baked into the formula: <code class="language-plaintext highlighter-rouge">numRoutes</code> must be stable for the mapping to be stable. Add or remove routes and the multiplier changes, which reassigns every virtual NodeId — so that’s a coordinated reconnect event for all clients on that VKC. In practice that’s fine: route topology changes on a different timescale to targets. A new tenant is added or leaves at the glacial pace of humans making decisions; targets flip in an incident at 2am. Stable for what changes slowly, flexible for what changes fast.</p>

<h2 id="proxies-arent-magic">Proxies aren’t magic</h2>

<p>Layer 7 protocol inspection gives you a lot of leverage. What it doesn’t give you is the ability to reach inside a Kafka broker and move its internal state somewhere else. The proxy can route frames to a different cluster. It cannot conjure the state those frames depend on. The points switch cleanly, but the tickets still say the 3:15 to Mos Eisley, carriage 13, seat 342323 (in Kafka terms, <code class="language-plaintext highlighter-rouge">topic-A.partition-13</code> at offset 342323). The new station has never run that service, and has no record of anyone booking a seat on it. That’s how the passengers find out the scenery changed.</p>

<h3 id="when-you-flip-the-target-the-state-doesnt-follow">When you flip the target, the state doesn’t follow</h3>

<p>If the routing target changes while a client is active:</p>

<ul>
  <li>
    <p><strong>Transactional producers:</strong> Transactions are scoped to a single cluster, because the Transaction Coordinator is a role inside it. There’s no extension point for an external one, so there’s nothing for the proxy to stitch a transaction across two clusters with, however closely they resemble each other. The second cluster’s coordinator knows nothing about a transaction the first one opened. If a cutover lands mid-transaction, the subsequent <code class="language-plaintext highlighter-rouge">EndTxnRequest</code> arrives at the new target and gets back <code class="language-plaintext highlighter-rouge">INVALID_TXN_STATE</code> or <code class="language-plaintext highlighter-rouge">UNKNOWN_PRODUCER_ID</code>. The producer has to abort and restart its transactional loop — the same recovery it needs after a fenced epoch or an expired transaction, which well-written transactional producers already handle.</p>

    <p>A proxy restart on its own is harmless. PIDs and transaction state are scoped to the cluster, not to a broker, so as long as the producer lands back on the same cluster, the KIP-360 fencing fields it sends on reconnect are the broker’s own real values. Change the cluster and that stops being true: the PID the client holds is meaningless to the new one. Not fenced, simply unknown. The producer reconnects as a stranger.</p>
  </li>
  <li>
    <p><strong>Consumer groups:</strong> Offset state lives in <code class="language-plaintext highlighter-rouge">__consumer_offsets</code> on the physical cluster. The secondary cluster’s Group Coordinator has no idea what the primary’s consumers have committed. Fail over without a replication pipeline that carries offsets and consumers either re-read data they’ve already processed, or skip ahead and lose it, depending on <code class="language-plaintext highlighter-rouge">auto.offset.reset</code>. Either way, nothing throws an exception to let you know.</p>
  </li>
  <li>
    <p><strong>Idempotent producers:</strong> Deduplication is the partition’s memory of who sent what. The leader remembers the recent sequence numbers it has accepted from each producer (PID and epoch), which is how it spots a retried batch and quietly bins it. That memory belongs to the cluster that handed out the PID, so when the route changes it stays behind. The new cluster has never heard of the client’s PID. At best the producer is told to start over; at worst a batch that was in flight across the cutover (already committed on the old cluster) is accepted a second time, because nothing on the new cluster can tell it’s a retry. The proxy has no way to inject that state.</p>

    <p>Idempotence holds within each cluster, but not across the switch: a cutover is a boundary the guarantee doesn’t cross. If you depend on it, treat the cutover as a known risk and either quiesce producers first or make sure downstream consumers can tolerate the odd duplicate. If that isn’t good enough, extreme measures exist: a filter could track what it has forwarded and reject re-submitted batches itself. That behaviour is specific to your deployment and would need a custom filter. You know your business better than we do, but it’s not one we’d expect to ship as a project.</p>
  </li>
</ul>

<h3 id="cutovers-are-an-explicit-decision-not-a-proxy-heuristic">Cutovers are an explicit decision, not a proxy heuristic</h3>

<p>Every cutover has the consequences above, and the proxy can’t repair any of them. That’s why automated failover <em>inside the proxy</em> is a deliberate non-goal.</p>

<p>A brief network hiccup and a genuine primary failure look identical from inside the proxy. Getting that call wrong — dropping in-flight transactions, replaying messages, committing offsets against the wrong cluster — is a cost the proxy has no way to absorb or undo. That judgement belongs to a human operator, or an orchestration playbook that can actually assess cluster health and replication lag.</p>

<p>Kroxylicious gives you the lever, and it can be thrown without restarting anything. Whether to throw it is the stationmaster’s call, and the stationmaster is you, ideally armed with something better than a hunch and a pager.</p>

<h3 id="offset-continuity-requires-out-of-band-replication">Offset continuity requires out-of-band replication</h3>

<p>The proxy routes frames; it doesn’t replicate log data. If consumers need to pick up where they left off on the secondary cluster, their committed offsets have to mean something there. That means a replication pipeline (<a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-1279%3A+Cluster+Mirroring">KIP-1279</a>, MirrorMaker 2, or equivalent) that is in place and caught up <em>before</em> you throw the lever, not after. If your pipeline translates offsets rather than preserving them, as MirrorMaker 2 does, applying that translation to your consumer groups is part of the cutover too. The proxy won’t do it for you. Throwing the lever is not a substitute for having done that work.</p>

<h3 id="layer-7-can-only-do-so-much">Layer 7 can only do so much</h3>

<p>Every failure mode above shares the same root: the proxy routed a frame to a new cluster, and something on that cluster had no memory of the client. That isn’t a proxy bug. It’s the definition of where connection switching ends. Post 1 framed the four patterns around a single axis: how deep into the Kafka protocol the router has to reach. Connection switching is the shallow end — it makes one decision, which way to throw the points, and then steps back. The journey that follows belongs to the broker.</p>

<p>The patterns deeper on that axis take on more of that journey. Partition weaving, for example, intercepts <code class="language-plaintext highlighter-rouge">OffsetCommit</code> and <code class="language-plaintext highlighter-rouge">OffsetFetch</code> and rewrites partition numbers so that a consumer group can span clusters. That’s a different contract: not a harder version of connection switching, but a different pattern, because the axis moved. Some limits move with it. Others, like transactions, don’t, because they belong to the protocol rather than the proxy.</p>

<h2 id="egress-ingress-or-does-it-matter">Egress, ingress, or does it matter?</h2>

<p>Post 1 promised we’d call out where each pattern lands on the egress/ingress axis. From a protocol standpoint connection switching is neutral — the mechanics work either side of the wire. In practice, your use case has a strong opinion about placement.</p>

<p>When talking about DR failover it’s obvious once you say it out loud. If the proxy lives in the broker domain — in front of the brokers, a reverse proxy — and the primary site goes down, so does the proxy. Your switch just went boom along with the primary site… a great disturbance in the Force, as if millions of consumers suddenly cried out in terror and were silenced. The secondary site’s ingress proxy was never in the traffic path to begin with; you can’t flip a routing target on a proxy your clients weren’t talking to. You’d still need to redirect clients to a different address, which is exactly the coordination problem connection switching was supposed to eliminate.</p>

<p>Thus for DR, the proxy needs to sit on the client side of the link as an egress deployment. The proxy isn’t collocated with what failed. It’s still in the traffic path. You can flip the routing target, and clients notice nothing beyond a reconnect.</p>

<p>Connection switching also sits quite happily on the ingress side of the fence. If your goal is workload dispatch — giving every team in the organisation a single <code class="language-plaintext highlighter-rouge">kafka.corp.internal:9092</code> and routing their connections to the right backing tier behind the scenes — the proxy sits in front of the brokers. The platform team controls that domain, and the stable endpoint is theirs to publish. You <em>could</em> run workload dispatch egress-side, but now you’re managing a fleet of client-side proxies, one per team or workload, and keeping them all pointed at the same routing config. That’s a lot of instances to babysit for a problem the platform team already owns.</p>

<p>So what happens when you want to combine both — cross-site DR failover with platform-side workload dispatch? You chain them together with a proxy at each end of the network link: egress on the client side, ingress on the broker side. The client-side egress proxy handles site-level DR, flipping between primary and secondary regions. The ingress proxy inside each region handles workload dispatch. What makes this work cleanly is that each proxy is completely indifferent to what sits behind it: it dials what it’s told, speaks Kafka, and has no idea whether the thing on the other end is a broker or another Kroxylicious instance. There’s no shared state between them, no coordination protocol, no handshake. That’s the pay-off from being a native layer 7 proxy.</p>

<p>Connection switching keeps the operational promise simple: platform teams can change the physical backend without the application teams having to do anything. The state work above is still yours, but it’s work you can do on your own schedule instead of everyone else’s. That’s not a small thing.</p>

<p>The next post moves from one-to-one connection switching to fanning out traffic and assembling secondary streams on the fly: <a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html"><strong>Stream Branching: Mind the gap</strong></a>.</p>

<hr />
<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:1">
      <p>There is always some bit of infra that fails to honour the TTL properly or doesn’t understand a CNAME or PTR record. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Sam Barker</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="routing" /><summary type="html"><![CDATA[Post 1 introduced the Routing API and the fundamental shift it brings: a Virtual Kafka Cluster (VKC) is no longer a fixed pipe wired to a single physical cluster on boot. It’s a stable identity. What actually lives behind it is now the proxy’s problem, not the client’s.]]></summary></entry><entry><title type="html">These are not the brokers you are connecting to</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html" rel="alternate" type="text/html" title="These are not the brokers you are connecting to" /><published>2026-10-12T03:00:00+00:00</published><updated>2026-10-12T03:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/2026/10/12/these-are-not-the-brokers-you-are-connecting-to.html"><![CDATA[<p>Back in May, Tom wrote about <a href="/blog/kroxylicious-proxy/2026/05/21/topic-routing.html">a proof of concept for routing</a> — Kafka clients producing and consuming from topics scattered across multiple clusters, with no idea that’s what they’re doing. The proxy handles the fan-out, the response merging, the session state. The client just sees topics.</p>

<p>That POC has been quietly maturing. We’re now in the process of turning it into something you can actually run in production, and in a few weeks we’ll be talking about it at <a href="https://current.confluent.io/san-francisco/sessions#session-SESS-165">Current in San Francisco</a>. In a session called <em>“These are not the brokers you are connecting to”</em> — my employer does not condone lying, but the proxy will quite happily tell your clients whatever you need it to.</p>

<p>This post is the first in a short series leading up to that talk. The goal here is to establish some vocabulary and get into the gory details I won’t have time for onstage. I’ve been thinking about the design space routing enables and I’m convinced there are a handful of distinct patterns worth naming separately. There are no hard boundaries between the patterns, they all leverage the same underlying infrastructure, but they are distinct because they trade off different aspects of the problem space. The names are mine and while I’ll happily accept better ones, we need something to start a conversation (plus I’m right 😉).</p>

<p>The deeper dives on each pattern will follow in subsequent posts.</p>

<h2 id="pick-your-poison">Pick your poison</h2>

<p>If you’ve tried to migrate a live Kafka workload between clusters, consolidate regional deployments, or shift cloud providers, you will have run into the same core problem: Kafka is not HTTP-based (stop rolling your eyes at the back). Kafka clients are genuinely indifferent to geography — they’ll talk to a broker in the same pod just as happily as one in Timbuktu. What they care about, deeply and lastingly, is <em>which</em> broker they’re talking to. Broker 1 is Broker 1. You can’t quietly swap it out, move it between availability zones, or retire it without a lot of fuss. The load balancer doesn’t get a say. Most proxies can only manage Kafka as a layer 4 protocol — and layer 4 is BOOOOORRRRING (I will not listen to arguments from the network engineer in the corner).</p>

<p>So when you need to reshape the underlying infrastructure without breaking application teams, you usually end up picking which operational headache you dislike the least.</p>

<p><strong>Application-level dual writes</strong> look clean in architecture diagrams. In production, network blips cause asymmetric failures, message ordering drifts, and duplicate delivery becomes every application team’s problem. Getting twenty teams to deploy matching code changes on the same timeline is an exercise in cat-herding that usually ends with someone’s Friday afternoon becoming someone else’s out of hours page.</p>

<p><strong>Replication pipelines</strong> (MirrorMaker 2, et al.) work great for asynchronous backup, but for live consolidation knowing whether you’re in sync is a very difficult question, not to mention doubling storage and network costs, and asking consumers to deal with offset translation. You’re running twice as much hardware to move bytes you already owned, fine if the migration ever actually ends.</p>

<p><strong>Maintenance windows</strong> are conceptually simple right up until a legacy service ignores DNS TTLs, holds onto stale sockets, and drops messages silently when the old brokers finally go dark. Sunday 2am is when the core reporting pipeline splutters to a halt.</p>

<h2 id="what-a-layer-7-proxy-buys-you">What a Layer 7 proxy buys you</h2>

<p>Jumping up to Layer 7 changes the game. Rather than blindly punting TCP bytes around, the proxy speaks Kafka. It knows a <code class="language-plaintext highlighter-rouge">Metadata</code> response from a <code class="language-plaintext highlighter-rouge">Produce</code> request, and it can answer a client’s question about where the brokers live with whatever answer you need.</p>

<p>From day one, Kroxylicious gave you a Virtual Kafka Cluster (VKC) — a stable endpoint for your clients. But until recently, it was an opinionated pipe. That was a compliment: it did real work. It could encrypt records, enforce auth, rewrite headers — all without the client noticing. But it was still a fixed pipe: one client socket in, one backend socket out, wired to a broker on whatever cluster you pointed it at on boot. The filters were stateless with respect to the broker topology: an encryption filter might talk out-of-band to a KMS for keys, but it didn’t care which physical cluster lived behind the socket.</p>

<p>Think of it like the horse in the late 19th century. A horse gets you from A to B across familiar ground without needing a national highway project. You feed it, you mount it, and you go. Horses were great.</p>

<p><a href="https://github.com/kroxylicious/design/blob/main/proposals/070-routing-api.md">Proposal 70</a>, the Routing API, is our combustion engine. The filters haven’t gone anywhere — encryption, auth enforcement, and header rewriting all ride along inside the car. But the platform underneath can now make routing decisions on the fly. As a project, we provide the API so <em>any</em> car is possible, but we only supply the Model T — apocryphally in any colour you like, so long as it’s black. If you need a bespoke Bentley or Bugatti router, you can build it.</p>

<p>The trade-off is the same one history made. A horse rider and a car driver both pick their own destination. But while the horse is happy on grass, the car only delivers that speed and range if there are roads, fuel stops, and mechanics.</p>

<p>Routing is the exact same trade: more range, more power, but you depend on the world outside the proxy. Kroxylicious can’t and shouldn’t make your business policy decisions — it doesn’t know which tenant belongs on which tier or when a cluster swap is safe. Those decisions belong to you. What the proxy gives you is the steering wheel, the throttle, and a much bigger map.</p>

<p>We get it: running a proxy is operational overhead. We wish swapping a CNAME was enough as much as you do — but to a Kafka client, a CNAME flip is an unexpected divorce. That’s why we’re all here.</p>

<h2 id="name-them-we-must">Name them we must</h2>

<p>After reviewing the <a href="https://github.com/kroxylicious/design/pull/70">routing design proposal</a> and thinking through the problem space, I think there are four distinct deployment patterns worth naming: <strong>connection switching</strong>, <strong>stream branching</strong>, <strong>topic weaving</strong>, and <strong>partition weaving</strong>. As with all patterns the boundaries are fuzzy and often more than one applies at once. The thing that convinces me they’re real is that they have descriptive power — each one has its own tradeoffs, failure modes, and a distinct place on the spectrum from the clear(ish) waters of connection switching to the mangrove swamp of partition weaving. Like all good abstractions, they’re useful.</p>

<p>You can deploy the proxy on either side of the network boundary: helping traffic egress from the client domain (forward proxy territory), or managing ingress into the broker domain (reverse proxy territory). I prefer <em>egress</em> and <em>ingress</em> because they describe traffic flows from your perspective rather than abstract networking theory. Some patterns land far more naturally on one side than the other, and we’ll call that out as we go, but the underlying mechanics are the same.</p>

<p>If you’re reaching for the <a href="https://www.enterpriseintegrationpatterns.com/patterns/messaging/MessageRoutingIntro.html">Enterprise Integration Patterns</a> book right now — well done for being as old as I am, the rest of you just Googled it. It describes what happens to individual messages, which is interesting, but I’m talking about whole streams. Those patterns are what makes all this possible under the hood; what I’m describing sits a layer or two higher.</p>

<p>The patterns build on each other along a single axis: how deep into the Kafka protocol the router has to reach. The first two — <strong>connection switching</strong> and <strong>stream branching</strong> — are flow patterns. Think of them like a railway network: you’re directing moving trains, either throwing points at the junction before departure or dispatching carriages down branch lines as the train passes through. The second two — <strong>topic weaving</strong> and <strong>partition weaving</strong> — are topology patterns, where you step off the track to stitch discrete streams into a single logical map.</p>

<p>Connection switching operates at the connection level — which broker, which forms part of which cluster, is this connection actually being sent to? Stream branching works at the stream level — where does this request go? Topic weaving reaches into the topic catalog — which topics are visible and where do they live? Partition weaving goes deepest — how do physical partition spaces map onto a logical one? Each step requires the router(s) to understand more of the protocol than the last. But the complexity doesn’t compound as routing is managed through a DAG which allows them to be composed rather than monolithic. A router handling topic visibility doesn’t care whether the partitions behind it are woven from multiple clusters. A router rewriting partition numbers doesn’t care whether the topic catalog above it spans two physical clusters or twenty.</p>

<h3 id="connection-switching"><a href="/blog/kroxylicious-proxy/2026/10/19/connection-switching-identity-without-commitment.html">Connection switching</a></h3>

<p>Until recently a VKC provided a 1:1 mapping between the thing the client addressed and the thing the proxy dialled. The routing API breaks that constraint — one VKC can now connect to one or more physical backends, and the target isn’t fixed. The VKC is stable; what’s behind it doesn’t have to be.</p>

<p>Every organisation has a cage it can’t close. The CFO wants it gone, but somewhere upstream is “the Thing” nobody dares touch that still talks to the Kafka cluster inside it. The cluster is full. The cage is full. You need more capacity, and you can’t get it here.</p>

<p>Before routing, that means updating <code class="language-plaintext highlighter-rouge">bootstrap.servers</code> in half a million places — and crucially, touching the Thing.</p>

<p>With connection switching, you leave a Kroxylicious instance in the cage and point it at a new cluster wherever you actually have headroom. Every client still connects to the same address. The proxy dials the new cluster behind the scenes. When you’re ready, update the route. When the cage is empty, tell the CFO. Nobody had to touch the Thing.</p>

<p>Before routing, Kroxylicious was a pipe with opinions — it could inspect and rewrite the stream, but it was inherently connection-oriented. One client socket, one backend, straight through. Connection switching breaks the static part of that: the backend can now change. The routing decision is made once at connection time — the points are thrown before the train departs, and after that it’s a straight run to the destination. It’s still 1:1; the interesting thing is that the 1 on the right side is now chosen, not fixed.</p>

<h3 id="stream-branching"><a href="/blog/kroxylicious-proxy/2026/10/29/stream-branching-mind-the-gap.html">Stream branching</a></h3>

<p>You’re chasing an issue in the reporting pipeline that only shows up in the sixth hour of the run and nobody can figure out which record trips it up. You’ve been there, right? What you really want is access to the live data with a debugger. Alas, this job is stuffed full of Personally Identifiable Information — so you’re out of luck. You’ve been there and got <em>that</em> t-shirt. What now? You build a router that shadows production traffic to a staging cluster, piping it through a redaction filter on the way so the PII becomes gibberish before it touches staging brokers. The client is still producing to one VKC. But the proxy is now opening <em>two</em> backend connections — one to the primary cluster, one to staging — and writing every record to both. The acknowledgement the client gets back is from the primary; the shadow write happens on the side. One stream in, two streams out. If you’ve got your EIP book off the shelf already, yes — it’s a Wire Tap with a Message Translator on the diverted stream.</p>

<p>That’s one flavour of stream branching — the secondary stream is a copy of the primary, diverted somewhere and the client never realises. But the diverted branch doesn’t have to be a copy. All staging clusters are capable of handling production load, aren’t they? No? Ohh right, you have budgets. We still want to stage some real traffic, but we can’t handle the full volume. A filter on the staging route drops 90% of the produce requests it sees and forwards the rest — we can do that as nothing cares about the acks.</p>

<p>Every record passes through the routing DAG before it hits the broker. Something in that DAG can inspect the payload, derive something from it — an audit log your compliance team needs, record telemetry for downstream aggregation, or an anonymised event feed — and emit that derived data to a topic anywhere the routing config points — a different topic on the same cluster, or a cluster the client has never heard of. The primary stream is untouched. The additional streams just appear, derived from the original client’s activity. The clients don’t change. Which means anything that previously required every application to cooperate — the audit trail, the telemetry, the thing all but one of your clients never supported — you can now just invent that stream yourself. This all works for stateless transformations performed inline. If you need state, joins, or windowing, Kafka Streams or Kafka Connect have your back.</p>

<p>I think of stream branching as a railway network, where the routing DAG forms the station network itself. The client’s primary stream runs straight down the express mainline. At each station along the line (a router node in the DAG), the stationmaster can inspect passing trains, reassemble carriages (record batches), or dispatch brand new trains down branch lines toward audit or staging clusters — all without delaying express traffic on the mainline. The power of the network is that complexity stays completely self-contained: one station handles PII redaction, the next branches an audit feed, and neither needs to know what happens up or down the line.</p>

<p>Stream branching is fundamentally a dual-write pattern, and dual writes have sharp edges. Kafka logs have no undo button: if a write succeeds on the primary cluster but fails on the secondary, you cannot roll back the primary. Returning an error to the client triggers a retry, sending duplicate batches to the primary; returning success leaves the secondary silently behind.</p>

<p>That is why stream branching is best suited for auxiliary streams — PII-redacted shadows in staging, sampled load, derived telemetry — where losing or duplicating the odd record doesn’t matter. If your architecture strictly requires atomic, lossless replication across two physical clusters, an L7 proxy isn’t the right tool; you want dedicated replication pipelines like MirrorMaker 2 (or KIP-1279 Cluster Mirroring). The dedicated post on stream branching gets into the gory details.</p>

<h3 id="topic-weaving">Topic weaving</h3>

<p>Your New York application team wants to consume <code class="language-plaintext highlighter-rouge">london_orders</code>, <code class="language-plaintext highlighter-rouge">tokyo_orders</code>, and <code class="language-plaintext highlighter-rouge">newyork_orders</code>. Those topics live on three different clusters — one in each region, provisioned by three different teams at three different points in time. Without topic weaving, the NY team needs bootstrap addresses for all three clusters, separate client configurations for all three, and the operational joy of managing credentials and failover for all three. With topic weaving, you point them at one VKC. The routing layer stitches the backing clusters together into a single logical view. The client asks for metadata and gets back a broker list that includes all brokers from all regions as part of the same cluster. As far as the client believes, they all live in its local cluster.</p>

<p>That’s the common case: different topics, different clusters, one coherent view for the client. Your router is what holds the map — which topic lives where, which broker list to return, what gets dispatched where.</p>

<p>There’s a subtler case. What if two of your clusters both host a topic called <code class="language-plaintext highlighter-rouge">orders</code>? Think of it like a sorting office: you write <em>George Street</em> on the parcel and drop it at the counter. The sorting office decides whether you mean George Street, Edinburgh or George Street, Dunedin — a city in New Zealand that Scottish settlers named after Edinburgh, gave the same street names, and promptly scrambled the layout. (Guess why I know.) The sender doesn’t need to know both exist. Neither does your client. Because the proxy controls what gets returned in a metadata response, your router decides which topics are visible and under what names — which means in principle it can arbitrate which names reach clients, or whether the duplicate surfaces at all.</p>

<p>You look after a gaggle of Kafka clusters. You know how they got there. You’re not proud of all of them. You can’t herd them — geese are worse than cats, they honk back — but you don’t have to admit to anyone else how many geese there actually are, or what they’re called.</p>

<p>Two things to keep in mind. Consumer group co-ordination stays pinned to physical clusters — that’s almost always fine, because a group’s offset state is tied to the topic-partitions it’s consuming and those live on one backend, but it’s worth knowing the seam is there. And transactions don’t cross cluster boundaries: a transaction that writes to topics on two different backing clusters is two independent transactions, and there is no way to make it otherwise — the Kafka protocol has no cross-cluster transaction coordinator and routing can’t invent one. If cross-topic atomicity matters, those topics need to share a physical cluster.</p>

<h3 id="partition-weaving">Partition weaving</h3>

<p>Topic weaving weaves (obviously 😉) whole topics together to present a unified catalog. Which invites the natural question: why stop at the topic catalog? Kafka’s real unit of parallelism and storage is the partition. Can we weave at that layer instead?</p>

<p>Yes — but now we have to be <em>really</em> careful with the protocol.</p>

<p>With partition weaving, a single logical topic has its partitions composed from physical topics across multiple clusters — which don’t even need to share a name.</p>

<p>Take an illustrative scenario: your third-party risk engine in <code class="language-plaintext highlighter-rouge">us-east</code> is hardcoded to read from a topic called <code class="language-plaintext highlighter-rouge">orders</code>. It has always read from <code class="language-plaintext highlighter-rouge">orders</code>. It will continue to read from <code class="language-plaintext highlighter-rouge">orders</code> (because vendor software rarely accommodates your topology reorganisations). Meanwhile, your business is growing in Europe, and sending every EU event across the Atlantic to land on <code class="language-plaintext highlighter-rouge">us-east</code> is expensive, slow, and fragile. The EU team provisions <code class="language-plaintext highlighter-rouge">orders-eu</code> on a local cluster sized for their producer load, and EU producers write there directly.</p>

<p>Rather than waiting on a vendor feature request or building intermediate replication pipelines, the router presents both physical topics as one logical <code class="language-plaintext highlighter-rouge">orders</code> topic to the risk engine. When the engine requests metadata for <code class="language-plaintext highlighter-rouge">orders</code>, it gets back 32 partitions: partitions 0–15 are backed by <code class="language-plaintext highlighter-rouge">orders</code> on <code class="language-plaintext highlighter-rouge">us-east</code>, and 16–31 by <code class="language-plaintext highlighter-rouge">orders-eu</code> on <code class="language-plaintext highlighter-rouge">eu-west</code>. When a consumer fetches from partition 20, the proxy transparently routes the <code class="language-plaintext highlighter-rouge">FetchRequest</code> to <code class="language-plaintext highlighter-rouge">eu-west</code> (rewriting it for partition 4) and translates the response back. The risk engine reads the full partition space without a single configuration change, and EU producers write locally without crossing the Atlantic.</p>

<p>Perceptive readers, all of you, will be asking how consumer groups survive this fiction. You can’t simply commit an offset for partition 20 to a coordinator whose cluster only knows 0–15 — Kafka brokers validate committed topic-partitions against their local metadata and reject unmapped ones with <code class="language-plaintext highlighter-rouge">UNKNOWN_TOPIC_OR_PARTITION</code>.</p>

<p>Instead, the proxy intercepts <code class="language-plaintext highlighter-rouge">OffsetCommit</code> and <code class="language-plaintext highlighter-rouge">OffsetFetch</code> requests, demuxes the partition tuples across the backing clusters, and translates virtual partition 20 to physical partition 4 on <code class="language-plaintext highlighter-rouge">eu-west</code>. Each coordinator only ever receives offset commits for partitions that genuinely exist on its cluster, and the proxy stitches the responses back together into a single seamless reply for the consumer.</p>

<p>What the proxy has to do here is far more demanding than in any of the previous patterns: partition numbers must be rewritten consistently across every Kafka RPC that mentions them — and they get everywhere, as you might expect. That’s the essential complexity of the pattern, not incidental overhead. It’s a lot of surfaces to get right. The operational contract also shifts: both physical topics have to honour the mapping, and your router is now the source of truth for what <code class="language-plaintext highlighter-rouge">orders</code> means. Transactions don’t cross cluster boundaries here either — same caveat as topic weaving, but worth repeating because with partition weaving it’s easier to forget the seam is there.</p>

<p>Partition weaving is workable, with a lot of effort. The dedicated post goes into what’s involved, and you can judge whether it’s worth it.</p>

<hr />

<p>These four patterns give us a working vocabulary for the rest of the series. The posts that follow take each one in turn — what it can do, what it can’t, and why. Some of the limits are ours and will close over time. Some are the Kafka protocol’s: transactions have no external coordinator, and no amount of clever routing changes that. And some would require the proxy to grow a consensus layer of its own — which is a whole different animal, and not one we’re planning to domesticate any time soon.</p>

<p>If you’re thinking about Kafka topology problems, have a use case that doesn’t fit cleanly into any of these patterns, or want to tell us where the vocabulary breaks down — find us on <a href="https://github.com/kroxylicious/kroxylicious">GitHub</a>, <a href="https://kroxylicious.slack.com">Slack</a>, or <a href="https://bsky.app/profile/kroxylicious.io">Bluesky</a>.</p>]]></content><author><name>Sam Barker</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="routing" /><summary type="html"><![CDATA[Back in May, Tom wrote about a proof of concept for routing — Kafka clients producing and consuming from topics scattered across multiple clusters, with no idea that’s what they’re doing. The proxy handles the fan-out, the response merging, the session state. The client just sees topics.]]></summary></entry><entry><title type="html">Kroxylicious release 0.25.0</title><link href="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/08/release-0_25_0.html" rel="alternate" type="text/html" title="Kroxylicious release 0.25.0" /><published>2026-10-08T11:00:00+00:00</published><updated>2026-10-08T11:00:00+00:00</updated><id>https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/08/release-0_25_0</id><content type="html" xml:base="https://kroxylicious.io/blog/kroxylicious-proxy/releases/2026/10/08/release-0_25_0.html"><![CDATA[<p>Kroxylicious 0.25.0 has surfaced upstream! 🐊</p>

<p>0.25.0 brings Kubernetes-based authentication for HashiCorp Vault, improved control of the Kubernetes Service resources created for Load Balancer-based ingress, the ability to configure the Service Account used to run the proxy pods, and OpenRewrite recipes to aid configuration migrations.  Take a look at <a href="https://github.com/kroxylicious/kroxylicious/blob/v0.25.0/CHANGELOG.md">all the changes</a>.</p>

<hr />

<h3 id="kubernetes-authentication-for-hashicorp-vault-kms">Kubernetes Authentication for HashiCorp Vault KMS</h3>

<p>Kroxylicious 0.25.0 adds Kubernetes authentication support to the HashiCorp Vault KMS provider. Running proxy instances in Kubernetes no longer requires managing Vault authentication tokens manually. You can now leverage HashiCorp Vault’s <a href="https://developer.hashicorp.com/vault/docs/auth/kubernetes">Kubernetes auth method</a> so that the Record Encryption filter authenticates to Vault using an annotated service account, giving you an improved security posture.</p>

<hr />

<h3 id="kubernetes-load-balancer-service-improvements">Kubernetes Load Balancer Service Improvements</h3>

<p>Several enhancements improve load balancer service integration support in the operator:</p>

<ul>
  <li>annotations specified in the <code class="language-plaintext highlighter-rouge">KafkaProxyIngress</code> CR now flow to the load balancer <code class="language-plaintext highlighter-rouge">Services</code>.  This is useful if you need to
have precise control of the type of load balancer deployed by your cloud provider.</li>
  <li>there’s now the ability to control <code class="language-plaintext highlighter-rouge">externalTrafficPolicy</code> and <code class="language-plaintext highlighter-rouge">allocateLoadBalancerNodePorts</code> giving you fine-grained control over load balancer behaviour.</li>
  <li>if a single <code class="language-plaintext highlighter-rouge">KafkaProxyIngress</code> is shared by many <code class="language-plaintext highlighter-rouge">VirtualKafkaClusters</code>, the load balancer service remains shared.  If you
use multiple <code class="language-plaintext highlighter-rouge">KafkaProxyIngress</code> resources of type <code class="language-plaintext highlighter-rouge">loadBalancer</code>, these will now result in distinct <code class="language-plaintext highlighter-rouge">Service</code> instances.</li>
</ul>

<h3 id="kubernetes-service-account-support">Kubernetes Service Account Support</h3>

<p>The <code class="language-plaintext highlighter-rouge">KafkaProxy</code> CR now allows you to refer to a Kubernetes <code class="language-plaintext highlighter-rouge">ServiceAccount</code> resource. If this is done, the proxy pods will use the
service account rather than the <code class="language-plaintext highlighter-rouge">default</code> service account.</p>

<h3 id="openrewrite-recipes-for-automated-configuration-upgrade">OpenRewrite Recipes for automated Configuration Upgrade</h3>

<p>You may remember we dipped our toes into the world of OpenRewrite in 0.24.0, where we used it to automate code changes following an API change.</p>

<p>We’ve extended the migration to support some upgrades of the Kroxylicious configuration file. The scope is limited to the <code class="language-plaintext highlighter-rouge">clusterDefinitions</code> configuration refactor, but we intend to teach it new things in upcoming releases.</p>

<p>It is as easy as:</p>

<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># dry-run</span>
jbang io.kroxylicious:kroxylicious-migrations:0.25.0 convert-config <span class="nt">--dry-run</span> /path/to/kroxylicious-config.yaml
<span class="c"># or apply them</span>
jbang io.kroxylicious:kroxylicious-migrations:0.25.0 convert-config /path/to/kroxylicious-config.yaml
</code></pre></div></div>

<hr />

<h3 id="community-contributions">Community Contributions</h3>

<p>This release included commits from:</p>
<ul>
  <li><a href="https://github.com/search?q=Abdullah">Abdullah</a></li>
  <li><a href="https://github.com/AdityaThakur1998">Aditya Thakur</a></li>
  <li><a href="https://github.com/DragonFSKY">DragonFSKY</a></li>
  <li><a href="https://github.com/search?q=Francisco+Vila">Francisco Vila</a></li>
  <li><a href="https://github.com/search?q=henryZrncik">henryZrncik</a></li>
  <li><a href="https://github.com/search?q=Hiroaki+KAWAI">Hiroaki KAWAI</a></li>
  <li><a href="https://github.com/search?q=Jabrail">Jabrail</a></li>
  <li><a href="https://github.com/jjj-n">jjj-n</a></li>
  <li><a href="https://github.com/k-wall">Keith Wall</a></li>
  <li><a href="https://github.com/matheusandre1">Matheus André</a></li>
  <li><a href="https://github.com/search?q=Peter+Mendis">Peter Mendis</a></li>
  <li><a href="https://github.com/RafaelReia">Rafael Reia</a></li>
  <li><a href="https://github.com/search?q=Robert+Young">Robert Young</a></li>
  <li><a href="https://github.com/SamBarker">Sam Barker</a></li>
  <li><a href="https://github.com/search?q=Thomas+Cooper">Thomas Cooper</a></li>
  <li><a href="https://github.com/tombentley">Tom Bentley</a></li>
</ul>

<p>Thank you all, your hard work is massively appreciated!</p>

<h3 id="artefacts">Artefacts</h3>

<p>Download binary distributions and container images from the <a href="https://kroxylicious.io/download/0.25.0/">download</a> page.</p>

<h3 id="feedback">Feedback</h3>

<p>Drop by and say hello on <a href="https://kroxylicious.slack.com">Slack</a>, <a href="https://github.com/kroxylicious/kroxylicious/issues">GitHub</a>, or <a href="https://bsky.app/profile/kroxylicious.io">bsky</a>. You can also join us in person at a <a href="/join-us/community-call/">community call</a>.</p>]]></content><author><name>Keith Wall</name></author><category term="blog" /><category term="kroxylicious-proxy" /><category term="releases" /><category term="releases" /><category term="kroxylicious-proxy" /><summary type="html"><![CDATA[Kroxylicious 0.25.0 has surfaced upstream! 🐊]]></summary></entry></feed>