Skip to content

12. RAG Deployment Patterns

Category: Production RAG Engineering
Module: Part VI โ€” Production Deployment
Difficulty: Advanced


๐Ÿ“– Overview

Deploying a RAG system is not simply a matter of running an API and connecting it to a vector database.

A production RAG deployment must account for:

Application Deployment
        โ†“
Retrieval Deployment
        โ†“
Index Deployment
        โ†“
Model Deployment
        โ†“
Knowledge Deployment
        โ†“
Configuration Deployment
        โ†“
Observability
        โ†“
Security
        โ†“
Scalability
        โ†“
Rollback

Different workloads require different deployment patterns.

For example:

Small Internal RAG
    โ†’ Single Service

Enterprise RAG
    โ†’ Microservices

High-Traffic RAG
    โ†’ Horizontally Scaled Services

High-Risk RAG
    โ†’ Canary / Blue-Green

Global RAG
    โ†’ Multi-Region

Frequently Changing RAG
    โ†’ Independent Index Deployment

The goal is not to choose the most complex deployment pattern.

The goal is to choose the simplest deployment architecture that satisfies the required quality, availability, latency, security, scalability, and cost objectives.


๐ŸŽฏ Learning Objectives

After completing this chapter, you will be able to:

  • Understand major RAG deployment patterns
  • Design monolithic RAG deployments
  • Design modular RAG deployments
  • Design microservice-based RAG platforms
  • Understand serverless RAG deployment
  • Deploy RAG using containers
  • Deploy RAG using Kubernetes
  • Design blue-green deployments
  • Design rolling deployments
  • Design canary deployments
  • Design shadow deployments
  • Design A/B deployments
  • Design multi-region RAG
  • Design active-active architectures
  • Design active-passive architectures
  • Deploy retrieval and generation independently
  • Deploy indexes independently from application code
  • Design model rollout strategies
  • Design embedding migration strategies
  • Design zero-downtime RAG deployments
  • Design rollback mechanisms
  • Design disaster recovery
  • Design deployment pipelines
  • Build CI/CD quality gates
  • Design environment strategies
  • Understand infrastructure-as-code for RAG
  • Design deployment observability
  • Choose appropriate deployment patterns based on workload requirements

๐Ÿง  1. Why RAG Deployment Is Different

Traditional backend deployment often looks like:

Code
 โ†“
Build
 โ†“
Test
 โ†“
Deploy

RAG introduces additional deployable components:

Application
Retriever
Embedding Model
Vector Index
Keyword Index
Reranker
Prompt
LLM
Knowledge Base
Configuration
Evaluation Dataset

Therefore:

RAG Deployment
โ‰ 
Application Deployment

It is a coordinated deployment of multiple versioned artifacts.


๐Ÿง  2. RAG Deployment Surface

flowchart TD
    A["RAG System"] --> B["Application"]
    A --> C["Retrieval"]
    A --> D["Indexes"]
    A --> E["Models"]
    A --> F["Prompts"]
    A --> G["Knowledge"]
    A --> H["Configuration"]

    B --> I["Deployment"]
    C --> I
    D --> I
    E --> I
    F --> I
    G --> I
    H --> I

๐Ÿง  3. Version Everything

A production RAG deployment should identify:

Application Version
Retriever Version
Embedding Version
Index Version
Reranker Version
Prompt Version
LLM Version
Configuration Version
Knowledge Version

Example:

{
  "application": "v12",
  "retriever": "v8",
  "embedding": "v4",
  "index": "v17",
  "reranker": "v3",
  "prompt": "v9",
  "model": "model-x",
  "configuration": "v11"
}

This enables:

Traceability
Reproducibility
Rollback
Debugging
Evaluation

๐Ÿง  4. Deployment Units

A mature RAG platform may have:

API Service
Query Service
Retrieval Service
Reranking Service
Generation Service
Ingestion Worker
Indexing Worker
Evaluation Service

Not every system needs all of them as separate services.


๐Ÿง  5. Deployment Granularity

There are several options:

Single Process
     โ†“
Modular Monolith
     โ†“
Multiple Services
     โ†“
Distributed Platform

Choose based on:

Scale
Team Size
Operational Complexity
Latency
Independent Scaling
Security
Cost

๐Ÿง  6. Pattern 1 โ€” Monolithic RAG

The simplest deployment:

                 RAG Application
                       โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ–ผ               โ–ผ               โ–ผ
   Retrieval        Context          LLM
       โ”‚               โ”‚               โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ–ผ
                    Response

Everything runs inside one application.


๐Ÿง  7. Monolithic Deployment

Docker Container
       โ”‚
       โ”œโ”€โ”€ API
       โ”œโ”€โ”€ Retrieval
       โ”œโ”€โ”€ Prompt
       โ”œโ”€โ”€ Validation
       โ””โ”€โ”€ Generation

External:

Vector DB
Object Storage
LLM Provider
Cache

๐Ÿง  8. Advantages of Monolithic RAG

Simple
Easy to Develop
Easy to Debug
Low Operational Overhead
Low Network Overhead
Easy Local Deployment

๐Ÿง  9. Limitations

Independent Scaling is Difficult
Large Deployment Unit
Higher Blast Radius
Retrieval and Generation Coupled
Harder Provider Isolation

๐Ÿง  10. When to Use

Good for:

Prototype
Small Internal Tool
Low Traffic
Single Team
Early Production

Avoid unnecessary microservices at this stage.


