<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pallavi Singla</title>
    <description>The latest articles on DEV Community by Pallavi Singla (@laserdatainc).</description>
    <link>https://dev.to/laserdatainc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4226936%2Fc6769bda-931a-4926-835a-f3e3fe7c6527.png</url>
      <title>DEV Community: Pallavi Singla</title>
      <link>https://dev.to/laserdatainc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/laserdatainc"/>
    <language>en</language>
    <item>
      <title>Killing agents in a delivery desk demo</title>
      <dc:creator>Pallavi Singla</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:14:20 +0000</pubDate>
      <link>https://dev.to/laserdatainc/killing-agents-in-a-delivery-desk-demo-4j1c</link>
      <guid>https://dev.to/laserdatainc/killing-agents-in-a-delivery-desk-demo-4j1c</guid>
      <description>&lt;p&gt;&lt;em&gt;This post first appeared on the &lt;a href="https://laserdata.com/blog/killing-agents-in-a-delivery-desk-demo" rel="noopener noreferrer"&gt;LaserData blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/laserdata/laser-delivery-desk" rel="noopener noreferrer"&gt;delivery desk&lt;/a&gt; is a demo app built on &lt;a href="https://github.com/laserdata/laser-sdk" rel="noopener noreferrer"&gt;Laser SDK&lt;/a&gt; 0.8.2 for Python. Agents handle problems for a fleet of delivery vans: closed roads, drivers who don't answer, customers who aren't home, new orders during the day, and the carrier's invoice at the end of the day. The code is on GitHub at &lt;a href="https://github.com/laserdata/laser-delivery-desk" rel="noopener noreferrer"&gt;laserdata/laser-delivery-desk&lt;/a&gt;, and the &lt;a href="https://docs.laserdata.com/laser-sdk" rel="noopener noreferrer"&gt;Laser SDK docs&lt;/a&gt; cover each feature it uses.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://laserdata.com/blog/agents-fail-their-sessions-shouldnt" rel="noopener noreferrer"&gt;support desk demo&lt;/a&gt; showed one agent recovering from a crash part way through a ticket. The delivery desk has more agents, and each problem is handled by a workflow that runs several steps across them. This post covers how the agents share work, what happens when you kill an agent part way through a task, and how to try that yourself, and then how the vans' rounds are planned and the other Laser SDK features the demo uses.&lt;/p&gt;

&lt;h2&gt;
  
  
  The demo
&lt;/h2&gt;

&lt;p&gt;Four vans drive their rounds on a map of inner Melbourne, and a slider changes the number of vans from two to eight. Each van starts the day with six drops, and customers order more during the day. The header lists the incidents you can trigger:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Road closure&lt;/strong&gt;: a van stops, and its round is replanned so the blocked drop comes last.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Driver unreachable&lt;/strong&gt;: a van stops answering, so it is parked and its drops move to another van.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nobody home&lt;/strong&gt;: a drop fails, and the parcel stays on the van for a second try at the end of its round.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SMS gateway down&lt;/strong&gt;: the next customer message fails, and once its retries run out it waits on the desk until you fix the gateway and send it again.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overbilled invoice&lt;/strong&gt;: the vans are run by a carrier, a courier company that bills the desk at the end of the day for each drop, each failed drop and each kilometre driven. This incident makes the carrier's bill charge for two more drops and 6 km more on one van than actually happened, as a billing mistake would, and the invoice agent finds the gap and asks a person before disputing it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqfmoke6e42kjo7np1kfa.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqfmoke6e42kjo7np1kfa.jpg" alt="The delivery desk during the day: vans on the map, resolved exceptions and new orders" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The delivery desk during the day: vans on the map, resolved exceptions and new orders&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The customers, the carrier and its rates are made up, and the SMS gateway is simulated, so no text messages go to real phones: each customer message is written to the log as an event instead.&lt;/p&gt;

&lt;p&gt;Two agents can use an LLM to write text: routing writes a one-line summary of each exception, and customer writes each message to a customer. By default the demo uses a mock that fills in fixed templates, so it runs with no model and no network calls. Set &lt;code&gt;DESK_LLM=claude&lt;/code&gt; to have Claude Code (&lt;code&gt;claude -p&lt;/code&gt;) write the text, or &lt;code&gt;DESK_LLM=api&lt;/code&gt; to call the Anthropic API, which needs an &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  The agents and the log
&lt;/h2&gt;

&lt;p&gt;The demo has four agent roles, each running as its own process, and routing runs as two copies that share the routing work between them, so five agent processes run in all.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dispatch&lt;/strong&gt; watches the log for problems, such as a van that has stopped or a drop that failed. It records each one as an exception, the demo's name for a delivery problem being handled (not a Python exception), and runs a workflow for each exception and each new order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing&lt;/strong&gt; assesses an exception and replans the rounds, or adds a new order to the van that needs the least extra driving.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customer&lt;/strong&gt; tells affected customers what is happening and when to expect their parcel, and keeps a record of earlier problems for each customer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invoice&lt;/strong&gt; checks the carrier's bill against the log at the end of the day, and asks a person before disputing anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Routing, customer and invoice are Laser SDK agents: each is started with &lt;code&gt;laser.spawn_agent&lt;/code&gt; and listed in the agent registry with the skills it serves. Dispatch is not an agent in that sense. It is an ordinary process that watches the views and runs the workflows that send work to the agents.&lt;/p&gt;

&lt;p&gt;The agents don't call each other. Everything they share goes through the server they all connect to, which for local development is &lt;a href="https://docs.laserdata.com/laser-sdk/laser-stack" rel="noopener noreferrer"&gt;Laser Stack&lt;/a&gt;. Laser Stack runs two services in Docker, named &lt;code&gt;iggy&lt;/code&gt; and &lt;code&gt;plane&lt;/code&gt;. The &lt;code&gt;iggy&lt;/code&gt; service is LaserData's build of the Apache Iggy server, which the docs call Laser Streams, and it holds the durable log. The &lt;code&gt;plane&lt;/code&gt; service is a managed backend that adds views, queries, key-value state, forks and the other features plain Apache Iggy doesn't have. LaserData Cloud provides the same features as a hosted deployment, and moving the demo between the two only changes the connection string. The demo uses three parts of it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The log.&lt;/strong&gt; An append-only, durable record of messages, stored in &lt;a href="https://iggy.apache.org" rel="noopener noreferrer"&gt;Apache Iggy&lt;/a&gt;. The simulator writes each van's position to the &lt;code&gt;fleet.positions&lt;/code&gt; topic, and drops, failed drops, agent steps and outcomes go to &lt;code&gt;fleet.events&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://docs.laserdata.com/laser-sdk/state" rel="noopener noreferrer"&gt;Key-value state&lt;/a&gt; (KV).&lt;/strong&gt; Holds the rounds, the status of each stop, the open exceptions and the result of each step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://docs.laserdata.com/laser-sdk/views" rel="noopener noreferrer"&gt;Queries and views&lt;/a&gt;.&lt;/strong&gt; A view keeps a topic in a form you can query, such as "which vans have stopped", and each view has a &lt;a href="https://docs.laserdata.com/laser-sdk/change-feed" rel="noopener noreferrer"&gt;change feed&lt;/a&gt;, so a process can follow new rows as they arrive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The simulator is not an agent: it drives the vans, makes the drops and plays the incidents, and writes everything it does to the log.&lt;/p&gt;
&lt;h2&gt;
  
  
  How dispatch works
&lt;/h2&gt;

&lt;p&gt;Dispatch follows both views with &lt;code&gt;laser.watch&lt;/code&gt;. When a van stops or a drop fails, dispatch opens an exception and saves it to KV with &lt;code&gt;expect_absent()&lt;/code&gt;, a write that only succeeds if the key doesn't exist yet. If dispatch sees the same incident again, even after a restart, the write fails, so no second exception is opened.&lt;/p&gt;

