Load Balancing in Scylla Alternator

Why Alternator Needs a Load Balancer

Server-side Load Balancing

$ while :
do
dig +noall +answer dynamodb.us-east-1.amazonaws.com
sleep 1

done
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.94.2.86
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.228.140
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.233.18
dynamodb.us-east-1.amazonaws.com. 3 IN A 52.119.228.140
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.233.182
dynamodb.us-east-1.amazonaws.com. 1 IN A 52.119.228.140
dynamodb.us-east-1.amazonaws.com. 1 IN A 52.119.233.18
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.233.238
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.234.122
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.233.174
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.233.214
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.224.232
dynamodb.us-east-1.amazonaws.com. 4 IN A 52.119.224.232
dynamodb.us-east-1.amazonaws.com. 5 IN A 52.119.225.12
dynamodb.us-east-1.amazonaws.com. 1 IN A 52.119.226.182
...

Client-side Load Balancing

An Example in Java

URI node = URI.create("https://127.0.0.1:8043/");AWSCredentialsProvider myCredentials =
new AWSStaticCredentialsProvider(
new BasicAWSCredentials("myusername", "mypassword"));
AmazonDynamoDB client =
AmazonDynamoDBClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
node.toString(), "region-doesnt-matter"))
.withCredentials(myCredentials)
.build();
DynamoDB dynamodb = new DynamoDB(client);
Table tab = dynamodb.createTable(tabName,
Arrays.asList(
new KeySchemaElement("k", KeyType.HASH),
new KeySchemaElement("c", KeyType.RANGE)),
Arrays.asList(
new AttributeDefinition("k", ScalarAttributeType.N),
new AttributeDefinition("c", ScalarAttributeType.N)),
new ProvisionedThroughput(0L, 0L));
import com.scylladb.alternator.AlternatorRequestHandler;URI node = URI.create("https://127.0.0.1:8043/");AlternatorRequestHandler handler =
new AlternatorRequestHandler(node);
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard()
.withRegion("region-doesnt-matter")
.withRequestHandlers(handler)
.withCredentials(myCredentials)
.build();
DynamoDB dynamodb = new DynamoDB(client);

Conclusions

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store