๐Ÿง  11. Pattern 2 โ€” Modular Monolith

A stronger intermediate architecture:

                 RAG Application
                       โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ–ผ               โ–ผ               โ–ผ
 Query Module    Retrieval Module   Generation
       โ”‚               โ”‚               โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ–ผ
                   Response

The modules have explicit interfaces but run in one process.


๐Ÿง  12. Why Modular Monolith?

It provides:

Low Operational Complexity
+
Strong Architectural Boundaries

without immediately introducing distributed-system complexity.


๐Ÿง  13. Pattern 3 โ€” Microservice RAG

At larger scale:

flowchart TD
    A["API Gateway"] --> B["RAG Orchestrator"]

    B --> C["Query Service"]
    B --> D["Retrieval Service"]
    B --> E["Generation Service"]

    D --> F["Vector Search"]
    D --> G["Keyword Search"]

    E --> H["Model Gateway"]

    I["Ingestion Service"] --> J["Indexing"]

๐Ÿง  14. Microservice Boundaries

Potential services:

Query Service
Retrieval Service
Reranking Service
Context Service
Generation Service
Ingestion Service
Indexing Service
Evaluation Service

But do not split services purely because components exist.


๐Ÿง  15. Independent Scaling

One of the strongest reasons for service separation:

Retrieval:
10,000 req/s

Generation:
500 req/s

They have very different scaling characteristics.


๐Ÿง  16. Microservice Trade-Off

Benefits:

Independent Scaling
Independent Deployment
Fault Isolation
Technology Flexibility
Team Ownership

Costs:

Network Latency
Distributed Tracing
Operational Complexity
Service Discovery
Failure Handling
Deployment Complexity

๐Ÿง  17. Pattern 4 โ€” Retrieval as a Platform

Multiple applications can consume a shared retrieval platform.

             Retrieval Platform
                    โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ           โ–ผ           โ–ผ
      Chat        Copilot      Agent
        โ”‚           โ”‚           โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ–ผ
                 Evidence

๐Ÿง  18. Why Retrieval Platform?

Centralize:

Security
Retrieval
Ranking
Metadata
Tenant Isolation
Observability
Evaluation

Applications focus on business capabilities.


๐Ÿง  19. Pattern 5 โ€” Serverless RAG

A serverless deployment may use:

API Gateway
     โ†“
Function / Container
     โ†“
Vector Search
     โ†“
LLM

Ingestion:

Object Storage
     โ†“
Event
     โ†“
Function
     โ†“
Embedding
     โ†“
Index

๐Ÿง  20. Serverless Advantages

No Server Management
Automatic Scaling
Pay Per Use
Fast Initial Deployment
Good for Variable Traffic

๐Ÿง  21. Serverless Limitations

Potential issues:

Cold Starts
Execution Limits
Concurrency Limits
Long-Running Processing
Connection Management
Vendor Coupling

๐Ÿง  22. Good Serverless Workloads

Low / Variable Traffic
Event-Driven Ingestion
Document Processing
Lightweight APIs
Scheduled Evaluation

๐Ÿง  23. Pattern 6 โ€” Containerized RAG

A common production pattern:

Docker
   โ†“
Container Registry
   โ†“
Container Platform

Possible platforms:

ECS
EKS
AKS
GKE
Cloud Run
OpenShift

๐Ÿง  24. Container Architecture

flowchart LR
    A["Container Registry"] --> B["Deployment Platform"]

    B --> C["RAG API"]
    B --> D["Retrieval Worker"]
    B --> E["Ingestion Worker"]
    B --> F["Evaluation Worker"]

    C --> G["Vector DB"]
    D --> G

๐Ÿง  25. Why Containers?

Containers provide:

Consistent Runtime
Portable Deployment
Dependency Isolation
Horizontal Scaling
CI/CD Integration

๐Ÿง  26. Pattern 7 โ€” Kubernetes RAG

For complex enterprise environments:

Kubernetes Cluster
โ”‚
โ”œโ”€โ”€ RAG API
โ”œโ”€โ”€ Retrieval Service
โ”œโ”€โ”€ Reranker
โ”œโ”€โ”€ Ingestion Workers
โ”œโ”€โ”€ Indexing Workers
โ””โ”€โ”€ Evaluation Workers

External:

Vector DB
Object Storage
LLM
Cache
Observability

๐Ÿง  27. Kubernetes Scaling

              Load Balancer
                    โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ–ผ         โ–ผ         โ–ผ
        Pod 1     Pod 2     Pod 3
          โ”‚         โ”‚         โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ–ผ
                Retrieval

Autoscaling can respond to:

CPU
Memory
Request Rate
Queue Depth
Custom Metrics

๐Ÿง  28. Kubernetes Advantages

Horizontal Scaling
Self-Healing
Rolling Deployments
Service Discovery
Resource Isolation
Declarative Configuration

๐Ÿง  29. Kubernetes Challenges

Operational Complexity
Networking
Security
Observability
Cluster Management
Cost

Do not use Kubernetes merely because it is available.


๐Ÿง  30. Pattern 8 โ€” Rolling Deployment

Replace instances gradually.

Version 1:

Pod A
Pod B
Pod C
Pod D

        โ†“

Update A

Pod A = V2
Pod B = V1
Pod C = V1
Pod D = V1

        โ†“

Update B

Pod A = V2
Pod B = V2
Pod C = V1
Pod D = V1

Eventually:

100% V2

๐Ÿง  31. Rolling Deployment Advantages