&lt;p&gt;Dispatch then runs a &lt;a href="https://docs.laserdata.com/laser-sdk/advanced/agents" rel="noopener noreferrer"&gt;workflow&lt;/a&gt; for the exception. For a closed road, an unreachable driver or a missed drop, the steps are assess, replan and notify, and for a new order they are assign and notify. The workflow engine records each step on the log as the run goes, and those records, the workflow's journal, are what let a restarted dispatch carry on from the right step.&lt;/p&gt;

&lt;p&gt;Each step names a skill rather than an agent. When an agent starts, it publishes a card to the agent registry listing the skills it serves (&lt;code&gt;assess&lt;/code&gt;, &lt;code&gt;replan&lt;/code&gt;, &lt;code&gt;assign&lt;/code&gt;, &lt;code&gt;notify&lt;/code&gt; or &lt;code&gt;invoice-check&lt;/code&gt;), and to run a step the registry finds the agents that serve its skill. Both routing processes serve the same skills, and dispatch sends each step to the one it has sent the fewest steps to, so the work is spread across them.&lt;/p&gt;
&lt;h2&gt;
  
  
  How resume works
&lt;/h2&gt;

&lt;p&gt;When an agent is killed, the process that replaces it has to find the task the old one was working on, and then find out how much of that task was already done.&lt;/p&gt;

&lt;p&gt;It gets the task back through redelivery. An agent marks a message as done only when it has finished handling it, so the message a killed agent was working on is never marked done, and the log delivers it again to the next process.&lt;/p&gt;

&lt;p&gt;It finds out how much was done from KV. Each step writes its result to KV, keyed by the exception id and the step name, so before doing a step routing checks for a saved result and, if there is one, returns it instead of doing the work again. A replan changes several things at once, so routing saves the whole plan to KV before applying any of it.&lt;/p&gt;

&lt;p&gt;The customer and invoice agents use the same check. Once the customer agent has sent the messages for an exception, it saves them in KV under the exception's id, so if the notify step is delivered again it answers with the saved messages. The invoice agent saves its finished check the same way and returns it if the check is asked for again.&lt;/p&gt;

&lt;p&gt;Laser SDK provides the log, redelivery, KV and the workflow journal, and the app decides what to save and makes each write safe to repeat.&lt;/p&gt;
&lt;h2&gt;
  
  
  Killing routing during a replan
&lt;/h2&gt;

&lt;p&gt;When a road closes, dispatch sends the replan step to one of the routing agents. Routing works out the new rounds, saves them, and then applies them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;plan_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{exc['id']}:plan"&lt;/span&gt;
&lt;span class="n"&gt;saved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;get_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plan_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;saved&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;saved&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;work_out&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;put_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plan_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;saved&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"checkpoint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;van&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;van&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;incident&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"new rounds saved to KV before applying them"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"replay"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;van&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;van&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;incident&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"found the saved plan, applying it"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Saving and applying a plan takes a fraction of a second, which is too quick to kill by hand. The &lt;code&gt;DESK_STEP_PAUSE&lt;/code&gt; setting makes routing wait a few seconds after saving the plan and before applying it, and while it waits, the exception card shows which routing agent has the step.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvfbat9sapm4mdi86tuu2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvfbat9sapm4mdi86tuu2.jpg" alt="A road closure on van-2, with routing holding before it applies the new round" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;A road closure on van-2, with routing holding before it applies the new round&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Each agent has a Kill button in the Agents panel, which sends the process SIGKILL, so it stops straight away without finishing or tidying up, as it would in a crash. The demo's supervisor, which starts all the agent processes, sees that one has died and starts a new one in its place.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnrgx5q5v1fwfyux1h9ro.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnrgx5q5v1fwfyux1h9ro.jpg" alt="Routing killed with SIGKILL while it holds the replan" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Routing killed with SIGKILL while it holds the replan&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the run shown here, &lt;code&gt;routing&lt;/code&gt; was killed while it held the replan. These are the main log lines for that exception:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;checkpoint routing replan | new rounds saved to KV before applying them
holding routing replan | holding 8s before committing: kill routing now
killed routing | routing pid 4565 killed (SIGKILL)
agent_up routing | routing up (pid 4598, LLM mock)
replay routing replan | found the saved plan, applying it
step routing replan done | van-2 goes round the closure: Southbank moved to the end of the round.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The new process found the saved plan and applied it without working it out again. Each step completed once, every parcel was delivered once, and the demo's end-of-day check that every kill was recovered passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fshlchrv7gd7gu7g4agyu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fshlchrv7gd7gu7g4agyu.jpg" alt="The new routing process finished the replan, and the exception resolved with the customer told" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The new routing process finished the replan, and the exception resolved with the customer told&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;While one routing agent applies a replan, the other may be adding a new order to the same van, and both write that van's round in KV. Routing writes rounds with compare-and-swap, so a write only goes through if the round hasn't changed since routing read it. If it has, routing reads the round again and applies its change on top, so the new order stays on the van instead of being overwritten by the replan.&lt;/p&gt;
&lt;h2&gt;
  
  
  Killing dispatch
&lt;/h2&gt;

&lt;p&gt;When dispatch starts, it looks in KV for open exceptions and resumes each workflow under its original run id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;scan_json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exceptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"open"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;event&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"resume"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;van&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"van"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;incident&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"resuming workflow {exc['run'][-6:]} from its journal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;wf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;laser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;workflow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"dispatch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fixed_inbox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;C&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;INBOX&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;wf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"run"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# the same id resumes the same run from its journal&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Passing an earlier run id to &lt;code&gt;run_id&lt;/code&gt; tells the workflow engine to replay that run's journal, skipping the steps it records as complete and sending out only the ones that didn't finish.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it
&lt;/h2&gt;

&lt;p&gt;You need Python 3.11 or later and Docker. Clone &lt;a href="https://github.com/laserdata/laser-delivery-desk" rel="noopener noreferrer"&gt;laserdata/laser-delivery-desk&lt;/a&gt;, then start Laser Stack from the project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This starts Laser Stack from the published &lt;a href="https://github.com/laserdata/laser-stack" rel="noopener noreferrer"&gt;images&lt;/a&gt;. Wait until &lt;code&gt;docker compose ps&lt;/code&gt; shows &lt;code&gt;iggy&lt;/code&gt; and &lt;code&gt;plane&lt;/code&gt; as healthy, then install and run the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 -m venv .venv &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; . .venv/bin/activate
pip install -e .
python -m fleet.server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To try a kill, start the server with &lt;code&gt;DESK_STEP_PAUSE=8&lt;/code&gt; so routing holds for eight seconds before committing a new round. Pick Road closure, then click Kill on the routing agent that is holding, or on dispatch.&lt;/p&gt;

&lt;p&gt;To run against LaserData Cloud instead of Docker, set &lt;code&gt;LASER_CONNECTION_STRING&lt;/code&gt; to your deployment; the README lists this and the other settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Planning the rounds
&lt;/h2&gt;

&lt;p&gt;The route planning is in &lt;a href="https://github.com/laserdata/laser-delivery-desk/blob/main/fleet/plan.py" rel="noopener noreferrer"&gt;&lt;code&gt;fleet/plan.py&lt;/code&gt;&lt;/a&gt;, and it works from road distances, which are covered in the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Starting rounds.&lt;/strong&gt; The demo has 60 customer stops around the depot in West Melbourne. At the start of the day it sorts them by compass bearing from the depot and cuts that list into one slice per van, so each van gets its own part of the city. Each van takes the six stops in its slice nearest the depot and visits them nearest first, and the other stops are the customers who order during the day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;New orders.&lt;/strong&gt; For each van, routing works out the cheapest place to fit the new stop into its round, measured as the extra metres driven, including the drive back to the depot. Each drop the van already has adds 1.5 km to the cost, so a busy van is less likely to get the order, which goes to the van with the lowest total.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Road closure.&lt;/strong&gt; The van does the rest of its round first, nearest stop next, and comes back to the blocked drop last.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nobody home.&lt;/strong&gt; The failed drop moves to the end of the round for a second attempt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Driver unreachable.&lt;/strong&gt; The van is taken off the road and its remaining drops go to one other van. To pick that van, routing scores each van still driving as its distance in kilometres from the stopped van plus 2 km for every stop it still has to make, and chooses the lowest score, so a nearby van with few drops left wins. The handed-over drops are then added to that van's round, and the whole round is reordered nearest stop first.&lt;/p&gt;

