
Environment Separation: Dev, Staging, and Prod
Learn how to manage multiple vector environments. Master data migration between Dev, Staging, and Production indexes.
Environment Separation: Dev, Staging, and Prod
Moving a vector-powered AI app to production is not as simple as "Hitting deploy." You are managing not only code but Data State. If your developers test a new "Sliding Window" chunking strategy (Module 7.1) directly in the production database, they will corrupt the search results for every user.
In this lesson, we learn how to isolate our environments effectively.
1. Why Isolation is Mandatory
- Data Integrity: Preventing test data (e.g., "Find the flying purple penguin") from appearing in real customer results.
- Cost Controls: Developers often run heavy re-indexing jobs. You don't want these jobs consuming the CPU/RAM of your live production instance.
- Model Drift: If your Dev environment uses a newer embedding model than Prod, your code will fail when deployed because the vector dimensions won't match (Module 1.4).
2. The Three-Tier Strategy
- Development (Dev):
- Uses Local Chroma or a free-tier Pinecone.
- Data is small and volatile.
- Purpose: Testing logic and tool integration.
- Staging (Pre-Prod):
- Matches Production hardware and model versions.
- Data is a Sample (10-20%) of real production data.
- Purpose: Benchmarking latency and recall accuracy.
- Production (Prod):
- High-Availability, Multi-AZ (Module 15.4).
- Sealed to developer access.
- Purpose: Serving real users.
3. The Migration Workflow
How do you move from Staging to Prod? You don't move the vectors. You move the code and the data source.
The Flow:
- Commit the code (e.g., a new chunking function).
- Run a background job in Prod to process the Raw Data using the new function.
- Create a New Index in Prod (Module 17.3).
- Swap the "Index Pointer" to the new version once indexing is complete.
4. Implementation: Environment Configuration (Python)
import os
# Use environment variables to point to the correct instance
ENV = os.getenv("APP_ENV", "dev")
CONFIG = {
"dev": {"index": "test-index", "host": "localhost:8000"},
"prod": {"index": "real-data-v1", "host": "api.pinecone.io"}
}
current_config = CONFIG.get(ENV)
5. Summary and Key Takeaways
- Never Test in Prod: Even for "Small" agents, keep a separate dev index.
- Match Embeddings: Ensure all environments use the exact same embedding model and dimensionality.
- Sample Data: Staging should contain a realistic "Edge case" dataset to catch retrieval errors before they hit users.
- Automated Deploys: Use CI/CD to update your vector metadata and configurations.
In the next lesson, we’ll look at Monitoring and Observability—the "Pulse" of your production system.