What you will learn
- Separate request handling from ingestion and background work.
- Plan timeouts, retries, caching, and rollback.
- Observe quality and operations without indiscriminate content logging.
- 01BuildVersion code, prompts and corpus
- 02ValidateQuality, access and failure tests
- 03ActivateSwitch a checked release
- 04Observe + recoverSignals and a rehearsed rollback
Draw the deployable components
Use a frontend for interaction, an authenticated application API for orchestration, an ingestion worker for document updates, storage for source records and indexes, and model/tool clients behind clear interfaces. Keep long ingestion jobs out of ordinary request handling. A queue can help isolate background work, but also needs retry and dead-letter handling.
Version documents, embeddings, prompts, and model configuration together in release records. Build a new index separately, validate it, then switch traffic through an atomic version pointer or equivalent mechanism. Keep the previous version available for rollback. Updating half the records in place can expose inconsistent evidence to users.
Bound failures and avoid retry storms
Set request deadlines and shorter dependency timeouts inside them. Retry transient errors with bounded backoff and jitter where appropriate. A circuit breaker can stop repeatedly calling a failing dependency. Distinguish a safe read retry from a write whose outcome is uncertain.
Fallback behavior must preserve the task's boundaries. If generation is unavailable, showing permitted source excerpts may be more honest than producing an ungrounded answer through an untested fallback model. If retrieval is unavailable, do not silently answer a private-policy question from general model knowledge. Explain the limitation and offer a useful next step.
Cache with the right identity and version
Embedding caches can key on content hash and embedding version. Answer caches need additional care: permissions, tenant, policy version, prompt version, and relevant request state can affect correctness. A shared cache keyed only by question text can leak private answers or return stale policy.
Start with measured bottlenecks. Shorter context, avoiding duplicate tool calls, batching ingestion, and limiting unnecessary generation can reduce cost. Horizontal scaling helps stateless application workers, but downstream quotas and database capacity may remain the bottleneck. Streaming improves perceived responsiveness; it does not reduce the total work automatically.
Instrument the path users depend on
Use request traces to connect retrieval, model calls, tool calls, and validation. Metrics summarize rates and distributions; logs capture selected events. OpenTelemetry provides concepts and tooling for these signals. Collect identifiers, durations, versions, status, and usage where useful; avoid making raw private prompts the default diagnostic record.
Define release gates from your evaluation set and operational requirements. Test cancellation, dependency outages, stale documents, unauthorized access, and rollback. Watch both service availability and answer quality after release. A green HTTP dashboard can coexist with systematically wrong answers if nobody measures the content path.
PUT IT TO WORK
Your practice task
Write a release runbook with a staging check, index activation step, smoke test, monitoring window, and rollback trigger. Simulate a model timeout and a retrieval outage using mocks. State exactly what the user sees in each case and what diagnostic event you record.
Checkpoint: compare your reasoning
A retrieval outage must not turn into a confident policy answer without evidence. Rollback needs a known previous application/configuration/index combination. “Restart everything” is not an adequate recovery plan if the problem is a bad document version.
References and further reading
Use these primary references for deeper study and current API details. Examples in this lesson use fictional Northstar data.