&lt;p&gt;Arrival times assume 3 minutes per kilometre of inner-city driving and 4 minutes at each drop, on the demo's clock, and customers are given a one-hour window starting on the half hour.&lt;/p&gt;

&lt;h2&gt;
  
  
  The roads and the map
&lt;/h2&gt;

&lt;p&gt;The vans follow real roads. The road between every pair of places (the depot and the 60 stops) is saved in &lt;code&gt;fleet/data/roads.json&lt;/code&gt;, which holds 3,660 one-way legs.&lt;/p&gt;

&lt;p&gt;The file was made once by &lt;code&gt;scripts/fetch_roads.py&lt;/code&gt;, which asks the public &lt;a href="https://project-osrm.org" rel="noopener noreferrer"&gt;OSRM&lt;/a&gt; demo router for driving routes over &lt;a href="https://www.openstreetmap.org" rel="noopener noreferrer"&gt;OpenStreetMap&lt;/a&gt; data. Each leg's points are simplified with the Douglas-Peucker algorithm to within 4 metres of the road, which keeps the shape at a fraction of the size. The demo reads the file and calls no routing service when it runs.&lt;/p&gt;

&lt;p&gt;The simulator moves each van 120 metres along its road every half second. The map in the browser uses &lt;a href="https://leafletjs.com" rel="noopener noreferrer"&gt;Leaflet&lt;/a&gt;, a JavaScript map library, with map tiles from OpenStreetMap. The server reads van positions from &lt;code&gt;fleet.positions&lt;/code&gt; and pushes them to the browser over a websocket.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Laser SDK features it uses
&lt;/h2&gt;

&lt;p&gt;Killing and resuming an agent uses the log, KV, workflows and the agent registry. The demo uses more of Laser SDK than that, and this table lists every feature it uses:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;What the demo uses it for&lt;/th&gt;
&lt;th&gt;Docs&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Log&lt;/td&gt;
&lt;td&gt;Van positions on fleet.positions ; drops, failed drops, agent steps and outcomes on fleet.events&lt;/td&gt;
&lt;td&gt;Messages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Views and change feed&lt;/td&gt;
&lt;td&gt;Dispatch follows two queryable views of the log with laser.watch&lt;/td&gt;
&lt;td&gt;Queries and views , Changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Queries&lt;/td&gt;
&lt;td&gt;The invoice check, the Readers panel and the evals count drops and kilometres per van&lt;/td&gt;
&lt;td&gt;Queries and views&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KV&lt;/td&gt;
&lt;td&gt;Rounds, stop status, exceptions and each step's result, with compare-and-swap and write-if-absent&lt;/td&gt;
&lt;td&gt;Key-value state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agents&lt;/td&gt;
&lt;td&gt;Routing, customer and invoice, each started with laser.spawn_agent , with retries&lt;/td&gt;
&lt;td&gt;Agents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Agent registry&lt;/td&gt;
&lt;td&gt;Each step names a skill, and the registry finds the agents that serve it&lt;/td&gt;
&lt;td&gt;Agents in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quarantine&lt;/td&gt;
&lt;td&gt;Takes an agent out of routing from the desk, and puts it back&lt;/td&gt;
&lt;td&gt;Agents in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Workflows&lt;/td&gt;
&lt;td&gt;One laser.workflow("dispatch") run per exception or order, resumed from its journal&lt;/td&gt;
&lt;td&gt;Agents in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contracts&lt;/td&gt;
&lt;td&gt;Dispatch sends the invoice check to whichever agent serves invoice-check , with a deadline&lt;/td&gt;
&lt;td&gt;Agents&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approval gate&lt;/td&gt;
&lt;td&gt;The invoice agent waits for a person before disputing a bill&lt;/td&gt;
&lt;td&gt;Agents in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dead letters and redrive&lt;/td&gt;
&lt;td&gt;A customer message that keeps failing is parked, then sent again once the gateway is fixed&lt;/td&gt;
&lt;td&gt;Agents in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forks&lt;/td&gt;
&lt;td&gt;The invoice agent tests the carrier's version of the day on a copy of the views&lt;/td&gt;
&lt;td&gt;Key-value state in depth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory&lt;/td&gt;
&lt;td&gt;The customer agent remembers each customer's earlier problems across days&lt;/td&gt;
&lt;td&gt;Memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Replay&lt;/td&gt;
&lt;td&gt;Rewind reads both topics from the start to rebuild the day&lt;/td&gt;
&lt;td&gt;Messages&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The other features
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Starting agents and retries.&lt;/strong&gt; Each agent process calls &lt;code&gt;laser.spawn_agent&lt;/code&gt; with the skills it serves, which go on its card in the registry, a handler for its messages, and a retry policy. If the handler raises an error, the SDK tries the message again a few times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quarantine.&lt;/strong&gt; Quarantining an agent stops new work going to it while leaving the process running, which you might do if one copy of an agent starts giving bad results. In the demo, each agent has a Quarantine button in the Agent registry panel in the browser. The button calls &lt;code&gt;laser.quarantine&lt;/code&gt;, which records in the registry that the agent is quarantined, and because dispatch picks agents through the registry, it sends new steps only to the agents still in service, with no change to dispatch's code. Reinstate calls &lt;code&gt;laser.unquarantine&lt;/code&gt;, and the agent gets work again. The desk won't quarantine an agent that is the only one serving a skill, since those steps would then have no agent to run them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dead letters and redrive.&lt;/strong&gt; SMS gateway down makes the next notify step fail. The customer agent retries it, and when the retries run out the SDK gives up on the message and calls the agent's &lt;code&gt;dead_letter&lt;/code&gt; hook. The hook parks the message in KV, where the desk shows it. Fix and redrive clears the fault and calls &lt;code&gt;laser.redrive_dead_letter&lt;/code&gt;, which puts the original message back on the log, and the customer agent handles it again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contracts.&lt;/strong&gt; A contract sends one request to one agent and waits for a single answer: the agent finished it, it failed, no agent picked it up, or the deadline passed. At the end of the day dispatch uses one to ask for the invoice check, with &lt;code&gt;laser.contract("invoice-check", ...)&lt;/code&gt;. The request is addressed to the &lt;code&gt;invoice-check&lt;/code&gt; skill rather than to the invoice agent by name, and the registry works out which agent receives it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forks.&lt;/strong&gt; A &lt;a href="https://docs.laserdata.com/laser-sdk/advanced/state" rel="noopener noreferrer"&gt;fork&lt;/a&gt; is a separate copy of the views that you can add rows to and query without changing the real views. It stores only the rows you add, and everything else comes from the real views. The invoice agent uses one to show exactly what a carrier's bill is charging for. With the overbilled invoice, the bill charges for two drops and 6 km more on one van than the log shows. The agent creates a fork with &lt;code&gt;laser.fork&lt;/code&gt;, adds those drops and kilometres to it as rows with &lt;code&gt;put_row&lt;/code&gt;, and runs its usual drop and kilometre totals against the fork with &lt;code&gt;query(...).fork(id)&lt;/code&gt;. If the fork's totals now match the bill, the added rows are exactly the work the carrier charged for that the log has no record of. Once the desk has approved or declined the dispute, the agent deletes the fork with &lt;code&gt;squash&lt;/code&gt;, so those rows never reach the real views.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approval gate.&lt;/strong&gt; Before disputing a bill, the invoice agent calls &lt;code&gt;ctx.approval_gate&lt;/code&gt; with a prompt that names the van, what the carrier billed, what the log shows, and the amount to hold. The SDK publishes the prompt to a topic for human input, and the handler waits until a person approves or declines on the desk in the browser. The decision comes back to the agent as a reply on the log.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkwnef2jid86vcvpzg2cm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkwnef2jid86vcvpzg2cm.jpg" alt="The invoice agent waiting on the desk: van-3 billed for 11 drops and 47.0 km against 9 drops and 41.0 km on the log" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The invoice agent waiting on the desk: van-3 billed for 11 drops and 47.0 km against 9 drops and 41.0 km on the log&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Memory.&lt;/strong&gt; The customer agent remembers every delay and missed drop for each customer on a &lt;a href="https://docs.laserdata.com/laser-sdk/memory" rel="noopener noreferrer"&gt;memory&lt;/a&gt; topic, in a stream of its own that a new day doesn't reset. When the same customer is affected again, on any day, the agent recalls their history and adds a line to the message, such as "Sorry, this is the second time we've been late to you, and we've flagged it." The same incident always produces the same memory record, so remembering it again after a redelivery doesn't add a duplicate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replay.&lt;/strong&gt; Rewind, under the map, shows the day as it was at any minute, built only from the log. For each of the two topics it opens a new cursor with &lt;code&gt;laser.topic(...).replay()&lt;/code&gt;, which starts at the first record, and polls it until it has read every record, using nothing from KV or the server's memory. It then groups the van positions by minute on the demo's clock, keeping each van's last position in that minute, and tags every event with the minute it happened in. The browser gets one frame per minute, and dragging the slider shows where each van was, which drops had been made and what the agents were doing at that point.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3x785b8mnvppme0fe4wy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3x785b8mnvppme0fe4wy.jpg" alt="Rewind at 10:01, with the day rebuilt from 2,160 records on the log" width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Rewind at 10:01, with the day rebuilt from 2,160 records on the log&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Queries.&lt;/strong&gt; The views are tables that Laser Stack keeps up to date from the topics. At startup the demo registers two of them by naming the fields to take from each JSON record: &lt;code&gt;fleet_events&lt;/code&gt; has a row per event with its van, stop, kind, agent, step and state, and &lt;code&gt;fleet_positions&lt;/code&gt; has a row per position report with the van, its status and the metres it has driven so far. Queries on a view are built from calls such as &lt;code&gt;where_eq&lt;/code&gt;, &lt;code&gt;count&lt;/code&gt;, &lt;code&gt;max&lt;/code&gt; and &lt;code&gt;group_by&lt;/code&gt;. This one counts the delivered drops for each van:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;laser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fleet_events"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;where_eq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"kind"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"delivered"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"van"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The kilometres for each van come from the highest &lt;code&gt;metres&lt;/code&gt; value it has reported, using &lt;code&gt;max&lt;/code&gt; instead of &lt;code&gt;count&lt;/code&gt;. The invoice agent checks the carrier's bill against totals like these. The Readers panel in the browser uses the same kind of query to show drops and kilometres per van, steps per agent, kills and replays, and one of the end-of-day checks counts deliveries per stop to make sure no parcel was delivered twice.&lt;/p&gt;

