Database / ChromaDB Interview Questions
How do you run ChromaDB as a standalone HTTP server and connect to it from multiple clients?
For production or multi-process environments, run ChromaDB as a persistent HTTP server and connect all clients via chromadb.HttpClient(). This removes the single-writer SQLite limitation and allows any number of clients — including different languages — to share the same database.
# --- SERVER SIDE --- # Install: pip install chromadb # Start the server from the command line: # chroma run --path ./chroma_data --port 8000 --host 0.0.0.0 # Or run programmatically (e.g. in tests): import chromadb from chromadb.config import Settings # --- CLIENT SIDE --- client = chromadb.HttpClient( host="localhost", port=8000, ) # Verify server is reachable client.heartbeat() # raises ConnectionError if server is down # Usage is identical to PersistentClient collection = client.get_or_create_collection( "shared_docs", metadata={"hnsw:space": "cosine"}, ) collection.add( documents=["Shared document from client 1"], ids=["s1"], ) results = collection.query(query_texts=["shared content"], n_results=1) print(results["documents"]) # With authentication (chromadb server configured with auth) client_auth = chromadb.HttpClient( host="my-server.example.com", port=443, ssl=True, headers={"Authorization": "Bearer my-token"}, )
# docker-compose.yml â containerised ChromaDB server # version: "3.9" # services: # chromadb: # image: chromadb/chroma:latest # ports: # - "8000:8000" # volumes: # - chroma_data:/chroma/chroma # environment: # - IS_PERSISTENT=TRUE # - ANONYMIZED_TELEMETRY=FALSE # volumes: # chroma_data:
| Mode | Concurrency | Network | Use case |
|---|---|---|---|
| EphemeralClient | Single process only | None | Tests, notebooks |
| PersistentClient | Single writer only | None | Local scripts, dev |
| HttpClient | Multiple clients | HTTP/HTTPS | Production, microservices |
More Related questions...