Simple
Low Infrastructure Overhead
No Full Duplicate Environment
Continuous Availability

๐Ÿง  32. Rolling Deployment Risk

During rollout:

V1 + V2

may run simultaneously.

Therefore:

API Contracts
Configuration
Database Schema
Prompt Contracts
Retriever Contracts

must remain compatible.


๐Ÿง  33. Pattern 9 โ€” Blue-Green Deployment

Maintain two environments:

Blue = Current
Green = New
                 Load Balancer
                      โ”‚
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
                โ–ผ           โ–ผ
              Blue        Green
              V1            V2

Traffic initially:

100% โ†’ Blue

After validation:

100% โ†’ Green

๐Ÿง  34. Blue-Green Advantages

Fast Rollback
Clean Environment
Easy Validation
Low Deployment Risk

๐Ÿง  35. Blue-Green RAG

Blue and Green may contain:

Application
Retriever
Prompt
Configuration

But index deployment requires additional planning.


๐Ÿง  36. Index Blue-Green

Production
    โ”‚
    โ–ผ
Index V10

Build
    โ”‚
    โ–ผ
Index V11
    โ”‚
    โ–ผ
Validate
    โ”‚
    โ–ผ
Switch

This allows index rollback independently from application rollback.


๐Ÿง  37. Pattern 10 โ€” Canary Deployment

Send a small percentage of traffic to the new version.

                  Traffic
                     โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ             โ–ผ
           V1 = 95%      V2 = 5%

Monitor:

Latency
Errors
Retrieval Quality
Answer Quality
Cost

๐Ÿง  38. Canary for RAG

Canary changes can include:

Retriever
Embedding Model
Reranker
Prompt
LLM
Index

๐Ÿง  39. Quality-Aware Canary

Traditional canary:

Error Rate
Latency

RAG canary should additionally monitor:

Recall
Groundedness
Citation Accuracy
No-Answer Rate
User Feedback

๐Ÿง  40. Canary Promotion

5%
 โ†“
10%
 โ†“
25%
 โ†“
50%
 โ†“
100%

Promotion should stop if quality or operational metrics degrade.


๐Ÿง  41. Pattern 11 โ€” Shadow Deployment

The new version receives copied traffic but does not affect the user response.

flowchart LR
    A["Production Request"] --> B["Current RAG"]
    A --> C["Shadow RAG"]

    B --> D["User Response"]
    C --> E["Evaluation Only"]

๐Ÿง  42. Shadow Deployment Benefits

Useful for testing:

New Retriever
New Model
New Prompt
New Index

against real production queries.


๐Ÿง  43. Shadow Deployment Risk

Shadow systems still consume:

Compute
Embedding
Reranking
LLM
Network

Therefore cost must be controlled.


๐Ÿง  44. Pattern 12 โ€” A/B Deployment

Different users receive different versions.

Users
  โ”‚
  โ”œโ”€โ”€ Group A โ†’ RAG V1
  โ”‚
  โ””โ”€โ”€ Group B โ†’ RAG V2

Compare:

Quality
Latency
Cost
Engagement
User Satisfaction

๐Ÿง  45. A/B Testing in RAG

Possible experiments:

Prompt A vs Prompt B
Retriever A vs Retriever B
Chunking A vs Chunking B
Reranker A vs Reranker B
Model A vs Model B

๐Ÿง  46. Pattern 13 โ€” Multi-Region

Global systems may deploy RAG into multiple regions.

                 Global Router
                       โ”‚
            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
            โ–ผ                     โ–ผ
         Region A              Region B
            โ”‚                     โ”‚
         RAG Stack              RAG Stack
            โ”‚                     โ”‚
         Index A                Index B

๐Ÿง  47. Why Multi-Region?

Reasons include:

Low Latency
High Availability
Data Residency
Disaster Recovery
Business Continuity

๐Ÿง  48. Active-Active

Both regions serve traffic:

             Global Router
                /      \
               โ–ผ        โ–ผ
          Region A    Region B
            50%         50%

Advantages:

High Availability
Load Distribution
Low Regional Latency

Challenges:

Data Synchronization
Index Consistency
Operational Complexity

๐Ÿง  49. Active-Passive

One region serves traffic.

Primary
  โ”‚
  โ–ผ
Production

Secondary
  โ”‚
  โ–ผ
Standby

During failure:

Primary
   โ†“
Failure
   โ†“
Failover
   โ†“
Secondary

๐Ÿง  50. Active-Active vs Active-Passive

Pattern Availability Complexity Cost
Active-Active Very High High High
Active-Passive High Medium Medium
Single Region Lower Low Lower

Choose based on business requirements.


๐Ÿง  51. Multi-Region Index Strategy

Possible approaches:

Replicated Index

or:

Region-Specific Index

or:

Shared Global Index

Selection depends on:

Data Residency
Freshness
Latency
Cost
Consistency

๐Ÿง  52. Pattern 14 โ€” Edge / Regional Retrieval

For latency-sensitive workloads:

User
 โ†“
Nearest Region
 โ†“
Regional Retrieval
 โ†“
Regional Index

Useful when:

Global Users
Low Latency Requirements
Regional Data

๐Ÿง  53. Pattern 15 โ€” Dedicated Tenant Deployment

For high-value enterprise tenants:

Tenant A
 โ”œโ”€โ”€ RAG API
 โ”œโ”€โ”€ Index
 โ””โ”€โ”€ Storage