&lt;p&gt;The code and the README are at &lt;a href="https://github.com/laserdata/laser-delivery-desk" rel="noopener noreferrer"&gt;laserdata/laser-delivery-desk&lt;/a&gt;, and Laser SDK is at &lt;a href="https://github.com/laserdata/laser-sdk" rel="noopener noreferrer"&gt;laserdata/laser-sdk&lt;/a&gt;, with its docs at &lt;a href="https://docs.laserdata.com/laser-sdk" rel="noopener noreferrer"&gt;docs.laserdata.com/laser-sdk&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>python</category>
      <category>distributedsystems</category>
    </item>
    <item>
      <title>Real-Time Analytics Benchmark: Apache Iggy vs Kafka into VeloDB Cloud</title>
      <dc:creator>Pallavi Singla</dc:creator>
      <pubDate>Wed, 25 Nov 2026 13:17:14 +0000</pubDate>
      <link>https://dev.to/laserdatainc/real-time-analytics-benchmark-apache-iggy-vs-kafka-into-velodb-cloud-2o0h</link>
      <guid>https://dev.to/laserdatainc/real-time-analytics-benchmark-apache-iggy-vs-kafka-into-velodb-cloud-2o0h</guid>
      <description>&lt;p&gt;&lt;em&gt;This post first appeared on the &lt;a href="https://laserdata.com/blog/real-time-streaming-analytics-iggy-velodb-benchmark" rel="noopener noreferrer"&gt;LaserData blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most streaming benchmarks stop at the broker. That is useful, but it is not the whole story for real-time analytics.&lt;/p&gt;

&lt;p&gt;The thing users actually feel is not "messages accepted by a broker." It is when an event becomes queryable, when a dashboard reflects the new state, when an alert has enough fresh context to fire, or when an application can make a decision from data that just arrived.&lt;/p&gt;

&lt;p&gt;That is why the recent &lt;a href="https://github.com/velodb/velodb-demos/tree/main/iggy/bench" rel="noopener noreferrer"&gt;VeloDB benchmark for Apache Iggy and Kafka&lt;/a&gt; is interesting. It measures two layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Layer 1:&lt;/strong&gt; broker-only throughput and latency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer 2:&lt;/strong&gt; end-to-end latency from event creation through broker, connector, VeloDB Stream Load, and queryable row.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The benchmark keeps the workload, region, payload, hardware class, target table, and analytics backend fixed. The broker and connector path are the variables. That makes it a useful case study in a question that comes up often: when you replace a traditional broker with a latency-first engine, how much of that advantage survives contact with the rest of the ingestion pipeline?&lt;/p&gt;

&lt;p&gt;The short answer: the broker advantage is large, and the end-to-end advantage shows up where it matters most, in the tail.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;The benchmark sends clickstream events into VeloDB Cloud through two comparable pipelines:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pipeline&lt;/th&gt;
&lt;th&gt;Broker&lt;/th&gt;
&lt;th&gt;Connector path&lt;/th&gt;
&lt;th&gt;Analytics backend&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Iggy to VeloDB&lt;/td&gt;
&lt;td&gt;Apache Iggy&lt;/td&gt;
&lt;td&gt;Iggy connector to VeloDB Stream Load&lt;/td&gt;
&lt;td&gt;VeloDB Cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kafka to VeloDB&lt;/td&gt;
&lt;td&gt;Apache Kafka&lt;/td&gt;
&lt;td&gt;Kafka Connect Doris sink to VeloDB Stream Load&lt;/td&gt;
&lt;td&gt;VeloDB Cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The workload is intentionally realistic rather than synthetic-only. Layer 2 uses nested clickstream JSON with fields such as &lt;code&gt;device_info&lt;/code&gt;, &lt;code&gt;event_properties&lt;/code&gt;, and &lt;code&gt;utm_params&lt;/code&gt;, streamed at a steady &lt;strong&gt;2,000 events per second&lt;/strong&gt;. Each event carries its creation timestamp, and VeloDB stamps &lt;code&gt;ingest_time&lt;/code&gt; when the row becomes queryable. The latency query compares those two timestamps inside VeloDB.&lt;/p&gt;

