Deployment Guide
Audience: Developers
Deployment Guide
This guide provides comprehensive information for deploying GL Open DeepResearch in production environments.
Overview
GL Open DeepResearch is a containerized application that requires several infrastructure components to function properly. This guide covers the technology stack, environment configuration, and deployment considerations.
Technology Stack
Core Application
Runtime: Python 3.12
Framework: FastAPI
Package Manager: uv
Base Image:
asia.gcr.io/gdp-labs/gl-base/python:3.12
Database
PostgreSQL: Primary database for accounts, profiles, tasks, and task groups
Minimum version: PostgreSQL 12+
Connection pooling: SQLAlchemy with configurable pool size
Message Queue & Task Processing
Celery: Asynchronous task processing
RabbitMQ: Message broker for Celery (alternative: Redis)
PostgreSQL: Celery result backend
Caching & Streaming
Redis: Streaming event storage and caching
Used for storing task streaming events (24-hour TTL)
Required for task stream endpoints (
GET /v1/tasks/{task_id}/stream)
External Services
LLM APIs: Required for deep research execution
Smart Search SDK: Web search and content retrieval
Sea Lion API: Optional LLM service integration
Infrastructure Requirements
Minimum Resources
API Service:
CPU: 2 cores
Memory: 2GB (minimum), 4GB (recommended)
Storage: 10GB for application code and dependencies
Worker Service:
CPU: 4 cores (for concurrent task processing)
Memory: 4GB (minimum), 8GB (recommended)
Storage: 10GB for application code and dependencies
Database (PostgreSQL):
CPU: 2 cores
Memory: 4GB
Storage: 100GB (scales with task volume)
Redis:
CPU: 1 core
Memory: 2GB
Storage: 10GB (events expire after 24 hours)
RabbitMQ:
CPU: 1 core
Memory: 1GB
Storage: 5GB
Network Requirements
Outbound HTTPS access to:
LLM API endpoints
Smart Search SDK endpoints
External web resources (for web scraping)
Inbound HTTP/HTTPS access on port 8000 (API service)
Internal network access between:
API service ↔ Database
API service ↔ Redis
Worker service ↔ Database
Worker service ↔ Redis
Worker service ↔ RabbitMQ
Environment Variables
Required Environment Variables
Database Configuration
Authentication
LLM Configuration (Tongyi)
GPT-Researcher Configuration
Smart Search SDK Configuration
Redis Configuration
Celery Configuration
Task Configuration
Webhook Configuration
Table Cleanup Configuration
Application Configuration
Profile Configuration
Profiles are loaded from profiles.yaml at application startup. The file path can be customized:
If not set, defaults to profiles.yaml in the application root directory.
Deployment Architecture
Container Components
GL Open DeepResearch consists of three main containerized services:
API Service: FastAPI application serving HTTP endpoints
Worker Service: Celery workers for asynchronous task processing
Flower Service (optional): Celery monitoring dashboard
Container Configuration
API Service
Port: 8000
Health Check:
GET /healthReadiness Probe: HTTP GET
/health(initial delay: 15s, period: 10s)Liveness Probe: HTTP GET
/health(initial delay: 30s, period: 10s)Entrypoint:
/app/entrypoint.sh
Worker Service
Command:
celery -A gl_deep_research.worker.celery_app worker --loglevel=INFO --concurrency=4 -Q deep_researchConcurrency: Configurable via
WORKER_CONCURRENCYenvironment variable (default: 4)Prefetch Multiplier: Configurable via
WORKER_PREFETCH_MULTIPLIERenvironment variable (default: 1)Queue:
deep_research(configurable viaCELERY_QUEUE_NAME)
Flower Service (Optional)
Port: 5555
Purpose: Monitor Celery tasks and workers
Access: Internal network only (recommended)
Database Migrations
Database migrations are handled automatically on application startup via Alembic. The entrypoint script runs migrations before starting the application.
Migration Files Location: /app/migration/versions/
Manual Migration (if needed):
Kubernetes Deployment
Helm Chart Structure
The deployment uses Helm charts with the following structure:
Key Kubernetes Resources
Deployments: API, Worker, Flower services
Services: ClusterIP services for internal communication
Ingress: ALB ingress for external API access
ConfigMaps: Non-sensitive configuration
Secrets: Sensitive configuration (API keys, passwords)
Resource Limits
API Service:
Worker Service:
Ingress Configuration
Example ALB ingress configuration:
Security Considerations
API Key Management
Master API key must be stored securely (Kubernetes Secrets)
Account API keys are hashed using bcrypt before storage
API keys are only returned once during account creation
Webhook Security
Webhook secrets are encrypted at rest using encryption
Webhook signatures use HMAC-SHA256 for verification
Set
GLDR_SECRETto a secure secret key
Network Security
Use TLS for Redis connections in production (
REDIS_TLS_ENABLED=True)Restrict database access to internal network only
Use service mesh or network policies to limit inter-service communication
Secrets Management
Store sensitive values in Kubernetes Secrets
Use secret management tools (e.g., Sealed Secrets, External Secrets Operator)
Rotate secrets regularly
Never commit secrets to version control
Monitoring & Observability
Health Checks
Endpoint:
GET /healthResponse:
{"status": "ok"}Use for Kubernetes readiness and liveness probes
Logging
Structured JSON logging (when
LOG_FORMAT=json)Log levels: DEBUG, INFO, WARNING, ERROR
Include request IDs for traceability
Metrics (Future)
Task execution metrics
API request metrics
Database connection pool metrics
Redis cache hit/miss rates
Error Tracking
Sentry integration for error tracking
Configure
SENTRY_DSNandSENTRY_PROJECTSet
ENVIRONMENTfor proper environment tagging
Scaling Considerations
Horizontal Scaling
API Service:
Stateless design allows horizontal scaling
Use load balancer to distribute requests
Consider database connection pool limits when scaling
Worker Service:
Scale workers based on task queue depth
Monitor Celery queue metrics
Adjust concurrency per worker based on task characteristics
Database Scaling
Use connection pooling (configure
DB_POOL_SIZE)Consider read replicas for read-heavy workloads
Monitor connection pool usage
Redis Scaling
Use Redis Cluster for high availability
Monitor memory usage (events expire after 24 hours)
Consider Redis persistence for critical data
Backup & Recovery
Database Backups
Regular PostgreSQL backups (daily recommended)
Test backup restoration procedures
Consider point-in-time recovery for production
Configuration Backups
Version control for Helm values
Backup
profiles.yamlconfigurationDocument environment-specific configurations
Troubleshooting
Common Issues
Database Connection Errors:
Verify
GL_DEEP_RESEARCH_DB_URLis correctCheck network connectivity between services
Verify database credentials
Check connection pool settings
Redis Connection Errors:
Verify
REDIS_HOST,REDIS_PORT, andREDIS_PASSWORDCheck Redis service availability
Verify network connectivity
Task Execution Failures:
Check worker logs for errors
Verify LLM API credentials and connectivity
Check Smart Search SDK configuration
Review task timeout settings
Streaming Events Not Available:
Verify Redis is accessible from worker service
Check
DEFAULT_STREAM_REDIS_CACHE_TTLsettingVerify events are being stored (check Redis keys)
Debug Mode
Enable debug logging for troubleshooting:
Production Checklist
Additional Resources
Examples - Getting started with the API
API Documentation - Detailed API endpoint documentation
Architecture Overview - System architecture details
Research Profiles - Profile configuration guide
Last updated