Tenant B
 โ”œโ”€โ”€ RAG API
 โ”œโ”€โ”€ Index
 โ””โ”€โ”€ Storage

Benefits:

Strong Isolation
Dedicated Performance
Custom Configuration

Cost:

Higher Infrastructure Cost

๐Ÿง  54. Pattern 16 โ€” Shared RAG Platform

Multiple tenants share infrastructure:

                RAG Platform
                     โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ–ผ             โ–ผ             โ–ผ
    Tenant A      Tenant B      Tenant C

Isolation occurs through:

Tenant ID
Metadata
ACL
Policy
Cache

๐Ÿง  55. Hybrid Tenant Deployment

A mature enterprise platform can use:

Small Tenants
    โ†“
Shared Infrastructure

Large / Regulated Tenants
    โ†“
Dedicated Infrastructure

This balances:

Isolation
Cost
Scale

๐Ÿง  56. Pattern 17 โ€” Independent Index Deployment

Do not necessarily deploy the index together with application code.

Application V12
      โ”‚
      โ–ผ
Index V17

The two can evolve independently.


๐Ÿง  57. Why Independent Index Deployment?

Useful when:

Documents Change Frequently
Embedding Changes
Chunking Changes
Index Optimization

๐Ÿง  58. Index Deployment Pipeline

flowchart LR
    A["Source Data"] --> B["Index Builder"]
    B --> C["Evaluation"]
    C --> D["Index V18"]
    D --> E["Canary"]
    E --> F["Production"]

๐Ÿง  59. Embedding Migration

Changing embeddings can require re-indexing.

Embedding V1
     โ†“
New Embedding V2
     โ†“
Re-Embed Documents
     โ†“
Build New Index
     โ†“
Evaluate
     โ†“
Deploy

Do not blindly replace the existing index.


๐Ÿง  60. Dual-Index Migration

During migration:

Query
 โ”œโ”€โ”€ Index V1
 โ””โ”€โ”€ Index V2

Compare:

Recall
Latency
Results

Then switch traffic.


๐Ÿง  61. Pattern 18 โ€” Dual Read

Both systems are queried:

Request
 โ”œโ”€โ”€ Old Retrieval
 โ””โ”€โ”€ New Retrieval

       โ†“

Comparison

Useful for:

Retriever Migration
Vector DB Migration
Embedding Migration

๐Ÿง  62. Pattern 19 โ€” Dual Write

During migration:

New Document
    โ”‚
    โ”œโ”€โ”€ Old Index
    โ””โ”€โ”€ New Index

This helps keep both indexes current.

Use carefully because it increases:

Cost
Complexity
Failure Modes

๐Ÿง  63. Migration Strategy

A safer migration:

Build New
   โ†“
Backfill
   โ†“
Dual Write
   โ†“
Dual Read
   โ†“
Compare
   โ†“
Canary
   โ†“
Switch
   โ†“
Retire Old

๐Ÿง  64. Pattern 20 โ€” Immutable Deployment

Treat deployment artifacts as immutable:

Application Image
Prompt Version
Index Version
Model Version
Configuration Version

Do not modify deployed artifacts in place.


๐Ÿง  65. Reproducible Deployment

Given:

Code Version
Index Version
Model Version
Configuration Version

you should be able to reconstruct the deployment.


๐Ÿง  66. Deployment Manifest

Example:

application:
  version: v12

retriever:
  version: v8

embedding:
  version: v4

index:
  version: v17

reranker:
  version: v3

prompt:
  version: v9

model:
  version: model-x

๐Ÿง  67. Deployment Metadata

Expose deployment information through:

Health Endpoint
Metadata Endpoint
Logs
Tracing
Response Metadata

Example:

{
  "application_version": "v12",
  "retriever_version": "v8",
  "index_version": "v17"
}

๐Ÿง  68. Environment Strategy

Use:

Development
       โ†“
Integration
       โ†“
Staging
       โ†“
Production

Each environment should have appropriate:

Configuration
Data
Credentials
Indexes
Models
Scale

๐Ÿง  69. Development Environment

Optimize for:

Speed
Low Cost
Developer Productivity

Possible:

Local Vector Store
Local Model
Mock LLM
Small Dataset

๐Ÿง  70. Staging Environment

Should resemble production enough to validate:

Networking
Authentication
Retrieval
Indexes
Models
Observability
Deployment

๐Ÿง  71. Production Environment

Requires:

High Availability
Security
Monitoring
Alerting
Backups
Scaling
Disaster Recovery

๐Ÿง  72. Configuration Promotion

Do not copy configuration manually.

Use:

Git
 โ†“
CI/CD
 โ†“
Environment Configuration

๐Ÿง  73. Secrets Promotion

Never move secrets through Git.

Use:

Secrets Manager
Vault
Cloud Secret Store
Workload Identity

๐Ÿง  74. CI/CD Pipeline

flowchart LR
    A["Git Commit"] --> B["Build"]

    B --> C["Unit Tests"]
    C --> D["Integration Tests"]
    D --> E["RAG Evaluation"]
    E --> F["Security Tests"]
    F --> G["Performance Tests"]

    G --> H["Build Artifact"]
    H --> I["Staging"]
    I --> J["Canary"]
    J --> K["Production"]

๐Ÿง  75. RAG-Specific Quality Gate

Traditional deployment:

Tests Pass
   โ†“
Deploy

RAG deployment:

Tests
 โ†“
Retrieval Evaluation
 โ†“