&lt;p&gt;The hardware is also disclosed:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Instance&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Streaming broker&lt;/td&gt;
&lt;td&gt;AWS EC2 c6id.4xlarge&lt;/td&gt;
&lt;td&gt;16 vCPU, 32 GB memory, local NVMe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Event source&lt;/td&gt;
&lt;td&gt;AWS EC2 c7i.2xlarge&lt;/td&gt;
&lt;td&gt;8 vCPU, 16 GB memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Analytics backend&lt;/td&gt;
&lt;td&gt;VeloDB Cloud&lt;/td&gt;
&lt;td&gt;4-core FE demo configuration&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Everything runs in AWS &lt;code&gt;us-east-1&lt;/code&gt;. The broker runs are back-to-back on the same machine.&lt;/p&gt;

&lt;p&gt;That last detail matters. Benchmarks often become arguments about benchmark shape. This one is explicit about the shape: same workload, same target table, same region, same hardware, same VeloDB backend, and standard connector paths for each broker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer 1: raw broker capability
&lt;/h2&gt;

&lt;p&gt;First, the benchmark isolates the broker. No database. No connector. Just sustained broker throughput and latency with 256-byte messages, batches of 1,000, and 8 parallel producers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Iggy&lt;/th&gt;
&lt;th&gt;Kafka&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Throughput&lt;/td&gt;
&lt;td&gt;1,232 MB/s&lt;/td&gt;
&lt;td&gt;371 MB/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Messages per second&lt;/td&gt;
&lt;td&gt;4.81M&lt;/td&gt;
&lt;td&gt;1.52M&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p50 latency&lt;/td&gt;
&lt;td&gt;1.7 ms&lt;/td&gt;
&lt;td&gt;3 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99 latency&lt;/td&gt;
&lt;td&gt;2.5 ms&lt;/td&gt;
&lt;td&gt;~40 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99.9 latency&lt;/td&gt;
&lt;td&gt;2.8 ms&lt;/td&gt;
&lt;td&gt;~80 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The headline is straightforward: Iggy delivered roughly &lt;strong&gt;3x the throughput&lt;/strong&gt; and about &lt;strong&gt;16x lower p99 latency&lt;/strong&gt; than Kafka in this broker-only run.&lt;/p&gt;

&lt;p&gt;The more important number is the shape of the tail. Iggy held p99.9 at about &lt;strong&gt;2.8 ms&lt;/strong&gt;. Kafka reached roughly &lt;strong&gt;80 ms&lt;/strong&gt; at p99.9. For systems that coordinate real-time analytics, alerts, operational automation, or agentic workflows, that difference is not cosmetic. It changes how much uncertainty the rest of the pipeline has to absorb.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Iggy behaves differently
&lt;/h2&gt;

&lt;p&gt;Iggy is built around a thread-per-core, shared-nothing execution model. Each core owns a shard and does useful work without cross-core locking on the hot path. It is also native Rust, so there is no JVM garbage collector sitting in the latency profile.&lt;/p&gt;

&lt;p&gt;The other major piece is &lt;code&gt;io_uring&lt;/code&gt;. Instead of paying for a syscall per network or disk operation, Iggy submits and completes I/O through per-core ring buffers shared with the kernel. The benchmark ran Iggy as a raw binary with local NVMe, XFS, hugepages, &lt;code&gt;mimalloc&lt;/code&gt;, and a mainline Linux kernel configured for Iggy's &lt;code&gt;io_uring&lt;/code&gt; path.&lt;/p&gt;

&lt;p&gt;That sounds low-level because it is. But the practical consequence is simple: the broker spends less time coordinating around itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg54f8gsc22r2qfwofcjw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg54f8gsc22r2qfwofcjw.gif" alt="Runtime visualization of Apache Iggy under load, showing 8 shards pinned to CPU cores, io_uring activity, and NVMe write throughput." width="719" height="405"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Iggy under load in the VeloDB benchmark: shards pinned to cores, per-core io_uring activity, and NVMe write throughput.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the part of the architecture that matters for tail latency. A broker can have good average latency while still injecting periodic stalls into the pipeline. Iggy's design is aimed at making that tail predictable under load.&lt;/p&gt;
&lt;h2&gt;
  
  
  Layer 2: event to queryable row
&lt;/h2&gt;

&lt;p&gt;Layer 2 is the more useful test for real-time analytics. It measures the full path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;event -&amp;gt; broker -&amp;gt; connector -&amp;gt; VeloDB Stream Load -&amp;gt; queryable row
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At &lt;strong&gt;2,000 events per second&lt;/strong&gt;, both connector paths kept up with the workload. That means the measurement is not a backlog test. It is a steady-state freshness test.&lt;/p&gt;

&lt;p&gt;Here are the end-to-end results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Percentile&lt;/th&gt;
&lt;th&gt;Iggy to VeloDB&lt;/th&gt;
&lt;th&gt;Kafka to VeloDB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;p50&lt;/td&gt;
&lt;td&gt;577 ms&lt;/td&gt;
&lt;td&gt;789 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p90&lt;/td&gt;
&lt;td&gt;1,011 ms&lt;/td&gt;
&lt;td&gt;1,646 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99&lt;/td&gt;
&lt;td&gt;1,232 ms&lt;/td&gt;
&lt;td&gt;3,588 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99.9&lt;/td&gt;
&lt;td&gt;1,346 ms&lt;/td&gt;
&lt;td&gt;10,022 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;max&lt;/td&gt;
&lt;td&gt;1,412 ms&lt;/td&gt;
&lt;td&gt;10,247 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The median story is useful, but not decisive. Both pipelines are in the sub-second range at p50, and both medians are largely shaped by connector flush behavior.&lt;/p&gt;

&lt;p&gt;The tail is decisive.&lt;/p&gt;

&lt;p&gt;The Iggy pipeline stayed near &lt;strong&gt;1.3 seconds at p99.9&lt;/strong&gt; and topped out at &lt;strong&gt;1.4 seconds&lt;/strong&gt;. The Kafka pipeline reached roughly &lt;strong&gt;10 seconds at p99.9&lt;/strong&gt; and max. That is about a &lt;strong&gt;7x heavier end-to-end tail&lt;/strong&gt; for Kafka in this benchmark.&lt;/p&gt;

&lt;p&gt;This is the result that matters for production systems. Real-time analytics does not fail only when the average gets bad. It fails when freshness becomes unpredictable, when the 99th percentile silently becomes the user experience for the workflow that happens to land in the wrong window.&lt;/p&gt;

&lt;h2&gt;
  
  
  VeloDB was not the bottleneck
&lt;/h2&gt;

&lt;p&gt;One of the cleaner findings in the write-up is that VeloDB was not the limiting factor in this run. The benchmark used a modest 4-core VeloDB FE demo configuration, and a single Stream Load commit completed in roughly &lt;strong&gt;170 ms&lt;/strong&gt; with headroom above the test rate.&lt;/p&gt;

&lt;p&gt;The end-to-end latency was dominated by connector micro-batch cadence and broker behavior, not by VeloDB ingest capacity.&lt;/p&gt;

&lt;p&gt;That distinction matters. If the database is saturated, broker comparisons get muddy. Here, the backend had room, so the pipeline exposed the difference between a low-tail broker path and a coarser commit-batched connector path.&lt;/p&gt;

&lt;p&gt;The write-up also notes that VeloDB can scale vertically and horizontally into the &lt;strong&gt;10 to 30 million rows per second&lt;/strong&gt; range, or &lt;strong&gt;60 to 90 GB/s&lt;/strong&gt;, when scaled out. This test was not trying to find that ceiling. It was testing query-ready freshness on a realistic streaming path.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this means for streaming analytics teams
&lt;/h2&gt;

&lt;p&gt;The lesson is not simply "one broker is faster." The more useful lesson is that broker architecture still matters even when the real application includes connectors, database commits, and queryable storage.&lt;/p&gt;

