pingcap / go-ycsb

A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
Apache License 2.0
594 stars 243 forks source link

go-ycsb AWS DynamoDB SDK v2 support for CRUD Insert/Read/Update/Delete operations #254

Closed filipecosta90 closed 1 year ago

filipecosta90 commented 1 year ago

This PR adds support for AWS DynamoDB. Bellow are the relevant configurations. The client was tested both locally and connecting to AWS us-east-2 Service endpoints.

Relevant configurations

field default value description
dynamodb.tablename "ycsb" The database tablename
dynamodb.primarykey "_key" The table primary key fieldname
dynamodb.rc.units 10 Read request units throughput
dynamodb.wc.units 10 Write request units throughput
dynamodb.ensure.clean.table true On load mode ensure that the table is clean at the begining. In case of true and if the table previously exists it will be deleted and recreated
dynamodb.endpoint "" Used endpoint for connection. If empty will use the default loaded configs
dynamodb.region "" Used region for connection ( should match endpoint ). If empty will use the default loaded configs

Testing locally

To test locally we've followed AWS page on running DynamoDB documentation.

In a one-liner simply do as follow:

docker run -d -p 8000:8000 amazon/dynamodb-local

Load the data

./bin/go-ycsb load dynamodb -p threadcount=1 -p recordcount=10000 -p operationcount=20000 -p readproportion=0 -p updateproportion=1 -p insertproportion=0 -p deleteproportion=0 -p dynamodb.endpoint=http://localhost:8000

Sample output:

 ./bin/go-ycsb load dynamodb -p threadcount=1 -p recordcount=10000 -p operationcount=20000 -p readproportion=0 -p updateproportion=1 -p insertproportion=0 -p dynamodb.endpoint=http://localhost:8000
2022/10/14 23:12:13 given you're using dynamodb local endpoint you need to specify -p dynamodb.region='localhost'. Ignoring  and enforcing -p dynamodb.region='localhost'
2022/10/14 23:12:13 Table ycsb does not exist.
2022/10/14 23:12:13 Waiting for table to be available.
***************** properties *****************
"command"="load"
"recordcount"="10000"
"insertproportion"="0"
"dynamodb.endpoint"="http://localhost:8000"
"dotransactions"="false"
"threadcount"="1"
"deleteproportion"="0"
"operationcount"="20000"
"updateproportion"="1"
"readproportion"="0"
**********************************************
INSERT - Takes(s): 10.0, Count: 6093, OPS: 610.7, Avg(us): 1600, Min(us): 887, Max(us): 22687, 99th(us): 3049, 99.9th(us): 5055, 99.99th(us): 6947
Run finished, takes 16.056505041s
INSERT - Takes(s): 16.0, Count: 10000, OPS: 623.7, Avg(us): 1564, Min(us): 887, Max(us): 22687, 99th(us): 2909, 99.9th(us): 4719, 99.99th(us): 7831

Run queries ( 30% reads, 30% updates, 40% writes )

./bin/go-ycsb run dynamodb -p threadcount=1 -p recordcount=10000 -p operationcount=20000 -p readproportion=0.3 -p updateproportion=0.3 -p insertproportion=0.4 -p dynamodb.endpoint=http://localhost:8000

Sample output:

% ./bin/go-ycsb run dynamodb -p threadcount=1 -p recordcount=10000 -p operationcount=20000 -p readproportion=0.3 -p updateproportion=0.3 -p insertproportion=0.4 -p dynamodb.endpoint=http://localhost:8000
2022/10/14 23:13:44 given you're using dynamodb local endpoint you need to specify -p dynamodb.region='localhost'. Ignoring  and enforcing -p dynamodb.region='localhost'
***************** properties *****************
"readproportion"="0.3"
"insertproportion"="0.4"
"recordcount"="10000"
"command"="run"
"operationcount"="20000"
"threadcount"="1"
"updateproportion"="0.3"
"dotransactions"="true"
"dynamodb.endpoint"="http://localhost:8000"
**********************************************
INSERT - Takes(s): 10.0, Count: 2707, OPS: 270.9, Avg(us): 1503, Min(us): 782, Max(us): 6707, 99th(us): 2573, 99.9th(us): 4123, 99.99th(us): 6707
READ   - Takes(s): 9.9, Count: 1988, OPS: 200.9, Avg(us): 1329, Min(us): 711, Max(us): 8887, 99th(us): 2499, 99.9th(us): 4287, 99.99th(us): 8887
UPDATE - Takes(s): 9.9, Count: 1965, OPS: 198.3, Avg(us): 1592, Min(us): 881, Max(us): 85311, 99th(us): 3127, 99.9th(us): 5467, 99.99th(us): 85311
INSERT - Takes(s): 20.0, Count: 5500, OPS: 275.1, Avg(us): 1498, Min(us): 782, Max(us): 6707, 99th(us): 2569, 99.9th(us): 3851, 99.99th(us): 6179
READ   - Takes(s): 19.9, Count: 4008, OPS: 201.5, Avg(us): 1313, Min(us): 711, Max(us): 8887, 99th(us): 2389, 99.9th(us): 3975, 99.99th(us): 8887
UPDATE - Takes(s): 19.9, Count: 4044, OPS: 203.1, Avg(us): 1530, Min(us): 881, Max(us): 85311, 99th(us): 3045, 99.9th(us): 4995, 99.99th(us): 85311
Run finished, takes 29.367686708s
INSERT - Takes(s): 29.4, Count: 8127, OPS: 276.8, Avg(us): 1499, Min(us): 730, Max(us): 23343, 99th(us): 2689, 99.9th(us): 5279, 99.99th(us): 16335
READ   - Takes(s): 29.3, Count: 5977, OPS: 204.3, Avg(us): 1311, Min(us): 691, Max(us): 27343, 99th(us): 2389, 99.9th(us): 4347, 99.99th(us): 8887
UPDATE - Takes(s): 29.3, Count: 5896, OPS: 201.4, Avg(us): 1506, Min(us): 881, Max(us): 85311, 99th(us): 2953, 99.9th(us): 5331, 99.99th(us): 15655

Example of running while connecting to AWS us-east-2 Service endpoints.

./bin/go-ycsb run dynamodb -p threadcount=1 -p recordcount=100 -p operationcount=100 -p readproportion=0 -p updateproportion=1 -p insertproportion=0  -p dynamodb.endpoint=https://dynamodb.us-east-2.amazonaws.com -p dynamodb.region="us-east-2"