How we keep a Laravel log ingest endpoint fast
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
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.
The request does almost nothing
It checks the token, pushes the batch into Valkey and returns a 202 Accepted. There are no MySQL queries in that path and no queue job per line. The token check is served from cache, so even auth doesn't touch the database.
A 202 is the honest answer here: we have your data and it's safely buffered, but it isn't searchable yet. In practice the gap is seconds.
Draining: claim, insert, then ack
The writing happens in separate long-running drainer processes, one per buffer shard. Each one claims a batch of 500 to 1000 lines, inserts it into ClickHouse, and only acknowledges it after the insert succeeded.
Popping first and writing second looks simpler, but it loses lines if the process dies in between. ClickHouse also prefers big inserts: lots of small ones create many small parts and slow everything down.
Replays without duplicates
Claim-then-ack raises the opposite problem. If a drainer dies after inserting but before acknowledging, the batch gets inserted again on restart.
ClickHouse's insert_deduplication_token handles that. Every batch carries a token derived from the batch, and a repeat with the same token is ignored. Crash, replay, no duplicates.
Queries start narrow
On the read side, every query filters by source and time range first, because that's what the table's primary key is built on. ClickHouse can then skip almost all of the data on disk before reading a row.
Live tail is the cheap part: after storing a batch, the drainer broadcasts it on a private Reverb channel and the browser appends the lines.
Try it
You can send a batch with curl and watch it show up in the live tail:
curl -X POST https://ingest.tailcove.dev/api/v1/logs \
-H "Authorization: Bearer YOUR_INGEST_TOKEN" \
-H "Content-Type: application/json" \
-d '[{"message":"Request started","level":"info"}]'
I'm one of the people building Tailcove, and happy to answer questions about any of this in the comments. It's on DevHunt this week and has a free plan.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.