Amazon Neptune
Managed graph database on AWS: property graphs and RDF, Gremlin, openCypher, and SPARQL, graph use cases, the shared cluster volume, replicas and failover, Neptune Serverless, global databases, streams, Neptune ML and Neptune Analytics, security, cost, and monitoring.
6 min read · Last reviewed · SAA-C03
Sign in to bookmark tutorials and track what you have read.
On this page
What it is
Amazon Neptune is a fully managed graph database for applications that work with highly connected data. A graph stores nodes (such as people, products, or accounts) and the relationships between them as first-class data, so a query can follow many links ("friends of friends who bought this product") quickly. Neptune is built to store billions of relationships and query them with millisecond LatencyThe time between sending a request and receiving the response, usually measured in milliseconds. Distance and processing add to it; caching and serving users from nearby locations reduce it.Glossary entry.
Neptune supports two graph models and three query languages:
- Property graphs, queried with Apache TinkerPop Gremlin or openCypher.
- RDF (Resource Description Framework), queried with SPARQL.
Typical uses are recommendation engines, fraud detection, knowledge graphs, social networks, identity graphs, drug discovery, and network security. Choose Neptune when the question is about relationships between data, not about rows or documents on their own. Relational joins across many levels are slow and complex; a graph is built for them.
Concepts
- DB cluster: like Amazon Aurora, it has one primary instance for writes and up to 15 Neptune Replicas for reads, all sharing one cluster volume. The volume keeps copies of the data across three AZ (Availability Zone)An isolated location within an AWS Region, made up of one or more data centers with their own power, cooling, and networking. The AZs in a Region are linked by fast, low-latency connections, so spreading resources across them protects against the failure of one site.Glossary entry and grows up to 128 TiB.
- Endpoints: a cluster endpoint for writes, a reader endpoint for reads across replicas, instance endpoints, and custom endpoints for groups of instances.
- Neptune Serverless: capacity in Neptune capacity units (NCUs), each 2 GiB of memory with matching CPU and networking. Capacity scales between a minimum of 1 NCU and a maximum of 128 NCUs (256 GB of memory).
- Bulk loader: loads large data sets from Amazon S3 into Neptune. It needs an IAM role that can read the bucket, and an S3 VPC endpointA private connection from a VPC to an AWS service or another endpoint service without crossing the internet. Gateway endpoints, for Amazon S3 and DynamoDB, are route table targets; interface endpoints are network interfaces that use AWS PrivateLink.Glossary entry.
Features to know
- Neptune global database: a primary cluster in one AWS RegionA separate geographic area where AWS runs its services, such as us-east-1 in Northern Virginia, made up of several Availability Zones. Most resources live in one Region; you choose Regions for latency, data residency, and the services you need.Glossary entry and up to five secondary Regions, with replication latency typically under a second. Secondaries serve low-latency reads and can take over if a Region fails; only the primary accepts writes.
- Neptune Streams: logs every change to the graph, in order, so you can notify people or keep a copy in another store, such as Amazon OpenSearch Service, ElastiCache, or S3.
- Full-text search: integrates with Amazon OpenSearch Service.
- Neptune ML (Machine learning)Software that learns patterns from example data to make predictions or decisions, instead of following rules written by hand. A model is first trained on data, then used to make predictions on new data, which is called inference.Glossary entry: trains machine learning models on the graph with graph neural networks, using Amazon SageMaker AI, to make predictions such as likely fraud or recommendations.
- Neptune Analytics: a separate, memory-optimized graph engine for analytics over large graphs, such as finding trends or running graph algorithms. Neptune Database is the service for transactional graph workloads.
- Vector search in Neptune Analytics: a vector index stores embeddings on the graph's nodes, so one query can combine similarity search with graph traversals. This is the basis of GraphRAG, which gives a language model connected context, and Amazon Bedrock can run it as a managed GraphRAG.
Security, resilience, performance, and cost
Security
- Neptune runs inside your VPC; control access with Security groupA stateful virtual firewall for network interfaces, such as an EC2 instance's, whose rules can only allow traffic. Return traffic for allowed connections is allowed automatically, and a rule can refer to another security group instead of IP addresses.Glossary entry and keep clusters in SubnetA range of IP addresses in a VPC, inside one Availability Zone. A subnet is public when its route table sends internet traffic to an internet gateway, and private when it does not.Glossary entry.
- Encryption at restEncrypting data where it is stored, such as on disks, in databases, or in backups, so that it cannot be read without the key. On AWS it usually uses keys in AWS KMS.Glossary entry with AWS KMS covers the data, backups, and snapshots. Decide on the key before you create the cluster: to change it, restore a snapshot into a new cluster with a different key.
- Use TLS (Transport Layer Security)The protocol that encrypts traffic between a client and a server and lets the server prove its identity with a certificate. It replaced SSL, though the older name is still common; HTTPS is HTTP over TLS.Glossary entry for connections. IAM database authentication requires every request to be signed with AWS Signature Version 4.
- Audit logs can be published to CloudWatch Logs; CloudTrail records API (Application programming interface)A defined way for one program to ask another for data or actions, such as a set of HTTPS requests and responses. Every AWS service is controlled through its API, which the console, the CLI, and the SDKs call for you.Glossary entry calls.
Resilience
- FailoverSwitching automatically to a standby resource when the primary one fails, such as a standby database in Amazon RDS or a backup site chosen by Route 53 failover routing.Glossary entry: if the primary fails, Neptune promotes a replica automatically. Set priorities from 0 (highest) to 15 to choose which one. Place replicas in two or more Availability Zones.
- Backups are continuous, with a retention of 1 to 35 days and PITR (Point-in-time recovery)Restoring a database to its state at a chosen moment within a retention period, using continuous backups. Amazon RDS, Amazon Aurora, Amazon DynamoDB, and AWS Backup support it.Glossary entry; you can also take manual snapshots.
- Use a global database for Regional DR (Disaster recovery)Preparing for and recovering from events that take a workload down, such as a Regional outage or deleted data. AWS describes four strategies, from cheapest and slowest to costliest and fastest: backup and restore, pilot light, warm standby, and multi-site active/active.Glossary entry.
Performance
- Scale reads with up to 15 replicas, scale the writer by changing instance class, or use Neptune Serverless for variable load.
- Load large data sets with the bulk loader rather than individual writes.
Cost
- Pay for instances (or serverless NCUs), storage, backup storage, and I/O with the Standard configuration. The I/O-Optimized configuration includes I/O in the price, for I/O-heavy workloads.
- Database Savings Plans cover Neptune.
Monitoring
- CloudWatch metrics for CPU, memory, query throughput, and replica lag. Audit and slow-query logs go to CloudWatch Logs, and events go to Amazon SNS.
Neptune or another option?
| If the requirement is | Choose |
|---|---|
| Query relationships across many levels of connected data | Amazon Neptune |
| Graph queries in Gremlin, openCypher, or SPARQL | Amazon Neptune |
| Fast analytics and graph algorithms over large graphs | Neptune Analytics |
| Tables, rows, and SQL (Structured Query Language)The standard language for querying and changing data in relational databases. Analytics services such as Amazon Athena and Amazon Redshift also use SQL.Glossary entry with simple joins | Amazon RDS or Aurora |
| Key-value lookups at any scale | Amazon DynamoDB |
| JSON (JavaScript Object Notation)A text format for structured data made of name-and-value pairs and lists, such as {"bucket": "logs"}. IAM policies, most AWS API responses, and many CloudFormation templates are written in JSON.Glossary entry documents with a MongoDB API | Amazon DocumentDB |
Reverse mindmap: when the question points here
- Yes, when the question says
- Highly connected data and relationships leads to Neptune
- Social network, friends of friends leads to Neptune
- Recommendation engine from relationships leads to Neptune
- Fraud rings, linked accounts leads to Neptune
- Knowledge graph, RDF, SPARQL leads to Neptune
- Gremlin or openCypher queries leads to Neptune
- Choose the feature
- Scale reads leads to Up to 15 Neptune Replicas
- Variable load, no sizing leads to Neptune Serverless
- Cross-Region reads and DR leads to Neptune global database
- Load a large data set from S3 leads to Bulk loader
- Keep another store in sync with graph changes leads to Neptune Streams
- Predictions from the graph leads to Neptune ML
- Graph algorithms and analytics leads to Neptune Analytics
- No, when the question says
- Rows and SQL leads to RDS or Aurora
- Key-value at any scale leads to DynamoDB
Key takeaways
- Neptune is a managed graph database for highly connected data, with millisecond queries over billions of relationships.
- It supports property graphs (Gremlin, openCypher) and RDF (SPARQL).
- The architecture is like Aurora: a shared cluster volume across three Availability Zones (up to 128 TiB) and up to 15 replicas that are failover targets.
- A global database adds up to five secondary Regions, with lag typically under a second.
- Neptune Serverless scales between 1 and 128 NCUs; the bulk loader imports from S3.
- Neptune ML adds graph machine learning; Neptune Analytics is the in-memory engine for graph analytics.
Sources
- Amazon Neptune User Guide: What is Amazon Neptune?
- Amazon Neptune User Guide: Overview of Amazon Neptune features
- Amazon Neptune User Guide: Neptune storage, reliability and availability
- Amazon Neptune User Guide: Neptune DB clusters and instances
- Amazon Neptune User Guide: Connecting to Amazon Neptune endpoints
- Amazon Neptune User Guide: Fault tolerance for a Neptune DB cluster
- Amazon Neptune User Guide: Backing up and restoring a Neptune DB cluster
- Amazon Neptune User Guide: Amazon Neptune Serverless
- Amazon Neptune User Guide: Capacity scaling in a Neptune Serverless DB cluster
- Amazon Neptune User Guide: Using Amazon Neptune with a global database
- Amazon Neptune User Guide: Capturing graph changes in real time using Neptune streams
- Amazon Neptune User Guide: Full-text search using Amazon OpenSearch Service
- Amazon Neptune User Guide: Neptune ML for machine learning on graphs
- Amazon Neptune User Guide: Using the Neptune bulk loader to ingest data
- Amazon Neptune User Guide: Encrypting Neptune resources at rest
- Amazon Neptune User Guide: Authenticating with IAM
- Amazon Neptune User Guide: Encrypting connections with SSL/HTTPS
- Amazon Neptune User Guide: Publishing Neptune logs to Amazon CloudWatch Logs
- Amazon Neptune User Guide: Amazon Neptune events
- Neptune Analytics User Guide: What is Neptune Analytics?
- Amazon Neptune pricing
- Neptune Analytics User Guide: Working with vector similarity in Neptune Analytics
- Prescriptive Guidance: Vector database options