Generation Evaluation
 โ†“
Citation Evaluation
 โ†“
Security
 โ†“
Performance
 โ†“
Deploy

๐Ÿง  76. Deployment Gate Example

Recall@10 >= target
AND
Groundedness >= target
AND
Citation Accuracy >= target
AND
p95 <= target
AND
Cost/request <= target

If any critical condition fails:

Deployment Blocked

๐Ÿง  77. Deployment Observability

Monitor deployment impact:

Before Deployment
        โ†“
Baseline
        โ†“
Deploy
        โ†“
Compare
        โ†“
Decision

๐Ÿง  78. Deployment Dashboard

Track:

Traffic
Errors
Latency
Retrieval Quality
Groundedness
Citation Quality
Token Usage
Cost

๐Ÿง  79. Rollback Strategy

Rollback may involve:

Application
Retriever
Prompt
Model
Index
Configuration

These should not necessarily be rolled back together.


๐Ÿง  80. Application Rollback

V12
 โ†“
Problem
 โ†“
V11

Simple if deployments are immutable.


๐Ÿง  81. Index Rollback

Index V17
 โ†“
Quality Regression
 โ†“
Index V16

Traffic can be switched back.


๐Ÿง  82. Prompt Rollback

Prompt V9
 โ†“
Grounding Regression
 โ†“
Prompt V8

Prompt versioning makes this possible.


๐Ÿง  83. Model Rollback

Model B
 โ†“
Latency / Quality Problem
 โ†“
Model A

Use model gateways where possible to simplify routing.


๐Ÿง  84. Partial Rollback

A powerful production capability:

Application โ†’ V12
Retriever   โ†’ V8
Index       โ†’ V16
Prompt      โ†’ V8
Model       โ†’ A

The system does not need to roll back every component.


๐Ÿง  85. Zero-Downtime Deployment

A production RAG deployment should ideally maintain:

Traffic
  โ†“
Healthy Version

while replacing components.

Use:

Rolling
Blue-Green
Canary

depending on risk.


๐Ÿง  86. Deployment Compatibility

During rollout:

V1 + V2

may coexist.

Therefore ensure compatibility between:

API
Retriever Contract
Index Schema
Metadata Schema
Configuration
Prompt Variables

๐Ÿง  87. Schema Evolution

Example:

Metadata V1
    โ†“
Metadata V2

New fields should ideally be introduced compatibly before old fields are removed.


๐Ÿง  88. Expand-and-Contract

A safer migration pattern:

Expand
 โ†“
Support Old + New
 โ†“
Migrate
 โ†“
Switch
 โ†“
Contract

Example:

Add New Metadata Field
        โ†“
Deploy Consumers
        โ†“
Populate Field
        โ†“
Switch Retrieval
        โ†“
Remove Old Field

๐Ÿง  89. Deployment Blast Radius

Not every change should affect:

100% Users
100% Tenants
100% Regions

Use:

Canary
Tenant-Based Rollout
Region-Based Rollout
Feature Flag

๐Ÿง  90. Tenant-Based Rollout

Tenant A โ†’ V2
Tenant B โ†’ V1
Tenant C โ†’ V1

Useful for enterprise platforms.


๐Ÿง  91. Region-Based Rollout

Region A โ†’ V2
Region B โ†’ V1
Region C โ†’ V1

Useful for global systems.


๐Ÿง  92. Feature Flag Rollout

hybrid_retrieval:
  enabled: true

Roll out gradually:

5%
10%
25%
50%
100%

๐Ÿง  93. Model Deployment Patterns

Models can be deployed through:

Managed API
Model Gateway
Dedicated Inference Service
GPU Cluster
Serverless Inference

๐Ÿง  94. Managed Model Deployment

RAG Application
      โ†“
Managed LLM API

Advantages:

Low Operational Complexity
Elastic Scaling
No GPU Management

๐Ÿง  95. Self-Hosted Model Deployment

RAG
 โ†“
Inference Gateway
 โ†“
GPU Cluster
 โ†“
Model

Benefits:

Control
Customization
Potential Cost Efficiency at Scale
Data Residency

Challenges:

GPU Cost
Scaling
Model Serving
Patch Management
Capacity Planning

๐Ÿง  96. Model Canary

Model A โ†’ 95%
Model B โ†’ 5%

Compare:

Quality
Latency
Tokens
Cost
Failure Rate

๐Ÿง  97. Prompt Deployment

Prompts should be treated as versioned artifacts.

Prompt V1
Prompt V2
Prompt V3

Deploy independently when architecture permits.


๐Ÿง  98. Prompt Canary

Users
 โ”œโ”€โ”€ Prompt V1
 โ””โ”€โ”€ Prompt V2

Evaluate:

Groundedness
Relevance
Citation
Safety

๐Ÿง  99. Retrieval Deployment

Retrieval components can also be independently deployed:

Retriever V7
     โ†“
Retriever V8

Use:

Shadow
Canary
A/B

before full rollout.


๐Ÿง  100. Deployment Pattern Selection

Use the following mental model:

Small System
    โ†“
Monolith

Growing System
    โ†“
Modular Monolith

Independent Scaling Required
    โ†“
Microservices

Variable / Event-Driven Workload
    โ†“
Serverless

Complex Enterprise Platform
    โ†“
Containers / Kubernetes

High Deployment Risk
    โ†“
Canary / Blue-Green

Global Availability
    โ†“
Multi-Region

Migration
    โ†“
Dual Read / Dual Write

