Overview
This guide covers production deployment best practices for BR-ACC, including security hardening, performance tuning, and scaling considerations.Pre-Deployment Checklist
Security audit
Review and implement all security recommendations:
- Change default passwords (
NEO4J_PASSWORD) - Generate strong JWT secret (
JWT_SECRET_KEY) - Enable HTTPS (
AUTH_COOKIE_SECURE=true) - Configure proper CORS origins
- Set up invite codes if restricting access
- Review firewall rules and network access
Resource planning
Ensure adequate server resources:
- 64GB RAM (minimum 32GB) for 40M+ nodes
- 8+ CPU cores
- 500GB+ SSD storage
- Backup storage (3x database size)
Database optimization
Configure Neo4j memory settings:
- Set
NEO4J_HEAP_INITIAL=4G - Set
NEO4J_HEAP_MAX=8G - Set
NEO4J_PAGECACHE=12G
Monitoring setup
Set up monitoring and alerting:
- Configure log aggregation
- Set up health check monitoring
- Configure alerts for service failures
- Set up database backup automation
Security Hardening
Required Security Changes
1. Neo4j Password
Generate a strong random password:.env:
.env
2. JWT Secret Key
Generate a cryptographically secure secret:.env:
.env
The JWT secret is used to sign authentication tokens. If compromised, attackers can forge valid sessions. Never reuse this secret across environments.
3. HTTPS and Secure Cookies
Enable secure cookies for HTTPS:.env
4. CORS Configuration
Restrict CORS to your production domain:.env
Optional Security Settings
Invite Codes
Restrict registration with an invite code:.env
Public Access Control
Disable public access to sensitive features:.env
Rate Limiting
Rate limits are configured inapi/src/bracc/config.py:21-22:
- Anonymous requests:
60/minute - Authenticated requests:
300/minute
Performance Tuning
Neo4j Memory Configuration
Neo4j memory configuration is the most critical factor for performance. The page cache should be large enough to fit your entire graph in memory.
Development Settings (Default)
Suitable for small datasets (<1M nodes):.env
Production Settings (40M+ nodes)
.env
Memory Allocation Guidelines
| Dataset Size | Min RAM | Heap Initial | Heap Max | Page Cache |
|---|---|---|---|---|
| <1M nodes | 4GB | 512m | 1G | 512m |
| 1-10M nodes | 16GB | 2G | 4G | 4G |
| 10-40M nodes | 32GB | 4G | 8G | 8G |
| 40M+ nodes | 64GB | 4G | 8G | 12G |
Rule of thumb:
- Heap: 25-50% of RAM
- Page Cache: 50-75% of remaining RAM after heap
- Leave 1-2GB for OS and other processes
Docker Memory Limits
Set memory limits indocker-compose.yml:
docker-compose.yml
Database Indexes
Ensure critical indexes exist:High Availability
Database Backups
Automated Daily Backups
Create a backup script:backup.sh
Restore from Backup
Health Monitoring
All services expose health endpoints:- API:
http://localhost:8000/health - Neo4j: Port 7687 (Bolt protocol)
- Frontend: Depends on API health
Example Health Check Script
health-check.sh
Load Balancing
For high-traffic deployments, run multiple API instances behind a load balancer:docker-compose.prod.yml
Deployment Architecture
Recommended Production Setup
Reverse Proxy Configuration
Caddy (Recommended)
Caddyfile
Nginx
nginx.conf
Logging and Monitoring
Log Aggregation
Configure Docker logging:docker-compose.prod.yml
Log Levels
Set appropriate log levels:.env
Metrics Collection
Neo4j exposes metrics at:- JMX metrics on port 3637
- HTTP metrics at
http://localhost:7474/metrics
prometheus.yml
Scaling Considerations
Vertical Scaling
For datasets up to 100M nodes:- Increase RAM (up to 128GB)
- Increase page cache proportionally
- Use faster NVMe SSD storage
Horizontal Scaling
Neo4j Community Edition does not support clustering. For multi-instance deployments, consider Neo4j Enterprise Edition or a sharding strategy.
- Run multiple API containers
- Use a load balancer (Nginx, HAProxy, Caddy)
- Share the same Neo4j instance
Disaster Recovery
Recovery Time Objective (RTO)
Target: 1 hourRecovery Point Objective (RPO)
Target: 24 hours (daily backups) For lower RPO:- Increase backup frequency
- Use Neo4j transaction logs
- Consider Neo4j Enterprise for online backup
Deployment Workflow
Troubleshooting
Common Production Issues
Out of Memory Errors
Slow Query Performance
Service Not Starting
Next Steps
Configuration
Review all configuration options
Docker Setup
Docker Compose reference
ETL Pipeline
Load data into BR-ACC
API Reference
API documentation