&lt;p&gt;For dashboards, observability pipelines, personalization systems, fraud checks, operational alerting, and AI systems that consume fresh business events, the budget is usually not owned by one component. It is shared across the whole path. If the broker injects jitter, every component after it has to live with that jitter.&lt;/p&gt;

&lt;p&gt;In this benchmark, Iggy created more headroom at the broker layer and preserved a much tighter tail through the VeloDB ingestion path. That is exactly the shape we want from a streaming substrate for real-time analytics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;enough throughput that the broker is not the first ceiling;&lt;/li&gt;
&lt;li&gt;low p99 and p99.9 latency, not just good averages;&lt;/li&gt;
&lt;li&gt;predictable freshness once events become queryable;&lt;/li&gt;
&lt;li&gt;a path that uses standard ingestion interfaces instead of custom benchmark-only shortcuts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last point is important. The benchmark used VeloDB Stream Load and standard connector paths. The result is not a microbenchmark trapped in the lab. It is closer to the architecture teams actually deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limitations
&lt;/h2&gt;

&lt;p&gt;The benchmark is careful about its own boundaries, and those boundaries are worth keeping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VeloDB backend was a 4-core demo configuration, not a scaled-out throughput test.&lt;/li&gt;
&lt;li&gt;The run used one region and one broker node.&lt;/li&gt;
&lt;li&gt;The Layer 2 test was steady-state and below saturation; it did not characterize overload behavior.&lt;/li&gt;
&lt;li&gt;The Iggy connector was still young and used a serial Stream Load path, while Kafka Connect used parallel tasks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point cuts in an interesting direction. The Iggy end-to-end path was not advantaged by connector maturity. The broker was strong enough, and the tail predictable enough, that the full path still came out tighter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;The VeloDB benchmark is a useful snapshot of where streaming analytics is headed. The backend can ingest and make data queryable quickly. The broker layer is where latency predictability can either be preserved or lost.&lt;/p&gt;

&lt;p&gt;In the broker-only layer, Iggy delivered roughly &lt;strong&gt;~3x throughput&lt;/strong&gt; and &lt;strong&gt;~30x lower p99 latency&lt;/strong&gt; than Kafka. In the full VeloDB ingestion path, the Iggy pipeline held p99.9 near &lt;strong&gt;1.3 seconds&lt;/strong&gt;, while the Kafka pipeline reached above &lt;strong&gt;10 seconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For teams building systems where fresh data drives decisions, the result is the thing that matters most: not just faster ingestion, but a tighter freshness envelope.&lt;/p&gt;

&lt;p&gt;That is the direction we are building for at LaserData Cloud: managed Apache Iggy for teams that need streaming infrastructure to be fast, open, and predictable enough for real-time analytics and AI-era data systems.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>kafka</category>
      <category>performance</category>
      <category>streaming</category>
    </item>
    <item>
      <title>Consumer Filters: Stop Moving Data You Do Not Need</title>
      <dc:creator>Pallavi Singla</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:18:29 +0000</pubDate>
      <link>https://dev.to/laserdatainc/consumer-filters-stop-moving-data-you-do-not-need-5a7m</link>
      <guid>https://dev.to/laserdatainc/consumer-filters-stop-moving-data-you-do-not-need-5a7m</guid>
      <description>&lt;p&gt;&lt;em&gt;This post first appeared on the &lt;a href="https://laserdata.com/blog/consumer-filters-stop-moving-data-you-do-not-need" rel="noopener noreferrer"&gt;LaserData blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Most data platforms spend too much money moving data that applications immediately discard.&lt;/p&gt;

&lt;p&gt;A change data capture feed might carry every update from every table, while a fraud service needs only high-value order changes. An operations desk might care about four event types in a topic containing hundreds. A backfill might need 2% of a year-long stream. In the usual architecture, each consumer downloads the full feed, deserializes every record, applies its own conditions, and throws almost everything away.&lt;/p&gt;

&lt;p&gt;That waste compounds as the business grows. More consumers mean more network transfer, more application CPU, more memory pressure, more autoscaling, and often more derived topics created only to route subsets of the same data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.laserdata.com/laser-sdk/consumer-filters" rel="noopener noreferrer"&gt;Consumer filters in the Laser SDK&lt;/a&gt; change where that work happens. The consumer declares what it needs. LaserData evaluates the policy beside the durable log and returns only matching records across the network.&lt;/p&gt;

&lt;p&gt;The idea is simple. Its effect on the cost, latency, and design of a streaming platform is not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoe3hdmx7bxvarp9l406.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzoe3hdmx7bxvarp9l406.png" alt="High-level architecture showing producers writing a complete feed to one durable LaserData topic, where server-side filters deliver different matching subsets to fraud, operations, and audit consumer groups." width="799" height="455"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;One durable source topic can serve multiple selective consumer groups. Matching records cross the network. Everything else remains available in the replayable log.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The executive case: make data movement proportional to business value
&lt;/h2&gt;

&lt;p&gt;Streaming costs are not limited to storage. Every record a consumer does not need can still create costs across the system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The hidden cost of client-side rejection&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The record is discarded last. The infrastructure bill starts first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Server egress&lt;/li&gt;
&lt;li&gt;Cross-zone traffic&lt;/li&gt;
&lt;li&gt;Consumer compute&lt;/li&gt;
&lt;li&gt;Decoding&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Retries&lt;/li&gt;
&lt;li&gt;Operations&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Client-side filtering pays most of that bill before deciding that a record is irrelevant. Server-side filtering moves the decision to the point where the data already lives.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/laserdata/laser-sdk/tree/main/examples/rust/src/cdc" rel="noopener noreferrer"&gt;complete Rust CDC example&lt;/a&gt; makes the difference concrete. It publishes a mixed satellite operations feed containing battery readings, maneuvers, ground-station changes, safe-mode events, and decommissions. The anomaly desk needs only safe-mode and decommission events.&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measure&lt;/th&gt;
&lt;th&gt;Full feed&lt;/th&gt;
&lt;th&gt;Filtered delivery&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Records&lt;/td&gt;
&lt;td&gt;240&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payload bytes&lt;/td&gt;
&lt;td&gt;27,953&lt;/td&gt;
&lt;td&gt;424&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Payload transfer avoided&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;td&gt;98.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1461y8qii0454obpazh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1461y8qii0454obpazh6.png" alt="Comparison of client-side and server-side filtering in the Rust CDC example: 27,953 payload bytes and 240 records versus 424 bytes and four matching records, avoiding 98.5 percent of payload transfer." width="799" height="455"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;The reference CDC workload delivers the same four useful records while avoiding 98.5% of payload transfer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a deliberately small, reproducible example, not a projection from a spreadsheet. The &lt;a href="https://github.com/laserdata/laser-example-frostline" rel="noopener noreferrer"&gt;Frostline example&lt;/a&gt; runs a larger CDC workload: ten million change records, 6.30 GB of payload, and four filtered consumer groups. In its recorded run, the groups received 777.64 MB instead of the 25.21 GB that four full-feed reads would move, avoiding 96.9% of payload transfer. Counting both TCP directions at the socket, application traffic fell from 31.40 GB to 1.11 GB, a 96.5% reduction. That run predates the group-owned filter API of Laser SDK 0.5.1, and the repository publishes the whole benchmark, including server CPU and latency.&lt;/p&gt;

&lt;p&gt;The exact savings depend on how selective each policy is. The architectural implication is broader: network and downstream processing can scale with the records that create value for a consumer, rather than with the total volume retained in the source stream.&lt;/p&gt;

&lt;p&gt;For a CTO or VP of Engineering, that creates four forms of leverage.&lt;/p&gt;
&lt;h3&gt;
  
  
  Lower unit cost without weakening the event backbone
&lt;/h3&gt;

