View on GitHub
AWS DBS Reference Architectures - Graph Databases

Connecting to Amazon Neptune from Clients Outside the Neptune VPC

Amazon Neptune only allows connections from clients located in the same VPC as the Neptune cluster. If you want to connect from outside the Neptune VPC, you can use a load balancer. This architecture shows how you can use either a Network Load Balancer or an Application Load Balancer to connect to Neptune.

Connecting to Amazon Neptune from clients outside the Neptune VPC using AWS Network Load Balancer

You want to connect to your Neptune cluster from clients located outside the VPC in which you launched your Neptune cluster.

Amazon Neptune only allows connections from clients located in the same VPC as the Neptune cluster. In this architecture, clients located outside the VPC connect to Neptune via a Network Load Balancer.

Network Load Balancer

Walkthrough of the Architecture

  1. In this architecture your Neptune cluster is run in at least two subnets in two Availability Zones, with each subnet in a different Availability Zone.
  2. The Neptune DB subnet group spans at least two subnets in two Availability Zones.
  3. Web connections from external clients terminate on a Network Load Balancer in a public subnet.
  4. The load balancer forwards requests to the Neptune cluster endpoint (which then routes to the primary instance in the database cluster).
  5. The target IP addresses of the cluster endpoint are refreshed on a periodic basis by a Lambda function.
  6. This Lambda function is triggered by a CloudWatch event. When it fires, the function queries a DNS server for the IP addresses of the Neptune cluster endpoint. It registers new IP addresses with the load balancer’s target group, and deregisters any stale IP addresses.

Best Practices

Connecting to Amazon Neptune from clients outside the Neptune VPC using AWS Application Load Balancer

You want to connect to your Neptune cluster from clients located outside the VPC in which you launched your Neptune cluster.

Amazon Neptune only allows connections from clients located in the same VPC as the Neptune cluster. In this architecture, clients located outside the VPC connect to Neptune via an Application Load Balancer.

Application Load Balancer

Walkthrough of the Architecture

  1. In this architecture your Neptune cluster is run in at least two subnets in two Availability Zones, with each subnet in a different Availability Zone.
  2. The Neptune DB subnet group spans at least two subnets in two Availability Zones.
  3. Web connections from external clients terminate on an Application Load Balancer in a public subnet.
  4. The load balancer forwards requests to HAProxy running on an EC2 instance. This EC2 instance is registered in a target group belonging to the ALB.
  5. HAProxy is configured with the Neptune cluster endpoint DNS and port. Requests from the ALB are forwarded to the primary instance in the database cluster.

This architecture differs from the previous architecture in that it introduces two hops between the client and the Neptune instance, whereas the previous architecture introduced only one hop. The previous architecture used all AWS managed services; this architecture introduces a piece of third-party open source software (HAProxy).

Best Practices