Zero Downtime Embedding Model Migration: Blue Green Indexes
In this article
This guide walks you through migrating an embedding model in a live search or vector database system without any downtime, using a blue/green index strategy. You create a new index with the new model, backfill it, then atomically swap traffic to it, while keeping the old index ready for instant rollback.
What You'll Need
- A vector database that supports multiple indexes per collection or separate collections (e.g., Elasticsearch, OpenSearch, Qdrant, Weaviate, Milvus, Pinecone).
- Access to the application code that queries the index, so you can change the index name via a configuration flag or environment variable.
- A script or pipeline to re-embed your entire dataset with the new model (or a way to generate embeddings in bulk).
- Monitoring for query latency, error rates, and index health (e.g., green status in Elasticsearch).
- A rollback plan: the ability to switch the application back to the old index quickly.
Step-by-Step
- Prepare the new model and embeddings. Ensure your new embedding model is available and produces vectors of the same dimensionality as your old model, or adjust your schema accordingly. If dimensions differ, you must create a new index with the new vector size.
- Create the new (blue) index. Name it clearly, e.g.,
my-index-v2, while the old (green) index remainsmy-index-v1. Configure the index with the same settings as the old one (distance metric, quantization, etc.), but with the vector dimension matching the new model. - Backfill the new index. Run a batch job that reads all documents from your primary data store (or the old index), generates embeddings using the new model, and writes them to the new index. Do this in parallel with your live traffic to the old index. Monitor the backfill progress and ensure it completes without errors.
- Verify data parity. After backfill, run integrity checks: compare document counts, sample a few embeddings to ensure they are not null or malformed, and run a few test queries against the new index to confirm results look reasonable.
- Update the application configuration. Change the index name in your application's configuration (or environment variable) from
my-index-v1tomy-index-v2. This is the moment of switchover. Do this in a controlled way, ideally during low traffic, and ensure your application can handle the change without restarting (e.g., via dynamic config reload). - Monitor the switchover. Watch query latency, error rates, and index health for a period (e.g., 15–30 minutes). If everything looks good, proceed. If not, immediately switch back to the old index by reverting the configuration.
- Keep the old index for rollback. Do not delete the old index immediately. Keep it for at least a few days or until you are confident the new model is stable. This is your green index for rollback.
- Clean up (optional). After the observation period, you can delete the old index to free storage, but only if you have a backup or can rebuild it quickly if needed.
Common Mistakes
- Not testing the new index with real queries before switchover. Always run sample queries and compare result quality against the old index.
- Switching all traffic at once without a canary. If possible, route a small percentage of traffic to the new index first to catch issues early.
- Forgetting to update the vector dimension in the index mapping. This causes indexing failures or query errors.
- Deleting the old index too soon. Keep it until you are absolutely sure the new model is better and stable.
- Ignoring index health. A yellow or red index can cause partial results or timeouts.
Tips
- Use a naming convention like
index-v1,index-v2to make the blue/green clear. - Automate the backfill and verification steps as much as possible to reduce human error.
- If your vector database supports aliases, use them: point an alias to the active index, and switch the alias during migration. This avoids changing the application code at all.
- Run a small-scale A/B test comparing search quality metrics (e.g., click-through rate) before full switchover, if you have such data.
- Document the exact rollback steps and test them in a staging environment.
Troubleshooting
New index is not returning results after switchover. Check that the application is actually using the new index name (verify logs or config). Check index health and that documents were indexed correctly. Re-run a sample query directly against the index.
Backfill job fails halfway. Resume from the last checkpoint if your job supports it, or restart from scratch. Ensure you have enough disk space and memory. Check for errors in the embedding generation (e.g., API rate limits).
Query latency spikes after switchover. The new index may not be fully optimized (e.g., missing warm-up). Let it run for a few minutes; if it persists, check if the index has enough replicas or if the vector search parameters need tuning.
Rollback is needed. Immediately revert the configuration to the old index name. The old index is still there and serving. If you used an alias, just switch the alias back. Then investigate what went wrong with the new model.
Dimension mismatch error. If the new model outputs a different vector size, you must create a new index with the correct dimension. You cannot change the dimension of an existing index.
Frequently Asked Questions
What is a blue/green index?
It's a deployment strategy where you run two identical environments (blue and green) side by side. In this case, the two environments are the old and new vector indexes. You switch traffic from one to the other atomically, and can roll back instantly.
Do I need to re-embed all my data with the new model?
Yes, because the new model produces different vectors. You must generate embeddings for all documents and store them in the new index. This is the most time-consuming part, so plan for it.
Can I use the same index name for both models?
No, you need two separate indexes with different names (or use aliases). If you overwrite the same index, you lose the ability to roll back.
How long should I keep the old index?
Keep it for at least a few days, or until you are confident the new model performs well in production. Some teams keep it for weeks or even permanently if storage is cheap.
What if my vector database doesn't support multiple indexes?
Most do. If not, you can create a separate collection or a separate cluster. The principle is the same: have both available and switch traffic.
Can I automate the switchover?
Yes, you can use a configuration management tool or a feature flag system that allows you to flip the index name without redeploying. Just ensure you have a rollback mechanism.