๐Ÿง  101. Deployment Decision Matrix

Requirement Recommended Pattern
Simple application Monolith
Strong modularity Modular Monolith
Independent scaling Microservices
Event-driven workload Serverless / Workers
Enterprise platform Containers / Kubernetes
Low deployment risk Blue-Green
Gradual rollout Canary
Production comparison Shadow
Experimentation A/B
Global availability Multi-Region
High isolation tenant Dedicated
Migration Dual Read / Dual Write
Independent index lifecycle Separate Index Deployment

๐Ÿง  102. Deployment Architecture by Maturity

Stage 1

Docker
 โ†“
RAG API
 โ†“
Vector DB
 โ†“
LLM

Stage 2

API
 โ†“
Retrieval
 โ†“
Generation

Stage 3

API
 โ†“
Retrieval Platform
 โ†“
Model Gateway

Stage 4

Multi-Tenant
+
Canary
+
Evaluation
+
Observability

Stage 5

Multi-Region
+
Independent Index
+
Automated Quality Gates
+
Continuous Deployment

๐Ÿง  103. Production Deployment Architecture

flowchart TD
    A["Users"] --> B["Global Load Balancer"]

    B --> C["Region A"]
    B --> D["Region B"]

    C --> E["RAG Gateway"]
    D --> F["RAG Gateway"]

    E --> G["Retrieval Platform"]
    F --> H["Retrieval Platform"]

    G --> I["Index A"]
    H --> J["Index B"]

    E --> K["Model Gateway"]
    F --> L["Model Gateway"]

    K --> M["LLM"]
    L --> N["LLM"]

    O["CI/CD"] --> P["Deployment Controller"]
    P --> E
    P --> F

    Q["Index Pipeline"] --> I
    Q --> J

    R["Observability"] --> E
    R --> F
    R --> G
    R --> H

๐Ÿง  104. Production Deployment Workflow

Developer
   โ†“
Git
   โ†“
CI
   โ†“
Unit Tests
   โ†“
Integration Tests
   โ†“
RAG Evaluation
   โ†“
Security Tests
   โ†“
Performance Tests
   โ†“
Artifact
   โ†“
Staging
   โ†“
Canary
   โ†“
Production
   โ†“
Observe
   โ†“
Promote / Rollback

๐Ÿง  105. Deployment Safety

Every production deployment should answer:

What changed?

Who receives the change?

How do we measure impact?

How quickly can we rollback?

What happens to existing requests?

What happens to indexes?

What happens to cached results?

What happens if the new version fails?

๐Ÿง  106. Cache During Deployment

Deployment can create stale caches.

Example:

Retriever V7
 โ†“
Cache V7 Results

Deploy Retriever V8

Cache keys should include version information where appropriate:

query
+
retriever_version
+
index_version

๐Ÿง  107. Deployment and Index Compatibility

Avoid:

Application V2
      โ†“
Expects metadata V2

Index V1
      โ†“
Only contains metadata V1

This creates runtime failures.

Use:

Schema Compatibility

during transitions.


๐Ÿง  108. Deployment and Freshness

Application deployment does not automatically mean:

Knowledge Updated

Keep separate lifecycles:

Application Deployment
Knowledge Deployment
Index Deployment

๐Ÿง  109. Knowledge Deployment

A document update may follow:

Source
 โ†“
Ingestion
 โ†“
Processing
 โ†“
Indexing
 โ†“
Validation
 โ†“
Available

This is a deployment of knowledge rather than application code.


๐Ÿง  110. Knowledge Canary

For high-risk knowledge changes:

New Knowledge
      โ†“
Shadow Index
      โ†“
Evaluate
      โ†“
Production

Useful for:

Policy Changes
Legal Documents
Regulated Knowledge

๐Ÿง  111. Regulated RAG Deployment

Regulated systems may require:

Approval
Audit
Versioning
Data Residency
Change Control
Rollback
Evidence

๐Ÿง  112. Approval Workflow

Change
 โ†“
Evaluation
 โ†“
Security Review
 โ†“
Business Approval
 โ†“
Deployment
 โ†“
Audit

๐Ÿง  113. GitOps

For Kubernetes-based environments:

Git
 โ†“
Desired State
 โ†“
Deployment Controller
 โ†“
Cluster

Benefits:

Auditability
Reproducibility
Declarative Deployment
Rollback

๐Ÿง  114. Infrastructure as Code

Infrastructure should be versioned:

Terraform
CloudFormation
Pulumi

Example:

Network
Compute
Storage
Vector DB
Cache
IAM
Monitoring

๐Ÿง  115. Deployment as Code

The same principle applies to:

Application
Infrastructure
Configuration
Prompts
Indexes
Evaluation

๐Ÿง  116. Immutable Artifacts

Examples:

Docker Image: sha256:...
Index: index-v17
Prompt: prompt-v9
Model: model-x-v4

Avoid mutable production artifacts.


๐Ÿง  117. Disaster Recovery Deployment

A recovery architecture should define:

Primary
Secondary
Backup
Restore
Failover
Failback

๐Ÿง  118. RAG Disaster Recovery

flowchart LR
    A["Primary Region"] --> B["Replication"]
    B --> C["Secondary Region"]

    A --> D["Backup"]
    D --> E["Restore"]

    C --> F["Failover"]
    E --> F

๐Ÿง  119. RPO / RTO

Define:

RPO
Maximum acceptable data loss

RTO
Maximum acceptable recovery time

