Database / ChromaDB Interview Questions
How does ChromaDB's PersistentClient store data on disk, and what are its limitations?
The PersistentClient stores data in a directory you specify. Inside, ChromaDB uses SQLite for metadata (IDs, document text, metadata key-value pairs) and binary files for the HNSW vector index. All writes are flushed to disk automatically — there is no explicit save/commit step.
import chromadb import os # Create or open a persistent database client = chromadb.PersistentClient(path="./my_vector_db") # After this call, ./my_vector_db/ contains: # - chroma.sqlite3 (metadata, documents, IDs) # - <uuid>/ (one folder per collection) # - header.bin (HNSW index configuration) # - data_level0.bin (HNSW graph layer 0) # - length.bin (element count) col = client.get_or_create_collection("notes") col.add( documents=["Remember to buy milk", "Meeting at 3pm tomorrow"], ids=["n1", "n2"], ) # Data is persisted immediately â no commit needed # Verify data survives restart: del client, col # simulate process exit client2 = chromadb.PersistentClient(path="./my_vector_db") col2 = client2.get_collection("notes") print(col2.count()) # 2 â still there! print(col2.get(ids=["n1"])["documents"]) # ["Remember to buy milk"] # Check the files on disk for root, dirs, files in os.walk("./my_vector_db"): for f in files: print(os.path.join(root, f))
| Limitation | Detail |
|---|---|
| Single writer only | SQLite allows only one writer at a time — concurrent writes from multiple processes cause errors |
| No built-in replication | The SQLite file is a single point of failure; back it up manually |
| No horizontal scaling | Cannot distribute load across multiple machines |
| File locking | Moving or copying the directory while the client is open can corrupt data |
| Migration | Upgrading ChromaDB versions may require running migration scripts on the SQLite DB |
For multi-process or production deployments, prefer running chroma run --path ./data as a server and connecting with HttpClient.
More Related questions...