Skip to main content

Overview

Chroma provides multiple configuration options to optimize performance for your specific workload. This guide covers index configuration, query optimization, batch operations, and best practices for high-performance deployments.

Index Configuration

Chroma supports multiple index types, each with configurable parameters. Proper index configuration is critical for query performance.

HNSW Vector Index

Hierarchical Navigable Small World (HNSW) is the default vector index algorithm, providing excellent query performance with configurable accuracy/speed tradeoffs.

HNSW Configuration

Or using the new schema API:

HNSW Parameters

HNSW Tuning Guidelines

For high accuracy (recall > 0.95):
For balanced performance:
For fast queries (lower accuracy acceptable):
For large-scale ingestion:

SPANN Vector Index

SPace Partition and Nearest Neighbor search (SPANN) is designed for billion-scale vector search with disk-based storage.

SPANN Configuration

SPANN Parameters

When to Use SPANN

Use SPANN when:
  • Dataset size > 10M vectors
  • Memory is limited relative to dataset size
  • Disk I/O bandwidth is sufficient
  • Acceptable trade-off: slightly lower recall for massive scale

Distance Metrics (Space)

Choose the appropriate distance metric for your embeddings:
Guidelines:
  • Cosine - Best for normalized embeddings (most embedding models)
  • L2 - Best for absolute distance measurements
  • Inner Product - Best when embeddings have meaningful magnitudes

Full-Text Search Index

Optimize full-text search for document queries:
FTS is automatically enabled on the #document field and supports efficient text search with BM25 ranking.

Metadata Inverted Indexes

Chroma automatically creates inverted indexes for metadata fields:
These indexes enable fast filtering with where clauses.

Query Optimization

Limiting Results

Always limit results to what you need:

Selective Field Inclusion

Only include fields you need:

Efficient Filtering

Structure where clauses for optimal performance:

Read Level Control

Control consistency vs. performance tradeoff:
Use INDEX_ONLY when:
  • Query latency is critical
  • Eventual consistency is acceptable
  • Workload is read-heavy with infrequent writes

Batch Operations

Batch Inserts

Always batch inserts for better performance:

Optimal Batch Size

Balance throughput vs. memory:

Batch Queries

Query multiple vectors in a single call:

Memory Management

Memory Limits

Set memory limits to prevent OOM:

LRU Cache Configuration

Enable LRU caching for segment data:
LRU cache evicts least recently used segments when memory limit is reached.

Resource Limits

Increase file descriptor limits for high concurrency:
Or set system-wide:

Connection Pooling

Configure HTTP connection pooling for remote clients:

Parallel Query Execution

Leverage multiple threads for queries:

Server-Side Configuration

Thread Pool Size

Increase for high concurrency:

gRPC Timeouts

Adjust for your workload:

Performance Best Practices

Ingestion

  1. Batch inserts - Use batches of 500-5000 depending on embedding size
  2. Pre-compute embeddings - Generate embeddings before inserting
  3. Use multiple threads - Parallelize embedding generation
  4. Tune HNSW construction - Lower ef_construction for faster builds
  5. Increase sync_threshold - Reduce disk writes during bulk inserts

Querying

  1. Limit results - Only request what you need
  2. Use appropriate ef_search - Balance recall vs. speed
  3. Enable INDEX_ONLY - For read-heavy workloads
  4. Batch queries - Query multiple vectors at once
  5. Filter efficiently - Use simple where clauses when possible
  6. Cache results - Cache frequent queries at application level

Memory

  1. Set memory limits - Prevent OOM with chroma_memory_limit_bytes
  2. Enable LRU cache - For datasets larger than RAM
  3. Monitor memory usage - Track with observability tools
  4. Use persistent storage - Don’t rely on in-memory for large datasets

Scaling

  1. Horizontal scaling - Use distributed Chroma for massive scale
  2. Read replicas - Separate read and write workloads
  3. Partition collections - Split large collections by tenant or category
  4. Monitor query latency - Track p50, p95, p99 percentiles

Benchmarking

Measure your specific workload:

Troubleshooting Performance

Slow Queries

  1. Check ef_search - may be too high
  2. Verify index is built - check collection count
  3. Review where clause complexity
  4. Monitor memory pressure - may be swapping
  5. Check network latency - for remote clients

Slow Ingestion

  1. Increase batch size
  2. Lower ef_construction
  3. Increase num_threads
  4. Increase sync_threshold
  5. Pre-generate embeddings

High Memory Usage

  1. Set chroma_memory_limit_bytes
  2. Enable LRU cache policy
  3. Reduce batch sizes
  4. Use persistent storage
  5. Check for memory leaks in custom embedding functions

Next Steps