&lt;p&gt;Teams can keep a complete, replayable source of truth while reducing the bytes delivered to selective consumers. They do not have to trade retention and optionality for a smaller application footprint.&lt;/p&gt;
&lt;h3&gt;
  
  
  Fewer routing pipelines to own
&lt;/h3&gt;

&lt;p&gt;Without server-side filters, organizations often add a stream processor or create intermediate topics for every audience: fraud events, premium-customer events, compliance events, operational alerts, and regional subsets. Each new branch adds configuration, capacity planning, monitoring, access rules, retention, and failure recovery.&lt;/p&gt;

&lt;p&gt;Consumer filters let multiple groups follow different subsets of one durable topic. The log remains shared. Delivery policy varies by consumer group.&lt;/p&gt;
&lt;h3&gt;
  
  
  Better economics for cloud and hybrid architectures
&lt;/h3&gt;

&lt;p&gt;Filtering before transfer matters when a producer and consumer sit in different availability zones, regions, clouds, or trust zones. It also matters for branch locations and edge environments where bandwidth is finite. Avoided bytes reduce both infrastructure load and the amount of data crossing expensive boundaries.&lt;/p&gt;
&lt;h3&gt;
  
  
  Faster delivery of new use cases
&lt;/h3&gt;

&lt;p&gt;A new consumer can declare a policy against an existing feed instead of waiting for a new routing service and topic hierarchy. That shortens the path from a business question to a production data product. It also reduces the number of permanent components created for temporary experiments.&lt;/p&gt;
&lt;h2&gt;
  
  
  The architecture: one log, many selective views of motion
&lt;/h2&gt;

&lt;p&gt;A filtered reader asks for a page from a topic partition. The server scans source records, evaluates the consumer's declarative filter, and returns the matches. Nonmatching records stay on the server.&lt;/p&gt;

&lt;p&gt;Matching records are not rewritten. They keep their original offset, message ID, timestamp, headers, and payload bytes. Applications can continue to use their existing typed decoders, audit identifiers, and replay logic.&lt;/p&gt;

&lt;p&gt;This distinction is important. A consumer filter is not a materialized copy and does not create a second stream of transformed records. It is a delivery policy over the durable log.&lt;/p&gt;

&lt;p&gt;Each group maintains its own progress. One group can be selective without changing what another group reads or what the topic retains.&lt;/p&gt;
&lt;h2&gt;
  
  
  What happens to latency
&lt;/h2&gt;

&lt;p&gt;Moving less data is usually good for end-to-end efficiency, but it is useful to be precise about where the gains come from.&lt;/p&gt;

&lt;p&gt;A filtered consumer can avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;transferring rejected payloads&lt;/li&gt;
&lt;li&gt;allocating memory for them in the application&lt;/li&gt;
&lt;li&gt;decoding and validating them downstream&lt;/li&gt;
&lt;li&gt;running application-level rejection logic&lt;/li&gt;
&lt;li&gt;passing them through additional internal pipelines or services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That can reduce consumer CPU time, network wait, garbage collection in managed runtimes, and the time between receiving a relevant record and acting on it. It can also reduce contention when many selective consumers share the same source.&lt;/p&gt;

&lt;p&gt;Filtering is not free. The streaming server still examines records for each reader. Payload predicates require decoding work on the server, and a very sparse filter may scan many source records before finding enough matches to fill a page. LaserData therefore keeps match limits and scan budgets explicit.&lt;/p&gt;

&lt;p&gt;The Frostline run shows the trade. Reader CPU fell from 66.78 to 5.91 seconds, while streaming server CPU rose from 31.32 to 99.50 seconds, so combined CPU rose by about 9.5%. On local loopback, where network transfer costs almost nothing, the filtered read phase took 29.97 seconds against 23.38 seconds for ordinary readers. Filtering pays off when network bytes, consumer compute, or downstream work cost more than the extra scanning on the server.&lt;/p&gt;

&lt;p&gt;The least expensive route is often a typed header. A header-only predicate never parses the payload. On a JSON payload, parsing costs more than the comparison itself, so a header test costs much less than a field or text predicate. The SDK ships &lt;code&gt;filter_evaluation&lt;/code&gt; and &lt;code&gt;filter_paths&lt;/code&gt; benchmarks to measure this on your own records. Record size, codec, expression shape, selectivity, storage, and deployment topology all matter.&lt;/p&gt;

&lt;p&gt;A practical design rule is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Put a stable routing field such as &lt;code&gt;event.type&lt;/code&gt;, tenant, region, or priority in a typed header.&lt;/li&gt;
&lt;li&gt;Reject unrelated records with a header predicate first.&lt;/li&gt;
&lt;li&gt;Add payload predicates only when the header match is not specific enough.&lt;/li&gt;
&lt;li&gt;Benchmark with the real record distribution, including p99 and p99.9 behavior.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In an &lt;code&gt;all&lt;/code&gt; expression, header conditions run first and evaluation stops at the first non-match. That lets a mixed-format topic reject most unrelated records without decoding their payloads.&lt;/p&gt;
&lt;h2&gt;
  
  
  A filter is a policy, not application code on the server
&lt;/h2&gt;

&lt;p&gt;LaserData filters are declarative. Consumers do not upload executable code into the data plane. They compose bounded expressions from a defined set of operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;comparisons such as &lt;code&gt;eq&lt;/code&gt;, &lt;code&gt;ne&lt;/code&gt;, &lt;code&gt;lt&lt;/code&gt;, &lt;code&gt;lte&lt;/code&gt;, &lt;code&gt;gt&lt;/code&gt;, &lt;code&gt;gte&lt;/code&gt;, &lt;code&gt;in&lt;/code&gt;, &lt;code&gt;contains&lt;/code&gt;, and &lt;code&gt;prefix&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;text operations including equals, prefix, suffix, contains, glob, and regex&lt;/li&gt;
&lt;li&gt;typed-header comparisons&lt;/li&gt;
&lt;li&gt;presence and absence tests&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;all&lt;/code&gt;, &lt;code&gt;any&lt;/code&gt;, and &lt;code&gt;not&lt;/code&gt; composition&lt;/li&gt;
&lt;li&gt;explicit coercion for values such as timestamp and decimal strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Payload filtering supports JSON, CBOR, Avro, and Protobuf. Avro and Protobuf use registered writer schemas. A &lt;code&gt;headers_only&lt;/code&gt; filter works with any payload format because it never decodes the body.&lt;/p&gt;

&lt;p&gt;This gives architects room to use the same mechanism across CDC, event routing, backfills, alerting, and mixed-format integration topics without embedding a general-purpose runtime inside the streaming server.&lt;/p&gt;
&lt;h2&gt;
  
  
  From a CDC requirement to a group policy in Rust, Python, and TypeScript
&lt;/h2&gt;

&lt;p&gt;Suppose a commerce change feed contains every order update, but a risk service needs only orders whose new total is at least 10,000. The same filter can be attached when the consumer group is created in Rust, Python, or TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;laser_sdk&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;filters&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nc"&gt;ConsumerFilter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FilterExpr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FilteredStart&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;laser_sdk&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;prelude&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;full&lt;/span&gt;&lt;span class="o"&gt;::*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="n"&gt;laser_sdk&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;CmpOp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;risk_policy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ConsumerFilter&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;FilterExpr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="nc"&gt;FilterExpr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;pred&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"table"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CmpOp&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Eq&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"orders"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;FilterExpr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;pred&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"op"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CmpOp&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Eq&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"u"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nc"&gt;FilterExpr&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;pred&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"after.total"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CmpOp&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Gte&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10_000_i64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;group&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;laser&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"commerce"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"commerce_cdc"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;consumer_group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"risk-review"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;risk_policy&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;group&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;FilteredStart&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;First&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three build the same definition with the same digest, so the idempotent setup can run from any of them. After setup, members can join by group name or ID. They do not need to repeat the filter definition. The group owns the delivery policy, and native partition assignment still distributes work among members.&lt;/p&gt;

