A high-performance distributed vector database system designed for scale. VectorHub shards Redis for speed, exposes a gRPC interface for fast insert/search operations, and replicates cleanly for high availability. Stress-tested to handle over 1 million vector writes per minute while keeping lookups under 100ms.
- Horizontal Scaling: Consistent hashing-based sharding across multiple Redis instances
- High Performance: Optimized for 1M+ vector operations/minute with sub-100ms search latency
- Replication: Built-in replication with automatic failover and lag monitoring
- gRPC API: Fast binary protocol with streaming support
- Multiple Distance Metrics: Cosine similarity, Euclidean distance, and dot product
- Monitoring: Prometheus metrics and health endpoints
- Production Ready: Docker support, comprehensive testing, and operational tooling
- Go 1.21+
- Docker & Docker Compose
- Redis (for local development)
# Clone the repository
git clone https://github.com/elcruzo/vectorhub
cd vectorhub
# Start with Docker Compose (recommended)
docker-compose up -d
# Or build and run locally
make build
./bin/vectorhub -config configs/config.yamlpackage main
import (
"context"
"log"
"github.com/elcruzo/vectorhub/pkg/client"
)
func main() {
// Connect to VectorHub
client, err := client.NewClient(&client.Config{
Address: "localhost:50051",
})
if err != nil {
log.Fatal(err)
}
defer client.Close()
ctx := context.Background()
// Create an index
err = client.CreateIndex(ctx, client.CreateIndexOptions{
Name: "embeddings",
Dimension: 128,
Metric: "cosine",
ShardCount: 8,
ReplicaCount: 2,
})
// Insert a vector
err = client.Insert(ctx, "embeddings", "doc-1",
[]float32{0.1, 0.2, 0.3, /* ... */},
map[string]string{"category": "document"})
// Search for similar vectors
results, err := client.Search(ctx, "embeddings",
[]float32{0.1, 0.2, 0.3, /* ... */},
client.SearchOptions{
TopK: 10,
IncludeMetadata: true,
})
for _, result := range results {
log.Printf("ID: %s, Score: %f", result.ID, result.Score)
}
}┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ gRPC Client │ │ gRPC Client │ │ gRPC Client │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────┐
│ VectorHub │
│ gRPC Server │
└─────────────────┘
│
┌─────────────────┐
│ Shard Manager │
│ (Consistent Hash)│
└─────────────────┘
│
┌────────────┬────────────┼────────────┬────────────┐
│ │ │ │ │
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│ Redis 0 │ │ Redis 1 │ │ Redis 2 │ │ Redis 3 │ │ Redis N │
│ Primary │ │ Replica │ │ Primary │ │ Replica │ │ ... │
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘
- Vector Service: Core gRPC service handling CRUD operations
- Shard Manager: Routes requests using consistent hashing
- Replication Manager: Handles primary-replica synchronization
- Storage Layer: Redis adapter with connection pooling
- Metrics Collector: Prometheus metrics for monitoring
- Insert Throughput: 1M+ vectors/minute
- Search Latency: <100ms for 99th percentile
- Batch Operations: 10K+ vectors per batch
- Memory Efficiency: <1KB overhead per vector
- Connection pooling and keepalive
- Parallel batch operations
- Efficient vector serialization
- Query result caching
- Background health monitoring
server:
grpc_port: 50051
metrics_port: 9090
redis:
addresses:
- "localhost:6379"
- "localhost:6380"
password: ""
pool_size: 100
sharding:
shard_count: 8
replica_count: 2
virtual_nodes: 150
replication:
factor: 2
sync_interval_seconds: 5
async_replication: true
metrics:
enabled: true
namespace: "vectorhub"All configuration options can be overridden with environment variables:
export VECTORHUB_REDIS__ADDRESSES="redis1:6379,redis2:6379"
export VECTORHUB_SHARDING__SHARD_COUNT=16
export VECTORHUB_LOGGING__LEVEL=debugInsert(vector)- Insert a single vectorBatchInsert(vectors)- Insert multiple vectors in parallelSearch(query, options)- Find similar vectorsGet(id)- Retrieve a vector by IDUpdate(id, vector)- Update an existing vectorDelete(id)- Delete a vectorCreateIndex(options)- Create a new vector indexDropIndex(name)- Delete an indexGetStats(index)- Get index statistics
- Cosine Similarity:
cosine(default for normalized vectors) - Euclidean Distance:
euclidean(good for spatial data) - Dot Product:
dot_product(fast for high-dimensional data)
VectorHub exposes Prometheus metrics on /metrics:
vectorhub_vectors_inserted_totalvectorhub_searches_totalvectorhub_latency_search_secondsvectorhub_shards_statusvectorhub_replication_lag_seconds
- gRPC health checks: Use
grpc_health_probe - HTTP health endpoint:
GET /healthon metrics port - Shard health monitoring with automatic failover
# Install dependencies
make install-tools
# Generate protobuf code
make proto
# Run tests
make test
# Build binary
make build
# Run benchmarks
make benchmark# Unit tests
make test-unit
# Integration tests (requires Redis)
make test-integration
# Benchmark tests
make test-benchmark
# Coverage report
make coverage# Build Docker image
make docker-build
# Run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f vectorhub
# Scale Redis instances
docker-compose up -d --scale redis=6The included docker-compose.yml provides a production-ready setup with:
- 4 Redis instances for sharding
- VectorHub server
- Prometheus for metrics
- Grafana for dashboards
Deploy to Kubernetes using the provided manifests:
kubectl apply -f deployments/k8s/- Horizontal Scaling: Add more Redis shards
- Vertical Scaling: Increase memory and CPU resources
- Replication: Increase replica count for higher availability
- Load Balancing: Use multiple VectorHub instances behind a load balancer
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Go best practices and
gofmtformatting - Write comprehensive tests for new features
- Update documentation for API changes
- Benchmark performance-critical code
This project is licensed under the MIT License - see the LICENSE file for details.
- Vector compression and quantization
- GPU acceleration for similarity computation
- Graph-based indexing (HNSW)
- Multi-tenant isolation
- REST API gateway
- Vector analytics and insights
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
VectorHub - Built for scale, optimized for speed, designed for reliability.