Skip to content

Courses / RAG Systems / Module 16

Module 16: Deployment and operations: ingestion pipelines, CI/CD, monitoring corpus drift

10 h · theory 3 · hands-on 4 · project 2 · revision 1

You will be able to

  • Run ingestion as a scheduled, idempotent pipeline
  • Deploy the API and index with Docker and CI/CD
  • Monitor retrieval quality and corpus drift
  • Roll back an index safely

Capstone increment: Capstone live at a public HTTPS URL with scheduled ingestion and quality monitoring.

Job-description skills: Deployment, Data pipelines, Cloud · Lab tools: docker, docker-compose, gh, caddy

1. Two pipelines to run

A RAG system is two services with different lifecycles. The ingestion pipeline runs on a schedule or on change events and turns sources into an index version. The query API serves users around the clock. They deploy separately, fail differently and need different monitoring.

The safe pattern: build each new index version beside the live one, evaluate it, switch an alias only if quality holds, and keep the previous version for instant rollback.

Schedulernightly + on webhookDiff sourceshash → changed docsParse + chunksame code as devEmbedbatched, retriedIndex v42built beside v41Eval v42golden setSwitch aliasv41 → v42Monitorquality, driftRoll backalias → v41Scheduled, idempotent ingestionPromote only if quality holdsscores drop
Never rebuild the live index in place. Build a new version, test it, switch an alias, and keep the old one for rollback.

2. Scheduled, idempotent ingestion

Run ingestion with a scheduler you can observe: a cron-triggered GitHub Actions workflow is enough for a capstone; Prefect, Dagster or Airflow add retries, backfills and run history for larger systems. Each run diffs sources by hash, parses and chunks only what changed, embeds in batches with retries, and records counts and failures.

Idempotency is the key property: running the same job twice must give the same index. Then retries after a crash, backfills after a bug fix and re-runs after a parser upgrade are all safe. Send documents that keep failing to a dead-letter list for a person to look at.

3. Ship the API and the index

Package the API as a Docker image; run it with the vector database and cache using docker compose on a small VM, behind Caddy for automatic HTTPS. Keep secrets in environment variables from the host or a secret manager, never in the image or the repo. Add a readiness check that fails until the index alias resolves and a test query returns results.

Deploy from CI: tests and the eval gate pass, the image builds and is pushed, the server pulls it and restarts with a health check. Rolling back the API is redeploying the previous image tag; rolling back the index is switching the alias.

In production: Pin model, embedding and parser versions in config. An upstream model update that changes answers should be a deploy you chose, not a surprise.

4. Index versions and safe rollback

Name index versions (kb_v41, kb_v42) and point a stable alias at the live one. Qdrant supports collection aliases; in Postgres a view or a schema search path does the same. Promote only after the new version passes the golden-set gate, and keep at least one previous version.

Practise the rollback before you need it: time how long it takes to switch the alias back and confirm answers. A rollback you have never run is a hope, not a plan.

5. Monitor quality and corpus drift

Watch online signals as well as uptime: not-found rate, citation-verifier failure rate, thumbs-down rate, the distribution of top retrieval scores, and the share of questions on topics with little coverage. A rising not-found rate after a product launch usually means new documents aren’t indexed yet.

Sample traces weekly and review them with the golden-set mindset: every confirmed failure becomes a new test case. Alert on sustained shifts (the population stability index is a simple measure), not on single spikes.

Tip: Show document freshness on the dashboard: the age of the newest indexed version of each key source. Stale sources explain many “wrong” answers.

Hands-on: coding window

The coding window and the full VS Code lab are available after you sign in.

Sign in to code

Labs

Lab 16.1: Compose stack with HTTPS

Run the API, Qdrant and Redis with docker compose on a small VM or free-tier instance, behind Caddy with a real domain and automatic HTTPS.

Expected: The capstone answers at https://your-domain/ask with a health check that reports the live index version.

Lab 16.2: CI/CD and scheduled ingestion

Add a deploy workflow (tests, eval gate, build, push, restart) and a nightly ingestion workflow that builds a new index version and promotes it only if the gate passes.

Expected: A failed gate leaves the old version live; a green run switches the alias.

Lab 16.3: Monitoring and a rollback drill (capstone increment)

Add a dashboard and alerts for not-found rate, verifier failures, score drift and source freshness. Then deliberately promote a bad index and roll back.

Expected: Alert screenshots and the measured rollback time in the README.

Go deeper

Videos

Further reading

  • Docs Snapshots · Qdrant docs. Back up and restore collections: the basis of index versions and rollback.
  • Docs What is Evidently? · Evidently AI docs. Open-source data and quality drift reports you can run on your corpus and queries.
  • Docs GitHub Actions documentation · GitHub. Workflows, jobs, secrets and environments for the CI/CD pipeline.

GitHub repositories

  • docker/compose: The compose file reference: healthchecks, depends_on conditions and restart policies.
  • caddyserver/caddy: The reverse_proxy directive and automatic HTTPS; a three-line Caddyfile is enough.
  • PrefectHQ/prefect: Flows with retries, schedules and caching; a natural home for ingestion as it grows.
  • evidentlyai/evidently: Data drift reports and metrics you can adapt to retrieval scores and query topics.

Checkpoint quiz

1. Why build a new index version instead of updating the live one?
2. What makes ingestion safe to retry?
3. Where should API keys live?
4. Not-found rate jumps after a product launch. Likely cause?
5. A rollback you have never practised is…

Interview questions

  1. How do you deploy a new index version without downtime or risk?
  2. Design the ingestion pipeline for 10,000 documents a day from five sources.
  3. What do you monitor in a production RAG system beyond uptime?
  4. A deploy changed answers for the worse. Walk through your rollback.
  5. How do you detect that the corpus has drifted from what users ask about?

Ask the professor

Sign in to ask questions about this module.

Discussion

Community discussion appears here once giscus is configured (see README).