Alternator supports four ways in which write operations can use quorum writes or LWT or both, which we called "write isolation policies". Until this patch, Alternator defaulted to the most generally safe policy, "always_use_lwt". This default could have been overriden for each table separately, but there was no way to change this default for all tables. This patch adds a "--alternator-write-isolation" configuration option which allows changing the default. Moreover, @dorlaor asked that users must *explicitly* choose this default mode, and not get "always_use_lwt" without noticing. The previous default, "always_use_lwt" supports any workload correctly but because it uses LWT for all writes it may be disappointingly slow for users who run write-only workloads (including most benchmarks) - such users might find the slow writes so disappointing that they will drop Scylla. Conversely, a default of "forbid_rmw" will be faster and still correct, but will fail on workloads which need read-modify-write operations - and suprise users that need these operations. So Dor asked that that *none* of the write modes be made the default, and users must make an informed choice between the different write modes, rather than being disappointed by a default choice they weren't aware of. So after this patch, Scylla refuses to boot if Alternator is enabled but a "--alternator-write-isolation" option is missing. The patch also modifies the relevant documentation, adds the same option to our docker image, and the modifies the test-running script test/alternator/run to run Scylla with the old default mode (always_use_lwt), which we need because we want to test RMW operations as well. Fixes #6452 Signed-off-by: Nadav Har'El <nyh@scylladb.com> Message-Id: <20200524160338.108417-1-nyh@scylladb.com>
3.6 KiB
3.6 KiB
Getting Started With ScyllaDB Alternator
Installing Scylla
Before you can start using ScyllaDB Alternator, you will have to have an up and running scylla cluster configured to expose the alternator port. This section will guide you through the steps for setting up the cluster:
Get Scylla with alternator support from a docker:
- Because Alternator is still experimental and improves quickly, it is
recommended to run the latest nightly build. Make sure you have the latest
nightly image by running:
docker pull scylladb/scylla-nightly:latest - Follow the steps in the Scylla official download web page
add to every "docker run" command:
-p 8000:8000before the image name and--alternator-port=8000 --alternator-write-isolation=alwaysat the end. The "alternator-port" option specifies on which port Scylla will listen for the (unencrypted) DynamoDB API, and the "alternator-write-isolation" chooses whether or not Alternator will use LWT for every write. For example, `docker run --name scylla -d -p 8000:8000 scylladb/scylla-nightly:latest --alternator-port=8000 --alternator-write-isolation=always
Testing Scylla's DynamoDB API support:
Running AWS Tic Tac Toe demo app to test the cluster:
- Follow the instructions on the AWS github page
- Enjoy your tic-tac-toe game :-)
Setting up the python environment
Run the following commands on your machine, this will install boto3 python library which also contains drivers for DynamoDB:
sudo pip install --upgrade boto3
Runnning some simple scripts:
The following is a 3 scripts test that creates a table named usertable writes the famous hello world record to it, and then, reads it back.
- Put the following create table example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
dynamodb.create_table(
AttributeDefinitions=[
{
'AttributeName': 'key',
'AttributeType': 'S'
},
],
BillingMode='PAY_PER_REQUEST',
TableName='usertable',
KeySchema=[
{
'AttributeName': 'key',
'KeyType': 'HASH'
},
])
- Put the following write example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
dynamodb.batch_write_item(RequestItems={
'usertable': [
{
'PutRequest': {
'Item': {
'key': 'test', 'x' : {'hello': 'world'}
}
},
}
]
})
- Put the following read example script in a python file and run it (changing local host to the address of your docker node if you are using docker):
import boto3
dynamodb = boto3.resource('dynamodb',endpoint_url='http://localhost:8000',
region_name='None', aws_access_key_id='None', aws_secret_access_key='None')
print(dynamodb.batch_get_item(RequestItems={
'usertable' : { 'Keys': [{ 'key': 'test' }] }
}))
You should see the record you inserted in step 2 along with some http info printed to screen.