AI EngineeringInterview preparation
Advanced·Concept·2 min read

Queues, caching, databases, and vector indexes

Practice this question

Overview

  • 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

  1. Persist task
  2. Enqueue via reliable dispatch/outbox
  3. Process bounded steps
  4. Write result
  5. Update status
  6. 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.
Adapted from 13_AI.MD · “Queues, caching, databases, and vector indexes”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.