Persistence & Production Patterns
From the course ChromaDB: Local Vector Database
Taking ChromaDB to Production
Data Persistence
# Data persists automatically with PersistentClient
client = chromadb.PersistentClient(path="/data/chroma")
# Data survives restarts — just reconnect
collection = client.get_collection("my_docs")
print(f"Loaded {collection.count()} documents")
Client-Server Mode
Run ChromaDB as a service for multi-process access:
# Start server
chroma run --host localhost --port 8000 --path /data/chroma
# Connect from any process
client = chromadb.HttpClient(host="localhost", port=8000)
Docker Deployment
services:
chromadb:
image: chromadb/chroma:latest
ports:
- "8000:8000"
volumes:
- chroma_data:/chroma/chroma
environment:
- CHROMA_SERVER_AUTH_CREDENTIALS=your-token
When to Use ChromaDB vs. Cloud Solutions
Use ChromaDB when:
- Developing and prototyping locally
- Data must stay on-premise
- Low latency is critical (no network hop)
- Dataset is under ~1M vectors
Use cloud (Pinecone, Weaviate) when:
- Scaling beyond single-machine capacity
- Need managed infrastructure
- Require cross-region availability
- Team needs shared access to indexes
Common Pitfall: Running ChromaDB Without Authentication in Client-Server Mode
By default, the ChromaDB server starts without any authentication. If you expose port 8000 publicly — even briefly — anyone can read, modify, or delete your data. Always enable token authentication before exposing the server:
environment:
- CHROMA_SERVER_AUTH_PROVIDER=chromadb.auth.token.TokenAuthServerProvider
- CHROMA_SERVER_AUTH_CREDENTIALS=your-secret-token
- CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER=X_CHROMA_TOKEN
Then connect from the client using:
client = chromadb.HttpClient(
host="localhost",
port=8000,
headers={"X-Chroma-Token": "your-secret-token"},
)
Best Practice: Separate Ingestion and Query Clients
In production, use separate process groups for ingestion (write-heavy) and querying (read-heavy). Point both to the same persistent data directory via ChromaDB's HTTP server. This prevents a slow bulk ingestion job from blocking user-facing search queries.
Named Product Reference: Coolify + ChromaDB
If you are already using Coolify for self-hosted deployments, the ChromaDB Docker image deploys in minutes using the same one-click service workflow. Pair it with Supabase (also deployable on Coolify) to store document metadata in Postgres while ChromaDB handles the vector index — a cost-effective alternative to Pinecone for teams on a budget.
Key Takeaways
- •PersistentClient automatically saves data to disk
- •Client-server mode enables multi-process access
- •Docker deployment provides easy production hosting
- •ChromaDB is ideal for local dev, on-premise, and datasets under 1M vectors
Progress is kept in this browser only.