Example:

RPO = 15 minutes
RTO = 30 minutes

These are illustrative.


๐Ÿง  120. Deployment Observability Checklist

โ˜ Deployment version tracked
โ˜ Traffic split visible
โ˜ Error rate monitored
โ˜ Latency monitored
โ˜ Retrieval quality monitored
โ˜ Groundedness monitored
โ˜ Citation quality monitored
โ˜ Token usage monitored
โ˜ Cost monitored
โ˜ Index version tracked
โ˜ Rollback available

๐Ÿงช 121. Practical Project

Build a deployment platform for:

Production RAG Application

Support:

Docker
CI/CD
Staging
Canary
Blue-Green
Index Versioning
Prompt Versioning
Model Routing
Rollback
Observability

๐Ÿงช 122. Suggested Repository

production-rag-deployment/
โ”‚
โ”œโ”€โ”€ application/
โ”‚   โ”œโ”€โ”€ rag-api/
โ”‚   โ”œโ”€โ”€ retrieval/
โ”‚   โ””โ”€โ”€ generation/
โ”‚
โ”œโ”€โ”€ deployment/
โ”‚   โ”œโ”€โ”€ docker/
โ”‚   โ”œโ”€โ”€ kubernetes/
โ”‚   โ”œโ”€โ”€ helm/
โ”‚   โ””โ”€โ”€ manifests/
โ”‚
โ”œโ”€โ”€ infrastructure/
โ”‚   โ””โ”€โ”€ terraform/
โ”‚
โ”œโ”€โ”€ ci/
โ”‚   โ”œโ”€โ”€ build.yaml
โ”‚   โ”œโ”€โ”€ test.yaml
โ”‚   โ””โ”€โ”€ deploy.yaml
โ”‚
โ”œโ”€โ”€ evaluation/
โ”‚   โ”œโ”€โ”€ datasets/
โ”‚   โ””โ”€โ”€ gates/
โ”‚
โ”œโ”€โ”€ indexes/
โ”‚   โ”œโ”€โ”€ v1/
โ”‚   โ””โ”€โ”€ v2/
โ”‚
โ””โ”€โ”€ docs/
    โ”œโ”€โ”€ architecture/
    โ”œโ”€โ”€ deployment/
    โ””โ”€โ”€ runbooks/

๐Ÿงช 123. Deployment Exercise

Implement:

Version 1
 โ†“
Production

Version 2
 โ†“
Staging
 โ†“
Evaluation
 โ†“
Canary 5%
 โ†“
Canary 25%
 โ†“
Canary 50%
 โ†“
100%

Then deliberately introduce:

Higher Latency

and verify:

Monitoring
 โ†“
Alert
 โ†“
Rollback

๐Ÿงช 124. Index Deployment Exercise

Create:

Index V1

Then:

Index V2

with an improved chunking strategy.

Perform:

Backfill
 โ†“
Offline Evaluation
 โ†“
Dual Read
 โ†“
Compare
 โ†“
Canary
 โ†“
Switch

๐Ÿงช 125. Model Deployment Exercise

Compare:

Model A
vs
Model B

using:

Shadow Traffic

Measure:

Latency
Quality
Groundedness
Citation
Cost

๐Ÿงช 126. Multi-Region Exercise

Deploy:

Region A
Region B

Test:

Region A Failure

Verify:

Traffic โ†’ Region B

๐Ÿง  127. Deployment Anti-Patterns

Anti-Pattern 1

Deploy directly to 100%

without evaluation or canary for high-risk changes.


Anti-Pattern 2

Application + Index + Prompt + Model

all changed simultaneously without version tracking.


Anti-Pattern 3

Mutable Production Index

with no version or rollback capability.


Anti-Pattern 4

No Health Checks

Anti-Pattern 5

No Deployment Observability

Anti-Pattern 6

No Rollback

Anti-Pattern 7

Production and Development
sharing the same data

Anti-Pattern 8

Manual Production Changes

with no audit trail.


๐Ÿง  128. Deployment Design Principles

Principle 1 โ€” Deploy Small Changes

Small Change
 โ†“
Small Blast Radius
 โ†“
Easy Diagnosis

Principle 2 โ€” Separate Lifecycles

Treat these independently:

Application
Index
Knowledge
Model
Prompt

Principle 3 โ€” Automate Quality Gates

Evaluation
 โ†“
Deployment Decision

Principle 4 โ€” Make Rollback Easy

Rollback should be:

Fast
Tested
Automated
Observable

Principle 5 โ€” Prefer Progressive Delivery

Shadow
 โ†“
Canary
 โ†“
Progressive Rollout
 โ†“
Full Production

Principle 6 โ€” Observe Quality

Traditional deployment metrics are not enough.

Track:

Latency
+
Errors
+
Retrieval Quality
+
Groundedness
+
Citation Quality

๐Ÿง  129. Deployment Pattern Summary

MONOLITH
    โ†“
Simple

MODULAR MONOLITH
    โ†“
Structured

MICROSERVICES
    โ†“
Independent Scaling

SERVERLESS
    โ†“
Variable / Event-Driven

CONTAINERS
    โ†“
Portable Production

KUBERNETES
    โ†“
Complex Enterprise Platform

ROLLING
    โ†“
Incremental Replacement

BLUE-GREEN
    โ†“
Fast Rollback

CANARY
    โ†“
Controlled Risk

SHADOW
    โ†“
Production Comparison

A/B
    โ†“
Experimentation

