Installation
Install Graphiti with Neptune support:Prerequisites
- Neptune Database Cluster or Neptune Analytics Graph
- Amazon OpenSearch Serverless Collection (for fulltext search)
- AWS Credentials configured with appropriate IAM permissions
Required IAM Permissions
Configuration
Environment Variables
.env
Neptune Database Setup
Connect to a Neptune Database cluster:Neptune Analytics Setup
Connect to a Neptune Analytics graph:Driver Implementation
The NeptuneDriver (graphiti_core/driver/neptune_driver.py:139) provides:
- Dual Backend Support: Works with both Neptune Database and Neptune Analytics
- OpenSearch Integration: Uses Amazon OpenSearch Serverless for fulltext search
- AWS Authentication: Automatic IAM-based authentication via boto3
- Managed Service: Fully managed, scalable graph infrastructure
Connection Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
host | str | Required | Neptune endpoint with protocol prefix |
aoss_host | str | Required | OpenSearch Serverless collection endpoint |
port | int | 8182 | Neptune Database port (ignored for Analytics) |
aoss_port | int | 443 | OpenSearch Serverless port |
Host Format
- Neptune Database:
neptune-db://<cluster-endpoint> - Neptune Analytics:
neptune-graph://<graph-id>
OpenSearch Integration
Neptune uses Amazon OpenSearch Serverless for fulltext indexing. The driver automatically manages four indices:Index Definitions
- node_name_and_summary: Entity node fulltext search
- community_name: Community node search
- episode_content: Episode content search
- edge_name_and_fact: Relationship fact search
Complete Example
When to Use Neptune
Choose Neptune if you:- Need a fully managed, production-ready graph database
- Want AWS-native integration and IAM security
- Require high availability and automated backups
- Need elastic scalability for varying workloads
- Prefer serverless deployment options (Neptune Analytics)
- Need persistent storage with automatic backups
- Want multi-AZ replication
- Require read replicas for high read throughput
- Need fast in-memory analytics
- Want to pay only for query execution time
- Require rapid scaling for analytical workloads
Performance Considerations
- Cold Starts: OpenSearch index creation takes ~60 seconds
- Batch Operations: Use bulk operations for large data imports
- Connection Pooling: Driver manages connection pooling automatically
- Query Optimization: Monitor CloudWatch metrics for query performance
Monitoring and Debugging
CloudWatch Metrics
Monitor Neptune through CloudWatch:- Query execution time
- Connection count
- Storage usage (Database only)
- Request count
Enable Query Logging
Cost Optimization
- Neptune Database: Use instance sizing based on workload
- Neptune Analytics: Pay per query; optimize query patterns
- OpenSearch Serverless: Configure appropriate OCU (capacity units)
- Data Transfer: Minimize cross-region data transfer
Security Best Practices
- IAM Roles: Use IAM roles instead of access keys when possible
- VPC Configuration: Deploy Neptune in private subnets
- Encryption: Enable encryption at rest and in transit
- Network Security: Use security groups to restrict access