Case Study Laurel's software factory: 6x the PRs at a 75% lower incident rate. Read the case study.

Making Ephemeral Environments Work for Event-Driven Services

How Miro extended its ephemeral environments to Kafka: a routing key carried in message headers, a consumer group per environment, and a fail-open filter in every consumer.

Author
Guest Author: Sanket Barapatre
Published
November 23, 2026
Reading time
10 min

This article was originally published on the Miro Engineering blog.

Kafka is one part of how Miro uses Signadot: half of its engineering teams test their changes in lightweight ephemeral environments every day, and its AI team builds and tests agentic features on them. Read the Miro case study.


When engineers change a backend service, they want to see how it behaves with everything around it: its callers, the services it calls, its database and its message broker. At Miro, we do that with ephemeral environments, but for services that talk over Kafka, the capability fell short. This post is about how we addressed that.

Ephemeral environments

An ephemeral environment is a short-lived test environment that an engineer creates on demand and deletes when they’re done. It lets them test their code changes against real dependencies, in an environment closer to production than their laptop. Before Miro adopted this approach, engineers shared one test environment, overwrote each other’s changes, and couldn’t always tell which version of a service they were testing.

In our setup, an engineer creates an ephemeral environment containing only the services they want to test. Let’s say they’re working on service B and they want to deploy their changed version of B next to the shared baseline. Everything else, including services A and C, their databases and the message broker, stays on the shared baseline. Each ephemeral environment is given its own unique routing key and requests meant for services in that environment carry that key. A request carrying the matching routing key reaches the changed version of B, and a request without it reaches the baseline B. This means requests from other users keep going to the baseline.

An ephemeral environment can contain several services, for example when a change spans more than one service.

In short, an ephemeral environment is a set of ephemeral deployments plus a routing key.

The routing key travels in the W3C baggage header, relying on the standard OpenTelemetry setup used across all our microservices. We build our ephemeral environments on Signadot.

This post focuses on one piece of it: Kafka.

Diagram titled "How a request reaches an ephemeral environment". With routing key "alice", a request passes through Service A (labeled baseline), then reaches alice's ephemeral deployment of Service B, then Service C (labeled baseline). Without a key, the request passes through the baseline of Services A, B and C.

The approach described above works well for synchronous requests like HTTP and gRPC: every hop carries the routing header, and every request reaches the right workload. But when a request carrying the routing key publishes a Kafka message, the trail goes cold.

Routing broke for these flows. Sometimes the services inside an ephemeral environment picked up another engineer’s event and broke their testing flow. Sometimes the baseline picked up the test event and broke the test in the ephemeral environment.

Engineers could not test their changes correctly in isolation, and test traffic leaked outside the ephemeral environment, affecting downstream services. We wanted ephemeral environments to work the same way regardless of how services talk to each other.

Why Kafka doesn’t route like a request

Two things set Kafka apart from HTTP and gRPC.

There’s no “request” to route: A Kafka consumer pulls messages from the broker over a long-lived connection. The broker doesn’t look at message headers to decide who gets a message. Instead, each partition of a topic is assigned to exactly one member of a consumer group. The request-level routing that works for HTTP has nothing to act on.

The Kafka broker is a shared resource: There’s one broker cluster and one copy of each topic, and neither knows about ephemeral environments. The cluster sits outside the ephemeral environment boundary. In a test environment, every version of a service, baseline or ephemeral, reads from the same topics.

This explains what our engineers ran into:

  • Wrong consumer: ephemeral and baseline deployments shared the same consumer group, so a partition assignment decided who got the event.
  • Lost key: the routing key wasn’t propagated with the message at all.

A three-phase solution

We defined some goals for our solution:

  • No per-environment setup: once a service has adopted it, creating an ephemeral environment is enough to turn routing on.
  • Minimal impact on production, and one control switch: the solution is designed to do nothing where there are no ephemeral environments, and one configuration flag turns it off entirely.
  • Low overhead: small enough for end-to-end and performance tests to run through it.

We delivered it in three phases, and each phase was useful on its own.

Phase 1: Carry the routing key across Kafka events

Most of our services share a common Kafka client library. A few still had their own Kafka clients, so we moved them onto the shared library first, then made the change there: producers write the routing key into the message headers and consumers restore it into context before the handler runs. Any HTTP, gRPC or Kafka call made by the handler carries the same key, so a flow can go from request → message → request and stay in the ephemeral environment. Building this support into the shared library rather than each service’s configuration meant that every service got it through one library upgrade.

Some of our services publish events through a common transactional outbox solution. These services needed an extra step: the routing key is stored as part of the outbox record so the relay can attach it when the event is published.

In production, the headers are carried too, but with no ephemeral environments present, nothing routes on them.

Diagram titled "Carrying the routing key across a Kafka event". A request carries the routing key in its baggage header. The producer service writes the key into the message headers, the Kafka topic carries it as a baggage header, the consumer service restores the key into context, and the next call, whether HTTP, gRPC or Kafka, carries the same key.

Phase 2: Separate consumer groups per ephemeral environment

Kafka delivers each message to every consumer group, so the simplest way to make sure an ephemeral environment sees a message is to give it its own group. When a service starts in an ephemeral environment, the library appends the environment’s name to the group ID. The new consumer group ages out through Kafka’s normal offset retention once the ephemeral environment is deleted.

