기술 블로그

← 모든 글

· Research AI

SQLite CQRS for Research AI: Same Keys, Same Fly Volume

UI는 한국어입니다. 글 본문은 아직 영어 또는 중국어만 있습니다.

We did not invent a new cache story for Research AI. We copied Invest AI’s one writer, many readers SQLite pattern and renamed the keys.

Key layout

KeyWriterReader
v2:research:{hash}worker pipelineFastAPI, Next proxy
v2:research:trendingcache warmer/api/trending
research:pending:queueAPI enqueueworker drain
worker:research_cache:heartbeatworkerops
user:v1:library:{token}account syncAPI

File lives on Fly volume researchai_data → /data/research.db. WAL mode. ~24h TTL on research rows.

Why not Redis for MVP

Extra service, extra bill, extra thing to debug at 2 a.m. SQLite on a volume worked for Invest; it works here until QPS forces a migration (documented in ADR-003).

Rate limits get their own DB

Usage metering uses usage_limits.db — same lesson as Invest: don’t mix high-churn quota writes with cache reads on one file.

Further reading: ADR-003 + CQRS with SQLite (Invest post)