DuckCon #7

SQL layer over user listening history for agentic access

Kian Mehrabani · DuckCon #7
7
sections
9
slides
DuckDBAgentic AISpotifyApache ArrowSQLData Platform
Watch on YouTube ↗
01 / Context

frame_00m00s.png
frame_00m00s.png
frame_00m24s.png
frame_00m24s.png
More detail

Two traditional access patterns: low-latency access for recent data (recent streams), and a custom materialization engine on top that lets customers build materialized views for longer tails. Listening data is heavily skewed, so materialization is used to reduce tail latencies.

02 / Problem

frame_04m06s.png
frame_04m06s.png
frame_04m48s.png
frame_04m48s.png
More detail

The agent needs an interface to translate prompts into a useful intermediate, plus something that can crunch the actual listening history to produce the answer. Traditional recommendations remain just as important, so the solution had to sit on top of the existing system.

03 / Decision

frame_04m57s.png
frame_04m57s.png
More detail

The 'Walks and Quacks like...' slide pairs the SQL logo with the DuckDB logo, framing DuckDB as the natural fit for an embeddable, in-process SQL engine.

04 / Architecture

frame_06m06s.png
frame_06m06s.png
More detail

The change to the existing platform was deliberately simple: a stateless, fully ephemeral service plopped on top of the existing user behavior store. Protobuf is the underlying data model.

05 / Learnings

frame_06m30s.png
frame_06m30s.png
More detail

Dashboards showed Proto Event Response Size at P50 (single-digit to ~32 MiB range) versus P99 (hundreds of MiB), illustrating the incredibly varied memory profile of the workload.

06 / Learnings

frame_08m00s.png
frame_08m00s.png
More detail

Buffer reuse has a downside: a small buffer can be resized by one giant query, leaving a large wasted memory block for subsequent small queries. Reusing the mature distributed join service was possible precisely because everything runs in memory and in process.

07 / Impact

frame_10m39s.png
frame_10m39s.png
More detail

The chart '(faucet-sql-service) Memory Usage - Avg per pod' shows peaks up to the mid-50 GiB range before, dropping to a lower, calmer band afterward. Kian noted 'it was a great day to be on call.'

Key Takeaways