EC2 Deployment Deploy Cognee on Amazon EC2 for traditional cloud server deployments with full control over the infrastructure and custom configurations. 
EC2 deployment is ideal for organizations that need direct server access, custom networking, or integration with existing AWS infrastructure. 
Why EC2? 
Full Control Complete control over server configuration, networking, and security 
AWS Integration Native integration with AWS services like RDS, S3, and VPC 
Cost Predictable Fixed costs with reserved instances and predictable billing 
Custom Networking Advanced networking configurations and security groups 
Prerequisites 
AWS Account
Active AWS account with EC2 permissions 
AWS CLI installed and configured 
Key pair created for SSH access 
 
Network Setup
VPC with public/private subnets 
Security groups configured for HTTP/HTTPS traffic 
Internet Gateway for public access 
 
Domain & SSL
Domain name (optional but recommended) 
SSL certificate (Let’s Encrypt or AWS Certificate Manager) 
 Instance Configuration  Development
 Production
 High Performance
Small Scale Setup 
Instance Type : t3.medium (2 vCPU, 4GB RAM)Storage : 20GB GP3 SSDOS : Ubuntu 22.04 LTSDatabases : Local SQLite, embedded vector DB Quick Deployment 
Launch EC2 Instance
# Using AWS CLI aws  ec2  run-instances  \   --image-id  ami-0c02fb55956c7d316  \   --instance-type  t3.medium  \   --key-name  your-key-pair  \   --security-group-ids  sg-12345678  \   --subnet-id  subnet-12345678  \   --block-device-mappings  '[{     "DeviceName": "/dev/sda1",     "Ebs": {       "VolumeSize": 20,       "VolumeType": "gp3"     }   }]'  \   --tag-specifications  'ResourceType=instance,Tags=[{Key=Name,Value=cognee-server}]' Replace the AMI ID, security group, and subnet with your specific values. 
Connect to Instance
# Get instance public IP aws  ec2  describe-instances  --filters  "Name=tag:Name,Values=cognee-server"  \   --query  'Reservations[*].Instances[*].PublicIpAddress' # SSH into the instance ssh  -i  /path/to/your-key.pem  ubuntu@YOUR-INSTANCE-IP 
Install Dependencies
# Update system sudo  apt  update  &&  sudo  apt  upgrade  -y # Install Python and pip sudo  apt  install  python3  python3-pip  python3-venv  git  curl  -y # Install uv for faster Python package management curl  -LsSf  https://astral.sh/uv/install.sh  |  sh source  $HOME /.cargo/env 
Deploy Cognee
# Clone repository git  clone  https://github.com/topoteretes/cognee.git cd  cognee # Run automated setup script chmod  +x  deployment/setup_ubuntu_instance.sh source  deployment/setup_ubuntu_instance.sh Manual Setup Process 
# Create virtual environment python3  -m  venv  cognee-env source  cognee-env/bin/activate # Install Cognee with all dependencies uv  sync  --dev  --all-extras  --reinstall # Set up environment variables cat  >  .env  <<  EOF OPENAI_API_KEY=your-openai-api-key POSTGRES_URL=postgresql://user:pass@localhost:5432/cognee NEO4J_URL=bolt://neo4j:password@localhost:7687 QDRANT_URL=http://localhost:6333 COGNEE_HOST=0.0.0.0 COGNEE_PORT=8000 EOF 
# Install PostgreSQL sudo  apt  install  postgresql  postgresql-contrib  -y sudo  -u  postgres  createuser  --interactive  cognee sudo  -u  postgres  createdb  cognee # Install Neo4j wget  -O  -  https://debian.neo4j.com/neotechnology.gpg.key  |  sudo  apt-key  add  - echo  'deb https://debian.neo4j.com stable 4.4'  |  sudo  tee  /etc/apt/sources.list.d/neo4j.list sudo  apt  update  &&  sudo  apt  install  neo4j  -y # Install and configure Qdrant docker  run  -d  --name  qdrant  -p  6333:6333  qdrant/qdrant 
# Create systemd service sudo  tee  /etc/systemd/system/cognee.service  <<  EOF [Unit] Description=Cognee Knowledge Graph Service After=network.target postgresql.service neo4j.service [Service] Type=simple User=ubuntu WorkingDirectory=/home/ubuntu/cognee Environment=PATH=/home/ubuntu/cognee/cognee-env/bin ExecStart=/home/ubuntu/cognee/cognee-env/bin/python -m cognee.api.server Restart=always RestartSec=10 [Install] WantedBy=multi-user.target EOF # Enable and start service sudo  systemctl  daemon-reload sudo  systemctl  enable  cognee sudo  systemctl  start  cognee AWS Service Integration 
RDS Integration Managed PostgreSQL # Connect to RDS instance POSTGRES_URL = postgresql://user:pass@your-rds-endpoint:5432/cognee 
S3 Storage Object Storage # Configure S3 for file storage AWS_S3_BUCKET = your-cognee-bucket AWS_ACCESS_KEY_ID = your-access-key AWS_SECRET_ACCESS_KEY = your-secret-key Security Configuration 
Security Groups
# Create security group aws  ec2  create-security-group  \   --group-name  cognee-sg  \   --description  "Security group for Cognee server" # Allow SSH (port 22) aws  ec2  authorize-security-group-ingress  \   --group-id  sg-12345678  \   --protocol  tcp  \   --port  22  \   --cidr  0.0.0.0/0 # Allow HTTP/HTTPS (ports 80/443) aws  ec2  authorize-security-group-ingress  \   --group-id  sg-12345678  \   --protocol  tcp  \   --port  80  \   --cidr  0.0.0.0/0 aws  ec2  authorize-security-group-ingress  \   --group-id  sg-12345678  \   --protocol  tcp  \   --port  443  \   --cidr  0.0.0.0/0 
SSL/TLS Setup
# Install Nginx sudo  apt  install  nginx  certbot  python3-certbot-nginx  -y # Configure Nginx reverse proxy sudo  tee  /etc/nginx/sites-available/cognee  <<  EOF server {     listen 80;     server_name your-domain.com;          location / {         proxy_pass http://localhost:8000;         proxy_set_header Host  \$ host;         proxy_set_header X-Real-IP  \$ remote_addr;     } } EOF # Enable site and get SSL certificate sudo  ln  -s  /etc/nginx/sites-available/cognee  /etc/nginx/sites-enabled/ sudo  certbot  --nginx  -d  your-domain.com 
Firewall Configuration
# Configure UFW firewall sudo  ufw  allow  OpenSSH sudo  ufw  allow  'Nginx Full' sudo  ufw  --force  enable Monitoring & Maintenance  System Monitoring
 Log Management
 Backup Strategy