ACTIVE-ACTIVE
    โ†“
High Availability

ACTIVE-PASSIVE
    โ†“
Disaster Recovery

DUAL READ
    โ†“
Migration

DUAL WRITE
    โ†“
Migration Synchronization

๐Ÿง  130. Final Mental Model

Production RAG deployment should be viewed as:

                    RAG DEPLOYMENT
                          โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                 โ–ผ                 โ–ผ
    APPLICATION         INDEX             MODEL
        โ”‚                 โ”‚                 โ”‚
     Version           Version           Version
        โ”‚                 โ”‚                 โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ–ผ
                    CONFIGURATION
                          โ”‚
                          โ–ผ
                    CI / CD PIPELINE
                          โ”‚
                          โ–ผ
                       STAGING
                          โ”‚
                          โ–ผ
                      EVALUATION
                          โ”‚
                          โ–ผ
                       CANARY
                          โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
                    โ–ผ           โ–ผ
                  PASS         FAIL
                    โ”‚           โ”‚
                    โ–ผ           โ–ผ
                PROMOTE      ROLLBACK
                    โ”‚
                    โ–ผ
                 PRODUCTION
                    โ”‚
                    โ–ผ
                OBSERVABILITY
                    โ”‚
                    โ–ผ
              CONTINUOUS IMPROVEMENT

๐Ÿง  131. Deployment Formula

A useful conceptual model:

Safe RAG Deployment
=
Versioning
+
Evaluation
+
Progressive Delivery
+
Observability
+
Rollback

๐Ÿง  132. What Makes RAG Deployment Production-Grade?

A production deployment should answer:

What changed?

Which version is running?

Which index is active?

Which model is active?

Which users receive the change?

How was the change evaluated?

What is the blast radius?

How do we monitor quality?

How do we rollback?

Can we reproduce the deployment?

Can we recover from regional failure?

If these questions cannot be answered, the deployment architecture is not mature enough.


๐Ÿ“š 133. Key Takeaways

  • RAG deployment involves more than deploying an application.
  • Application, retrieval, index, model, prompt, knowledge, and configuration have different lifecycles.
  • Version every important RAG artifact.
  • Monolithic RAG is appropriate for simple systems.
  • Modular monoliths provide strong boundaries without distributed-system overhead.
  • Microservices become useful when components require independent scaling or ownership.
  • Retrieval can be exposed as a shared platform capability.
  • Serverless is useful for variable and event-driven workloads.
  • Containers provide portability and predictable runtime environments.
  • Kubernetes is useful for complex enterprise platforms but introduces significant operational complexity.
  • Rolling deployments provide incremental replacement.
  • Blue-green deployments provide clean environments and fast rollback.
  • Canary deployments reduce blast radius.
  • Shadow deployments allow production comparison without affecting users.
  • A/B deployments enable controlled experimentation.
  • Multi-region deployments improve availability and latency but increase complexity.
  • Active-active architectures provide high availability at higher operational cost.
  • Active-passive architectures simplify disaster recovery.
  • Dedicated tenant deployment provides strong isolation at higher cost.
  • Shared tenant deployment improves infrastructure efficiency but requires strong isolation controls.
  • Hybrid tenant deployment balances cost and isolation.
  • Indexes should have independent versioning and deployment lifecycles.
  • Embedding migrations should use controlled index migration strategies.
  • Dual-read and dual-write patterns can help during large migrations.
  • RAG deployments should use immutable artifacts where practical.
  • CI/CD pipelines should include retrieval and generation evaluation, not just unit tests.
  • Quality gates should include retrieval quality, groundedness, citation quality, latency, and cost.
  • Progressive delivery is particularly valuable for high-risk RAG changes.
  • Deployment observability must measure AI-specific quality signals.
  • Rollback should be possible for application, retriever, index, prompt, model, and configuration independently where architecture permits.
  • Schema evolution must maintain compatibility during rolling deployments.
  • Knowledge deployment and application deployment should be treated as separate lifecycles.
  • Infrastructure should be managed through infrastructure-as-code.
  • Secrets should never be stored in source control.
  • Production deployments should be observable, reproducible, auditable, and reversible.
  • The correct deployment pattern depends on scale, availability, security, latency, team capability, cost, and business risk.
  • The objective is not the most sophisticated deployment architecture.
  • The objective is safe, measurable, repeatable, scalable, and reversible RAG delivery.

๐Ÿงญ 134. Chapter Navigation

Part VI โ€” Production RAG Deployment & Operations

Previous:
11. Building Production RAG Systems

Next:
13. RAG Caching Strategies

Production RAG Engineering Path

01 Prompt Assembly
        โ†“
02 Context Selection & Context Engineering
        โ†“
03 Response Validation
        โ†“
04 Citation & Source Attribution
        โ†“
05 Enterprise Response
        โ†“
06 RAG Evaluation & Benchmarking
        โ†“
07 RAG Observability
        โ†“
08 RAG Performance Optimization
        โ†“
09 RAG Cost Optimization
        โ†“
10 Production Retrieval Architecture
        โ†“
11 Building Production RAG Systems
        โ†“
12 RAG Deployment Patterns
        โ†“
13 RAG Caching Strategies
        โ†“
14 Multi-Tenant RAG
        โ†“
15 RAG Testing Frameworks
        โ†“
16 RAG Failure Patterns

Enterprise AI Engineering Handbook
Building Production-Grade Enterprise AI Systems โ€” One Chapter at a Time.