&lt;p&gt;That separation is useful for platform teams. Application code expresses how to process a qualifying event. The group binding defines which events qualify.&lt;/p&gt;

&lt;h2&gt;
  
  
  The CDC example shows more than byte savings
&lt;/h2&gt;

&lt;p&gt;The Rust example is worth reading because it exercises the operational lifecycle, not only the happy path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Evidence of change, not only current value
&lt;/h3&gt;

&lt;p&gt;The transition branch of the satellite policy does not merely ask whether &lt;code&gt;after.mode&lt;/code&gt; equals &lt;code&gt;safe&lt;/code&gt;. It also requires the producer-supplied &lt;code&gt;changed&lt;/code&gt; list to contain &lt;code&gt;mode&lt;/code&gt;. A battery update for a satellite already in safe mode therefore does not look like a new transition. The policy's other branches select decommissions and telemetry reports of safe mode, which carry no such evidence.&lt;/p&gt;

&lt;p&gt;This is a critical CDC design choice. A filter evaluates one record at a time. It does not infer a prior row version by searching the log. If a consumer needs evidence that a specific column changed, the producer or CDC envelope should carry that evidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Header-only routing for opaque events
&lt;/h3&gt;

&lt;p&gt;The example publishes binary alerts with a numeric &lt;code&gt;priority&lt;/code&gt; header. A pager group selects critical alerts without decoding their bodies. That pattern works for encrypted, proprietary, or mixed-codec payloads as long as producers stamp trustworthy routing metadata.&lt;/p&gt;

&lt;h3&gt;
  
  
  The same policy model across codecs
&lt;/h3&gt;

&lt;p&gt;The example publishes typed records in CBOR, Avro, and Protobuf, then applies a field predicate to each. The consumer receives the original encoded bytes and decodes them using its normal schema-aware path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test and preview before consumers read
&lt;/h3&gt;

&lt;p&gt;Once a group holds its policy, teams can test that policy against a supplied sample record or preview it against a bounded range of stored records in one partition. Neither operation joins the group or advances an offset, so verdicts and match rates can be inspected before any consumer starts reading. Before a group exists, the SDK's local evaluator gives the same verdict for a sample record without a server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Controlled revisions instead of silent policy drift
&lt;/h3&gt;

&lt;p&gt;Saved filters have immutable revisions. The example drafts a stricter revision while the group keeps running its active one, then runs the stricter definition in a separate A/B group. It pauses the variant's revision, acknowledges in-flight work, resumes it, and shows that a group running one policy refuses another with &lt;code&gt;conflict&lt;/code&gt; instead of switching predicates over the same offsets.&lt;/p&gt;

&lt;p&gt;This is more than configuration hygiene. If two different filters shared progress, one version could advance past records required by the other. Separate groups and immutable revisions keep delivery semantics explicit and reviewable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F485al5wm4c2bza78w8mh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F485al5wm4c2bza78w8mh.png" alt="Consumer filter policy lifecycle from definition through an immutable group binding, testing and preview, observation, and a drafted revision, with a separate consumer group running the revised definition for A/B comparison." width="799" height="455"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Policy changes are explicit: bind an immutable revision, test and preview it before consumers read, and run a new predicate in a separate group.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Safe progress across records that never arrive
&lt;/h2&gt;

&lt;p&gt;Filtering creates a subtle offset problem: how does a consumer make progress across source records it never receives?&lt;/p&gt;

&lt;p&gt;LaserData tracks both delivered work and the range examined by the server. Empty pages can advance their scanned range automatically. For pages with matches, the reader lets application work finish and stores only the offset through which every returned record is complete. Applications can process returned records out of order without committing past unfinished work.&lt;/p&gt;

&lt;p&gt;The reader also bounds unacknowledged record-bearing pages per partition. If that bound is reached, it stops reading the partition until work is acknowledged rather than allowing read-ahead memory to grow without limit.&lt;/p&gt;

&lt;p&gt;These mechanics preserve the properties enterprises depend on from consumer groups: resumability, replay, partition ownership, bounded memory, and deliberate acknowledgment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design tradeoffs architects should make explicit
&lt;/h2&gt;

&lt;p&gt;Consumer filters remove an entire class of avoidable data movement, but they should be treated as an engineered policy layer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selectivity determines the return
&lt;/h3&gt;

&lt;p&gt;A consumer that needs 95% of a topic will save far less than one that needs 1%. Measure payload bytes, not only record counts. A small number of large records can dominate transfer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Put cheap predicates first
&lt;/h3&gt;

&lt;p&gt;Prefer typed headers for coarse routing and payload fields for precise decisions. This is especially important for topics that mix codecs or event families.&lt;/p&gt;

&lt;h3&gt;
  
  
  Define malformed-record behavior
&lt;/h3&gt;

&lt;p&gt;A payload that cannot be decoded is a fault, not a normal non-match. The filter can stop, pass the record through as unevaluated, or drop it. The right choice depends on whether continuity, quarantine, or strict correctness is the priority.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep authorization separate
&lt;/h3&gt;

&lt;p&gt;A consumer filter is a delivery policy, not an access-control boundary. Use topic permissions and deployment authorization to control which principals may read data at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  Treat policy changes like schema changes
&lt;/h3&gt;

&lt;p&gt;Version them, preview them, test representative samples, run variants in separate groups, observe their match rates and latency, and roll them out deliberately.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where consumer filters fit best
&lt;/h2&gt;

&lt;p&gt;The strongest candidates are workloads where one durable feed serves multiple narrow interests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CDC feeds shared by search indexing, fraud, analytics, cache invalidation, and audit consumers&lt;/li&gt;
&lt;li&gt;operational alert streams routed by severity, service, tenant, or region&lt;/li&gt;
&lt;li&gt;large backfills where a repair job needs only a small historical subset&lt;/li&gt;
&lt;li&gt;agent and automation systems that react to specific tool results, state transitions, or exceptions&lt;/li&gt;
&lt;li&gt;multi-tenant event platforms where services consume only their assigned domain&lt;/li&gt;
&lt;li&gt;edge or cross-region consumers with constrained or expensive bandwidth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The common pattern is high source volume, low matching fraction, and several consumers with different definitions of relevance.&lt;/p&gt;

&lt;h2&gt;
  
  
  The larger platform decision
&lt;/h2&gt;

&lt;p&gt;For years, streaming platforms have made it normal to move a complete dataset into every application and ask each team to reduce it locally. That approach is simple at the beginning. At enterprise scale, it turns relevance into repeated infrastructure work.&lt;/p&gt;

&lt;p&gt;Consumer filters make a different trade: keep one complete, durable log, but move only the records each consumer can act on.&lt;/p&gt;

&lt;p&gt;For engineering leaders, that means lower transfer costs, less consumer compute, fewer derived pipelines, and a platform that can support more use cases without multiplying infrastructure. For lead engineers and architects, it means declarative server-side selection with original offsets, typed payloads, consumer-group progress, testable policies, and controlled revisions.&lt;/p&gt;

&lt;p&gt;The goal is not to make the streaming server do arbitrary application work. It is to stop every application from paying to receive data it already knows it does not need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.laserdata.com/laser-sdk/consumer-filters" rel="noopener noreferrer"&gt;&lt;strong&gt;Read the consumer filters guide →&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/laserdata/laser-sdk/tree/main/examples/rust/src/cdc" rel="noopener noreferrer"&gt;&lt;strong&gt;Explore the complete Rust CDC example →&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/laserdata/laser-example-frostline" rel="noopener noreferrer"&gt;&lt;strong&gt;See the Frostline benchmark →&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dataengineering</category>
      <category>streaming</category>
      <category>cdc</category>
      <category>rust</category>
    </item>
  </channel>
</rss>