# Install monitoring tools sudo  apt  install  htop  iotop  nethogs  -y # Check system resources htop df  -h free  -m # Monitor Cognee service sudo  systemctl  status  cognee sudo  journalctl  -u  cognee  -f 
# Stop instance aws  ec2  stop-instances  --instance-ids  i-1234567890abcdef0 # Change instance type aws  ec2  modify-instance-attribute  \   --instance-id  i-1234567890abcdef0  \   --instance-type  Value=m5.xlarge # Start instance aws  ec2  start-instances  --instance-ids  i-1234567890abcdef0 
# Create Application Load Balancer aws  elbv2  create-load-balancer  \   --name  cognee-alb  \   --subnets  subnet-12345678  subnet-87654321  \   --security-groups  sg-12345678 # Create target group aws  elbv2  create-target-group  \   --name  cognee-targets  \   --protocol  HTTP  \   --port  8000  \   --vpc-id  vpc-12345678 
# Create launch template aws  ec2  create-launch-template  \   --launch-template-name  cognee-template  \   --launch-template-data  '{     "ImageId": "ami-0c02fb55956c7d316",     "InstanceType": "t3.medium",     "KeyName": "your-key-pair",     "SecurityGroupIds": ["sg-12345678"],     "UserData": "base64-encoded-startup-script"   }' Troubleshooting  Common Issues
 Database Issues
 Performance Issues
Service Won’t Start # Check service status sudo  systemctl  status  cognee sudo  journalctl  -u  cognee  --no-pager # Check port availability sudo  netstat  -tlnp  |  grep  :8000 # Verify environment variables cat  .env Cost Optimization 
Reserved Instances Save up to 75% Purchase reserved instances for predictable workloads to reduce costs significantly. 
Spot Instances Development/Testing Use spot instances for non-critical workloads to save up to 90% on compute costs. 
Use AWS Cost Explorer to monitor your EC2 spending and optimize instance types based on actual usage patterns. 
Next Steps 
High Availability Multi-AZ Setup Deploy across multiple availability zones for improved resilience. 
Monitoring Stack CloudWatch Integration Set up comprehensive monitoring with CloudWatch and custom metrics. 
Need Help? Join our community for EC2 deployment support and AWS best practices.