Outside an ephemeral environment, the group ID doesn’t change, so the baseline keeps its group and its committed offsets.

Diagram titled "A consumer group per ephemeral environment". A producer service publishes messages m1 to m4 to a Kafka topic. The baseline consumer, in group checkout-events, is unchanged and keeps its committed offsets. The ephemeral consumer, in group checkout-events-<environment-name>, starts at the latest offset and is cleaned up by offset retention. Both receive m1 to m4: each consumer group receives its own copy of every message, so the ephemeral environment never steals a partition from the baseline.

The side effect: every consumer, baseline and ephemeral alike, now received every message. Phase 3 fixed that.

Phase 3: Let every Kafka consumer decide what to process

Consumers in an ephemeral environment were the easy half of the solution. An ephemeral environment knows its own routing key, so it can skip anything that doesn’t carry it. The baseline was the more difficult part.

Should it skip every message that carries a routing key? Not always.

If a service’s baseline skipped every message with a routing key, nothing would reach downstream services, and tests would break. The baseline should skip a message only when it carries the routing key of an ephemeral environment that includes this service.

We wrote the target behaviour down as a table before writing any code, and it became our acceptance test:

Routing key in the messageConsumerShouldWhy
no keyBaselineProcessNormal traffic
no keyalice’s ephemeral deploymentSkipAn ephemeral deployment handles only traffic aimed at it
alicealice’s ephemeral deploymentProcessExact match
alicebob’s ephemeral deploymentSkipEphemeral environments don’t interfere with each other
alice, and alice’s ephemeral environment includes this serviceBaselineSkipKeeps the baseline out of someone else’s test
alice, but alice’s ephemeral environment doesn’t include this serviceBaselineProcessThe flow passes through this service, so someone has to handle it

The last two rows were the hard part. Letting the baseline process everything mixes up end-to-end results. Giving it a fixed list of keys to reject would break every time the test tooling changed.

Our chosen solution: ask the ephemeral environment platform (Signadot) which routing keys belong to active ephemeral environments that include this service, and skip only those. The platform already exposes this list, and Signadot’s guide to testing Kafka-based microservices describes the pattern.

The check reads only the headers, so skipping a message is cheap.

Three design choices kept this small:

  • Look up on demand, then cache
    Instead of polling in the background, the baseline looks up active keys only when a message carries one, and caches them for 10 seconds by default. The trade-off: for up to that long after an ephemeral environment starts or is deleted, its messages may be processed twice or not at all. In practice an ephemeral environment takes longer than that to start, so the window rarely matters, and either way it stays within the test environment.
  • Fail open
    If the lookup fails, the baseline processes everything, as it did before any filtering existed. A test message processed twice is easier to spot than one that silently disappears, and metrics show us when it happens.
  • Keep production impact minimal
    The filter is opt-in and skips nothing where no ephemeral environments exist, so production consumers keep processing every message.

What changed

BeforeAfter
Testing a change to a Kafka consumerWhether your test event reached your ephemeral deployment depended on its partitionYour ephemeral environment gets its own copy of every event and processes only yours
Your test’s effect on othersYour ephemeral deployment could process other engineers’ events, and the baseline could process yoursThe baseline skips only events meant for an active ephemeral environment that includes the service, so test events stay within their own environment
Flows that cross KafkaThe routing key was lost at the first Kafka hopThe key survives Kafka, including the transactional outbox, so a request → event → request flow stays in your ephemeral environment

For a service already on the shared Kafka library, adoption is a one-time opt-in. After that, every new ephemeral environment that includes the service gets routing with no further setup. Teams whose end-to-end tests span Kafka can now run them in ephemeral environments instead of the shared test environment, and tests for several changes can run in parallel without getting in each other’s way.

What we learned

  1. Extend the convention you already have
    HTTP and gRPC already carried the routing key in W3C baggage. Putting it in the same header meant the key now flows through any mix of synchronous and asynchronous hops.
  2. Consolidate before you extend
    If some services bypass your shared client library, move them onto it first. It takes longer up front, but every later change then ships once instead of twice.
  3. Ship through what teams already use
    The easiest feature to adopt arrives in a dependency teams already have, and is enabled by the platform they already deploy with. Building it into the shared client library, rather than shipping a separate one, is what made that possible here.

Closing thoughts

Closing the Kafka gap didn’t take extra topics or a parallel messaging stack. It took a routing key that travels with the message, a consumer group per ephemeral environment, and a short, fail-open check in each consumer against the list of active routing keys.

Thanks to Yannis Gonianakis for reviewing the Kafka design, Daniel Stanoescu and Andrew Eacott for laying the foundations of our ephemeral environments, and Luci Onea for adopting early and sharing feedback.


Apache®, Apache Kafka®, Kafka, and the associated logos are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries. No endorsement by the Apache Software Foundation is implied by the use of these marks. OpenTelemetry is a trademark of The Linux Foundation. Signadot is a trademark of Signadot, Inc. W3C® is a trademark (registered in numerous countries) of the World Wide Web Consortium. All other trademarks are the property of their respective owners. Use of these names and logos is for identification purposes only and does not imply endorsement or affiliation.

Stay in the loop

Get the latest updates from Signadot