Deployment Guide on AWS
This document explains how to deploy ScalarDB GraphQL servers on the Amazon EKS environment.
We will deploy multiple GraphQL servers to an EKS cluster with an AWS Load Balancer Controller, which manages an internal AWS Application Load Balancer. The AWS Application Load Balancer handles HTTP cookie-based session affinity. When we deploy multiple GraphQL servers, session affinity is required to handle transactions properly. This is because GraphQL servers keep the transactions in memory, so GraphQL queries that use continued transactions must be routed to the same server that started the transaction.
What we create
In this guide, we will create the following components.
- A VPC with NAT gateway
- An EKS cluster with a Kubernetes node group
- A managed database service
- A bastion instance with a public IP
- An internal ALB for load balancing HTTP requests using the AWS Load Balancer Controller.
Step 1. Configure an EKS cluster
Please follow steps 1 to 3 in the Deploy ScalarDL on AWS guide to set up a VPC, subnets, a bastion host, a database, an EKS cluster, and a node group.
Note: That guide instructs to add a label to the node group with a key agentpool and a value scalardlpool. However, since we will deploy GraphQL servers, not ScalarDL, we should change the label. For example, the node group can be labeled with a key agentpool and a value scalardbgraphqlpool. The label can be used to select nodes when deploying ScalarDB GraphQL servers.
In this document, a placeholder cluster name <your-cluster-name> will be used in command examples. Please change it to your cluster name.
Step 2. Load Database Schema
We need to load a database schema to the database before starting ScalarDB GraphQL.
Here is an example for DynamoDB. For other databases and more detailed instructions, please refer to the ScalarDB Schema Loader.
-
Create a
database.propertiesconfiguration file for DynamoDBscalar.db.contact_points=<AWS region>
scalar.db.username=<AWS access key ID>
scalar.db.password=<AWS secret access Key>
scalar.db.storage=dynamo -
Create a
schema.jsonfile. Please refer to the sample in the ScalarDB Schema Loader document. -
Load the schema to the database with ScalarDB Schema Loader
docker run --rm -v $PWD/schema.json:/schema.json \
-v $PWD/database.properties:/database.properties \
ghcr.io/scalar-labs/scalardb-schema-loader:3.5.2 \
-c /database.properties -f /schema.json --coordinator