Queues, caching, databases, and vector indexes
Practice this questionOverview
- Queues decouple arrival from processing.
- Caches reduce repeated eligible work.
- Business databases store authoritative records; vector indexes store derived retrieval representations.
- Each has a distinct consistency and recovery contract.
Why this matters
AI ingestion and model calls are often slower and more variable than normal database reads.
An everyday example
A waiting tray manages work; quick-reference notes speed repeats; official records remain the final authority.
A technical example
Store a document and ingestion job, enqueue parsing, then publish the searchable version only after validation.
How it works
- Persist task
- Enqueue via reliable dispatch/outbox
- Process bounded steps
- Write result
- Update status
- Invalidate affected caches/indexes.
Architecture and flow
Business transaction + outbox → queue → worker → derived index/cache updates.
The insurance assistant example
Revised policy wording becomes searchable only when its complete index version is ready.
When to use it
Long processing, repeated reads, and searchable document lifecycles.
When to avoid it
Do not use Redis or a vector index as the only claim transaction record.
Interview answer
“I distinguish authoritative data from derived caches and indexes, and use durable job records and reliable dispatch for asynchronous processing.”
Benefits, trade-offs, and production considerations
- An outbox stores pending messages in the same transaction as business changes; a dispatcher later sends them.
- It reduces the “DB committed but queue publish failed” gap.
- Consumers still need deduplication.