Deployment and Operations¶
This document provides guidelines for deploying and operating GoVector in production environments. It covers deployment strategies, configuration options, monitoring, and best practices.
π Deployment Options¶
Embedded Mode¶
Embedded mode is the simplest deployment option, where GoVector runs directly within your application process.
Use Cases¶
- Single-instance applications
- Edge devices
- Applications with low traffic
- Development and testing
Deployment Steps¶
- Add as a dependency:
- Initialize in your application:
import (
"github.com/yourusername/govector/core"
)
// Initialize collection
collection, err := core.NewCollection(core.CollectionConfig{
Name: "my-collection",
VectorLen: 768,
Metric: core.Cosine,
IndexType: core.HNSW,
Quantize: true, // Enable quantization for production
})
if err != nil {
log.Fatalf("Failed to create collection: %v", err)
}
// Save collection on shutdown
defer func() {
if err := collection.Save("/path/to/persistence"); err != nil {
log.Printf("Failed to save collection: %v", err)
}
}()
Microservice Mode¶
Microservice mode runs GoVector as a standalone server, accessible via HTTP API.
Use Cases¶
- Multi-application systems
- Language-agnostic environments
- High-traffic applications
- Centralized vector storage
Deployment Steps¶
- Build the server:
- Run the server:
- Using systemd:
Create a systemd service file /etc/systemd/system/govector.service:
[Unit]
Description=GoVector Vector Database
After=network.target
[Service]
Type=simple
User=youruser
WorkingDirectory=/path/to/govector
ExecStart=/path/to/govector-server --host 0.0.0.0 --port 6333 --data ./data
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Start and enable the service:
π§ Configuration¶
Server Configuration¶
| Flag | Description | Default |
|---|---|---|
--host |
Host to listen on | 127.0.0.1 |
--port |
Port to listen on | 6333 |
--data |
Data directory | ./data |
--log-level |
Log level (debug, info, warn, error) | info |
Environment Variables¶
| Variable | Description | Default |
|---|---|---|
GOVECTOR_HOST |
Host to listen on | 127.0.0.1 |
GOVECTOR_PORT |
Port to listen on | 6333 |
GOVECTOR_DATA_DIR |
Data directory | ./data |
GOVECTOR_LOG_LEVEL |
Log level | info |
π Monitoring¶
Health Check¶
GoVector provides a health check endpoint:
Metrics¶
GoVector exposes Prometheus-compatible metrics at http://localhost:6333/metrics:
govector_collection_count- Number of collectionsgovector_point_count{collection="name"}- Number of points per collectiongovector_search_requests_total- Total search requestsgovector_search_duration_seconds- Search latencygovector_upsert_requests_total- Total upsert requestsgovector_upsert_duration_seconds- Upsert latency
Logging¶
GoVector logs to stdout/stderr by default. For production, consider redirecting logs to a centralized logging system:
π‘οΈ Security¶
Network Security¶
- Use HTTPS in production
- Limit network access to trusted clients
- Use a reverse proxy (e.g., Nginx) for additional security
Authentication¶
While GoVector doesn't include built-in authentication, you can add it using a reverse proxy:
server {
listen 443 ssl;
server_name govector.example.com;
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem;
location / {
proxy_pass http://localhost:6333;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Basic authentication
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
πΎ Backup and Recovery¶
Backup¶
Regularly backup the data directory:
# Create backup
mkdir -p /backup/govector
cp -r /path/to/data/* /backup/govector/
# Compress backup
tar -czf /backup/govector-$(date +%Y%m%d).tar.gz /backup/govector/
Recovery¶
To recover from a backup:
- Stop GoVector
- Restore the backup:
# Restore from backup
tar -xzf /backup/govector-20231201.tar.gz -C /path/to/
# Set correct permissions
chown -R youruser:yourgroup /path/to/data
- Start GoVector
π Performance Tuning¶
For High Traffic¶
- Use SSD storage for better I/O performance
- Enable SQ8 quantization to reduce memory usage
- Adjust HNSW parameters for your dataset size
- Use batch operations for bulk inserts
For Large Datasets¶
- Increase memory allocation
- Use multiple collections to distribute load
- Consider sharding across multiple instances
π© Common Issues¶
Out of Memory¶
- Cause: Large dataset without quantization
- Solution: Enable SQ8 quantization, increase memory allocation
Slow Performance¶
- Cause: Inappropriate HNSW parameters, slow disk
- Solution: Tune HNSW parameters, use SSD storage
Data Corruption¶
- Cause: Unexpected shutdown, disk error
- Solution: Regular backups, use journaling filesystem
π Related Documentation¶
- Usage Modes - Different ways to use GoVector
- Collection Management - Collection creation and configuration
- HNSW Index - HNSW index implementation
- Storage Engine - Persistence and serialization