Skip to main content

Production Deployment Guide

Production deployment requires significant infrastructure expertise. This guide covers the essentials, but your team should be comfortable with Docker, PostgreSQL operations, and Kubernetes (if using).

Architecture Overview

Deployment Options

Suitable for: Small teams, single-server deployments

Production docker-compose.yml

Required Environment Variables

Create a .env file:
Security: Never commit .env files. Use a secrets manager in production.

CORS Configuration (Production-safe)

Configure CORS based on whether you send credentials (Authorization headers or cookies):
Do not combine * with explicit origins. Wildcard origin runs in non-credential mode.

Production Checklist

Database

1

Enable Connection Pooling

Configure DB_POOL_SIZE and DB_MAX_OVERFLOW:
For high-traffic deployments, consider PgBouncer.
2

Set Up Backups

Schedule regular pg_dump backups:
Test your restore procedure regularly!
3

Configure Read Replicas (Optional)

For read-heavy workloads, add read replicas:
4

Monitor Query Performance

Enable slow query logging:

Security

1

Rotate API Keys

Generate strong API keys and rotate regularly:
You must update all agent clients when rotating keys. There’s no built-in key rotation mechanism.
2

Enable TLS

Always use HTTPS in production. Configure your reverse proxy (nginx, Traefik, etc.):
3

Network Isolation

  • Place PostgreSQL in a private subnet
  • Use VPC security groups to restrict access
  • Never expose PostgreSQL to the internet
4

Secrets Management

Use a secrets manager instead of environment files:
  • AWS Secrets Manager
  • HashiCorp Vault
  • GCP Secret Manager
You’ll need to write custom code to fetch secrets at startup.

Monitoring

1

Health Checks

Monitor the /health endpoint:
Set up alerts for non-200 responses.
2

Prometheus Metrics

Scrape /metrics endpoint:
Available metrics:
  • aegis_memory_add_total
  • aegis_memory_query_total
  • aegis_memory_query_latency_seconds
3

Log Aggregation

Ship logs to your log aggregation system:
4

Alerting

Set up alerts for:
  • API error rate > 1%
  • Query latency p99 > 500ms
  • Database connections > 80% of pool
  • Disk usage > 80%

Scaling

The Aegis API is stateless and can be horizontally scaled:
Use a load balancer (nginx, HAProxy, cloud LB) in front.
PostgreSQL with pgvector benefits from:
  • More RAM (for HNSW index caching)
  • Faster SSDs
  • More CPU cores for parallel queries
Start with 4GB RAM, 2 vCPUs minimum.
For large memory counts (1M+), tune the HNSW index:
See pgvector tuning guide for details.

Disaster Recovery

Backup Strategy

Restore Procedure

Cost Estimation

Costs scale primarily with:
  • Number of memories stored (database size)
  • Query volume (compute + embeddings)
  • Embedding calls (OpenAI API costs)

Need Help?

Production deployment requires careful planning. If you’re facing challenges:

GitHub Issues

Report bugs or ask questions

Community Discord

Get help from the community
Coming Soon: We’re working on a managed platform that handles all of this for you. Join the waitlist to be notified when it launches.