<?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: Tailcove</title>
    <description>The latest articles on DEV Community by Tailcove (@tailcove).</description>
    <link>https://dev.to/tailcove</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%2F4261514%2F99a7af0d-9fed-4e75-bec5-2a9946074ad1.png</url>
      <title>DEV Community: Tailcove</title>
      <link>https://dev.to/tailcove</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tailcove"/>
    <language>en</language>
    <item>
      <title>How we keep a Laravel log ingest endpoint fast (Valkey buffer, batched ClickHouse writes)</title>
      <dc:creator>Tailcove</dc:creator>
      <pubDate>Tue, 24 Nov 2026 00:15:00 +0000</pubDate>
      <link>https://dev.to/tailcove/how-we-keep-a-laravel-log-ingest-endpoint-fast-valkey-buffer-batched-clickhouse-writes-4ifa</link>
      <guid>https://dev.to/tailcove/how-we-keep-a-laravel-log-ingest-endpoint-fast-valkey-buffer-batched-clickhouse-writes-4ifa</guid>
      <description>&lt;p&gt;We're building a hosted log tool on Laravel 13, and the part that took the most thought was ingestion. Clients send logs in bursts, sometimes thousands of lines a second, and the endpoint can't sit waiting on a database while that happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  The request does almost nothing
&lt;/h2&gt;

&lt;p&gt;It checks the token, pushes the batch into Valkey (Redis-compatible) and returns a 202. There are no MySQL queries in that path and no queue job per line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Drainers do the writing
&lt;/h2&gt;

&lt;p&gt;Separate long-running drainer processes, one per buffer shard, claim a batch of 500 to 1000 lines, insert it into ClickHouse, and only acknowledge it after the insert succeeded. Popping first and writing second looks simpler, but it loses lines if the process dies in between.&lt;/p&gt;

&lt;h2&gt;
  
  
  Replays without duplicates
&lt;/h2&gt;

&lt;p&gt;That raises the opposite problem: if a drainer dies after inserting but before acknowledging, the batch gets inserted again on restart. ClickHouse's &lt;code&gt;insert_deduplication_token&lt;/code&gt; handles that. Every batch carries a token, and a repeat with the same token is ignored, so a replay doesn't create duplicates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reads start with source and time
&lt;/h2&gt;

&lt;p&gt;Every query filters by source and time range first, because that's what the table's primary key is built on. Without that, ClickHouse has to scan far more than it needs to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Live tail is the cheap part
&lt;/h2&gt;

&lt;p&gt;After storing a batch, the drainer broadcasts it on a private Laravel Reverb channel and the browser appends the lines. Nothing extra is stored for it.&lt;/p&gt;




&lt;p&gt;Happy to go deeper on any of this in the comments. If you want to poke at it, Tailcove is on DevHunt this week and has a free plan: &lt;a href="https://devhunt.org/tool/tailcove" rel="noopener noreferrer"&gt;https://devhunt.org/tool/tailcove&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>clickhouse</category>
      <category>redis</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
