6400: Vector Databases¶
Module Overview¶
This module covers production vector database systems for RAG applications. You'll learn to deploy, scale, and optimize vector databases like Qdrant, Pinecone, and Weaviate. Lesson 6404 adds the compression mechanics underneath: scalar, binary, and product quantization with the oversampling and rescore economics that make a lossy index useful.
Why This Matters:
- Vector databases power scalable RAG systems
- Production deployment requires performance, reliability, and security
- Different databases excel at different use cases
- Proper indexing and scaling are critical for performance
Learning Objectives¶
After completing this module, you will be able to:
- Vector Database Architecture: Understand how vector databases work
- Qdrant Setup: Deploy and configure Qdrant for production
- Pinecone vs Weaviate: Compare managed vs self-hosted solutions
- Performance Optimization: Tune indexes, shards, and replication
- Production Deployment: Build scalable, reliable vector systems
- Vector Compression: Implement scalar, binary, and product quantization and price the oversampling-rescore trade
Module Contents¶
6401: Qdrant Setup¶
Self-Hosted Vector Database
- Why Qdrant: architecture and features
- Docker deployment and verification
- The Qdrant Python client
- Production configuration
- Snapshots, backups, and troubleshooting
Experiments:
- Deploy Qdrant locally
- Create and populate collections
- Implement filtered search
- Benchmark query performance
6402: Vector Database Comparison¶
Managed vs Self-Hosted Solutions
- Feature matrix across major vector databases
- Deep dives: Pinecone, Weaviate, Qdrant, and more
- Benchmarks and performance
- Client implementations
- Selection criteria and migration paths
Experiments:
- Deploy both databases
- Compare query performance
- Test scalability
- Analyze cost vs performance
6404: Vector Compression and Quantization¶
SQ, Binary, and Product as Working Code
- The memory ledger: 15.36 GB raw against 3.84/0.48/0.24 GB compressed
- Scalar quantization: the int8 range and the quantile measurement decision
- Binary quantization: sign bits, Hamming ranking, and the rescore default
- Product quantization: the codebook split and ADC lookups
- The oversampling and rescore campaign
Experiments:
- Re-run product quantization with m=16 instead of 8
- Run the campaign with limit=5 and check the os=1 no-op row
- Measure recall on your own collection before choosing quantile bounds
6403: Qdrant Production Deployment¶
Production Vector Database Self-Hosted (Guide)
- Deployment targets and Docker deployment
- Initial configuration and performance tuning
- Backup strategy, monitoring, security hardening
- RAG integration
- Troubleshooting and optional K3s deployment
Guide: guides/6403-Qdrant-Production-Deployment.md
Prerequisites¶
Before starting this module, ensure you have:
- Module 6100: Vector Embeddings (vector fundamentals)
- Module 6200: Retrieval Strategies (retrieval strategies)
- Docker and container basics
- Linux system administration
- Database fundamentals
Review: PREREQUISITES.md for detailed requirements.
Assessment¶
Quiz¶
- Format: 20 multiple-choice questions
- Passing Score: 80% (16/20)
- Topics: Vector databases, Qdrant, Pinecone, Weaviate
- Location: 6400: Vector Databases - Quiz
Practice Exercises¶
- Format: Vector database deployment projects
- Duration: 3 hours
- Topics:
- Deploy Qdrant in production
- Compare Pinecone vs Weaviate
- Optimize database performance
- Set up backups and monitoring
- Location: 6400: Vector Databases - Practice
Related Modules¶
This module connects to:
- 6100: Vector Embeddings (embedding generation)
- 6200: Retrieval Strategies (retrieval strategies)
- 6300: Context Management (context management)
- 6500: MLOps Pipelines for RAG (production ML)
Time Commitment¶
| Activity | Time |
|---|---|
| 6401: Qdrant Setup | 3 hours |
| 6402: Vector Database Comparison | 3 hours |
| 6404: Vector Compression and Quantization | 3 hours |
| Guide (6403) | 5 hours |
| Quiz | 30 minutes |
| Practice | 3 hours |
| Total | 17.5 hours |
Resources¶
Vector Databases:
- Qdrant (self-hosted)
- Pinecone (managed)
- Weaviate (self-hosted)
- Milvus (self-hosted)
- pgvector (PostgreSQL extension)
Essential Tools:
- Docker / Docker Compose
- Python client libraries
- Monitoring tools (Prometheus, Grafana)
Vector Database Comparison¶
| Feature | Qdrant | Pinecone | Weaviate | pgvector |
|---|---|---|---|---|
| Deployment | Self-hosted | Managed | Self-hosted | Self-hosted |
| Performance | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
| Ease of Use | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| Features | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
| Cost | Low (self) | High (managed) | Low (self) | Very low |
| Best For | Production | Rapid start | Rich features | Simple needs |
Qdrant Configuration¶
storage:
# Performance tuning
optimizers_cpu_threshold: 0.5
optimizer_indexing_threshold: 20000
# Memory management
max_optimization_threads: 2
service:
# API configuration
max_workers: 0 # Auto
# HNSW parameters
hnsw_index:
m: 16
ef_construct: 100
full_scan_threshold: 10000
Performance Tuning Parameters¶
| Parameter | Qdrant | Pinecone | Weaviate |
|---|---|---|---|
| Index Type | HNSW | HNSW | HNSW |
| M (connectivity) | 16 | N/A | 16 |
| ef_construction | 100 | N/A | 100 |
| ef_search | Tunable | Auto | Tunable |
| Sharding | Yes | Yes | Yes |
Deployment Options¶
| Option | Complexity | Cost | Control |
|---|---|---|---|
| Local Docker | Low | Minimal | Full |
| Cloud VM | Medium | Low | Full |
| Kubernetes | High | Medium | Full |
| Pinecone Managed | Low | High | Limited |
| Serverless | Low | Variable | Limited |
Backup Strategies¶
| Strategy | RTO | RPO | Complexity |
|---|---|---|---|
| Snapshot backups | Minutes | Hours | Medium |
| Replication | Seconds | Minutes | High |
| S3/Cloud storage | Hours | Hours | Low |
Tips for Success¶
- Start with Qdrant: Best open-source option
- Use managed for MVP: Pinecone is fastest to start
- Optimize HNSW parameters: Small changes, big impact
- Monitor memory: Vector databases are memory-hungry
- Test with real data: Synthetic benchmarks lie
Common Pitfalls¶
- Wrong index parameters: HNSW tuning is critical
- Ignoring filters: Payload filtering needs optimization
- Under-provisioning: Vector databases need RAM
- No backups: Data loss is catastrophic
- Skipping monitoring: Performance degrades silently
When to Choose Each Database¶
| Scenario | Recommended |
|---|---|
| Production, control | Qdrant |
| Quick start, low effort | Pinecone |
| Rich ecosystem, self-hosted | Weaviate |
| Existing PostgreSQL | pgvector |
| Enterprise, on-prem | Milvus |
Cost Comparison (Monthly)¶
| Database | 1M vectors | 10M vectors | 100M vectors |
|---|---|---|---|
| Qdrant (self) | $20 | $100 | $500 |
| Pinecone ( Starter) | $70 | $200+ | Custom |
| Weaviate (self) | $20 | $100 | $500 |
| pgvector (self) | $10 | $50 | $200 |
Production Checklist¶
Before deploying to production:
- HNSW parameters tuned
- Backup strategy configured
- Monitoring set up
- Replication configured
- Security (auth, TLS) enabled
- Load testing completed
- Disaster recovery tested
- Documentation complete
Next Module: 6500: MLOps Pipelines for RAG
Previous Module: 6300: Context Management
Questions? Review the PREREQUISITES.md or check Phase 6 documentation.