Skip to content

Commit ff4ecbd

Browse files
authored
[scylla] native Scylla support with token aware balancing policy and LWT (#1473)
1 parent 6720467 commit ff4ecbd

10 files changed

Lines changed: 1314 additions & 0 deletions

File tree

bin/bindings.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ rest:site.ycsb.webservice.rest.RestClient
6868
riak:site.ycsb.db.riak.RiakKVClient
6969
rocksdb:site.ycsb.db.rocksdb.RocksDBClient
7070
s3:site.ycsb.db.S3Client
71+
scylla:site.ycsb.db.scylla.ScyllaCQLClient
7172
solr7:site.ycsb.db.solr7.SolrClient
7273
tarantool:site.ycsb.db.TarantoolClient
7374
tablestore:site.ycsb.db.tablestore.TableStoreClient

bin/ycsb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ DATABASES = {
9898
"rocksdb" : "site.ycsb.db.rocksdb.RocksDBClient",
9999
"s3" : "site.ycsb.db.S3Client",
100100
"seaweedfs" : "site.ycsb.db.seaweed.SeaweedClient",
101+
"scylla" : "site.ycsb.db.scylla.ScyllaCQLClient",
101102
"solr7" : "site.ycsb.db.solr7.SolrClient",
102103
"tarantool" : "site.ycsb.db.TarantoolClient",
103104
"tablestore" : "site.ycsb.db.tablestore.TableStoreClient",

distribution/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ LICENSE file.
234234
<artifactId>seaweedfs-binding</artifactId>
235235
<version>${project.version}</version>
236236
</dependency>
237+
<dependency>
238+
<groupId>site.ycsb</groupId>
239+
<artifactId>scylla-binding</artifactId>
240+
<version>${project.version}</version>
241+
</dependency>
237242
<dependency>
238243
<groupId>site.ycsb</groupId>
239244
<artifactId>solr7-binding</artifactId>

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ LICENSE file.
143143
<rocksdb.version>6.2.2</rocksdb.version>
144144
<s3.version>1.10.20</s3.version>
145145
<seaweed.client.version>1.4.1</seaweed.client.version>
146+
<scylla.cql.version>3.10.1-scylla-0</scylla.cql.version>
146147
<solr7.version>7.7.2</solr7.version>
147148
<tarantool.version>1.6.5</tarantool.version>
148149
<thrift.version>0.8.0</thrift.version>
@@ -196,6 +197,7 @@ LICENSE file.
196197
<module>rocksdb</module>
197198
<module>s3</module>
198199
<module>seaweedfs</module>
200+
<module>scylla</module>
199201
<module>solr7</module>
200202
<module>tarantool</module>
201203
<module>tablestore</module>

scylla/README.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
<!--
2+
Copyright (c) 2020 YCSB contributors. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License"); you
5+
may not use this file except in compliance with the License. You
6+
may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13+
implied. See the License for the specific language governing
14+
permissions and limitations under the License. See accompanying
15+
LICENSE file.
16+
-->
17+
18+
# Scylla CQL binding
19+
20+
Binding for [Scylla](https://www.scylladb.com/), using the CQL API
21+
via the [Scylla driver](https://github.com/scylladb/java-driver/).
22+
23+
Requires JDK8.
24+
25+
## Creating a table for use with YCSB
26+
27+
For keyspace `ycsb`, table `usertable`:
28+
29+
cqlsh> create keyspace ycsb
30+
WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 3 };
31+
cqlsh> USE ycsb;
32+
cqlsh> create table usertable (
33+
y_id varchar primary key,
34+
field0 varchar,
35+
field1 varchar,
36+
field2 varchar,
37+
field3 varchar,
38+
field4 varchar,
39+
field5 varchar,
40+
field6 varchar,
41+
field7 varchar,
42+
field8 varchar,
43+
field9 varchar);
44+
45+
**Note that `replication_factor` and consistency levels (below) will affect performance.**
46+
47+
## Quick start
48+
49+
Create a keyspace, and a table as mentioned above. Load data with:
50+
51+
$ bin/ycsb load scylla -s -P workloads/workloada \
52+
-threads 84 -p recordcount=1000000000 \
53+
-p readproportion=0 -p updateproportion=0 \
54+
-p fieldcount=10 -p fieldlength=128 \
55+
-p insertstart=0 -p insertcount=1000000000 \
56+
-p cassandra.coreconnections=14 -p cassandra.maxconnections=14 \
57+
-p cassandra.username=cassandra -p cassandra.password=cassandra \
58+
-p scylla.hosts=ip1,ip2,ip3,...
59+
60+
Use as following:
61+
62+
$ bin/ycsb run scylla -s -P workloads/workloada \
63+
-target 120000 -threads 840 -p recordcount=1000000000 \
64+
-p fieldcount=10 -p fieldlength=128 \
65+
-p operationcount=50000000 \
66+
-p scylla.coreconnections=280 -p scylla.maxconnections=280 \
67+
-p scylla.username=cassandra -p scylla.password=cassandra \
68+
-p scylla.hosts=ip1,ip2,ip3,... \
69+
-p scylla.tokenaware=true
70+
71+
## On choosing meaningful configuration
72+
73+
### 1. Load target
74+
75+
You want to test how a database handles load. To get the performance picture
76+
you would want to look at the latency distribution and utilization under the
77+
constant load. To select load use `-target` to state desired throughput level.
78+
79+
For example `-target 120000` means that we expect YCSB workers to generate
80+
120,000 requests per second (RPS, QPS or TPS) to the database.
81+
82+
Why is this important? Because without setting target throughput you will be
83+
looking only on the system equilibrium point that in the face of constantly
84+
varying latency will not allow you to see either throughput, nor latency.
85+
86+
For more information check out these resources on the coordinated omission problem:
87+
88+
See
89+
[[1]](http://highscalability.com/blog/2015/10/5/your-load-generator-is-probably-lying-to-you-take-the-red-pi.html)
90+
[[2]](https://medium.com/@siddontang/the-coordinated-omission-problem-in-the-benchmark-tools-5d9abef79279)
91+
[[3]](https://bravenewgeek.com/tag/coordinated-omission/)
92+
and [[this]](https://www.youtube.com/watch?v=lJ8ydIuPFeU)
93+
great talk by Gil Tene.
94+
95+
### 2. Parallelism factor and threads
96+
97+
Scylla utilizes [thread-per-core](https://www.scylladb.com/product/technology/) architecture design.
98+
That means that a Node consists of shards that are mapped to the CPU cores 1-per-core.
99+
100+
In production setup, Scylla reserves 1 core to the interrupts handling and other system stuff.
101+
For the system with hyper threading (HT) it means 2 virtual cores. From that follows that the number
102+
of _Shards_ per _Node_ typically is `Number Of Cores - 2` for HT machine and
103+
`Number Of Cores - 1` for a machine without HT.
104+
105+
It makes sense to select number of YCSB worker _threads_ to be multiple of the number
106+
of shards, and the number of nodes in the cluster. For example:
107+
108+
AWS Amazon i3.4xlarge has 16 vCPU (8 physical cores with HT).
109+
110+
=>
111+
112+
scylla node shards = vCPUs - 2 = 16 - 2 = 14
113+
114+
=>
115+
116+
threads = K * shards * nodes = K * 14 * nodes
117+
118+
for i3.4xlarge where
119+
120+
- K is parallelism factor >= 1,
121+
- Nodes is number of nodes in the cluster.
122+
123+
For example for 3 nodes `i3.4xlarge` and `-threads 840` means
124+
`K = 20`, `shards = 14`, and `threads = 14 * 20 * 3`.
125+
126+
Thus, the `K` - the parallelism factor must be selected in the first order. If you
127+
don't know what you want out of it start with 1.
128+
129+
For picking desired parallelism factor it is useful to come from desired `target`
130+
parameter. It is better if the `target` is a multiple of `threads`.
131+
132+
Another concern is that for high throughput scenarios you would probably
133+
want to keep shards incoming queues non-empty. For that your parallelism factor
134+
must be at least 2.
135+
136+
### 3. Number of connections
137+
138+
Both `scylla.coreconnections` and `scylla.maxconnections` define limits
139+
per node. When you see `-p scylla.coreconnections=280 -p scylla.maxconnections=280`
140+
that means 280 connections per node.
141+
142+
Number of connections must be a multiple of:
143+
144+
- number of _shards_
145+
- parallelism factor `K`
146+
147+
For example, for `i3.4xlarge` that has 14 shards per node and `K = 20`
148+
it makes sense to pick `connections = shards * K = 14 * 20 = 280`.
149+
150+
### 4. Other considerations
151+
152+
Consistency levels do not change consistency model or its strongness.
153+
Even with `-p scylla.writeconsistencylevel=ONE` the data will be written
154+
according to the number of a table replication factor (RF). Usually,
155+
by default RF = 3. By using `-p scylla.writeconsistencylevel=ONE` you
156+
can omit waiting all replicas to write the value. It will improve your
157+
latency picture a bit but would not affect utilization.
158+
159+
Remember that you can't measure CPU utilization with Scylla by normal
160+
Unix tools. Check out Scylla own metrics to see real reactors utilization.
161+
162+
Always use [token aware](https://www.scylladb.com/2019/03/27/best-practices-for-scylla-applications/)
163+
load balancing `-p scylla.tokenaware=true`.
164+
165+
For best performance it is crucial to evenly load all available shards.
166+
167+
### 5. Expected performance target
168+
169+
You can expect about 12500 uOPS / core (shard), where uOPS are basic
170+
reads and writes operations post replication. Don't forget that usually
171+
`Core = 2 * vCPU` for HT systems.
172+
173+
For example if we insert a row with RF = 3 we can count at least 3 writes -
174+
1 write per each replica. That is 1 Transaction = 3 u operations.
175+
176+
Formula for evaluating performance with respect to workloads is:
177+
178+
uOPS / vCPU = [
179+
Transactions * Writes_Ratio * Replication_Factor +
180+
Transactions * Read_Ratio * Read_Consistency_level
181+
] / [ (vCPU_per_node - 2) * (nodes) ]
182+
183+
where Transactions == `-target` parameter (target throughput).
184+
185+
For example for _workloada_ that is 50/50 reads and writes for a cluster
186+
of 3 nodes of i3.4xlarge (16 vCPU per node) and target of 120000 is:
187+
188+
[ 120K * 0.5 * 3 + 120K * 0.5 * 2 (QUORUM) ] / [ (16 - 2) * 3 nodes ] =
189+
= 7142 uOPS / vCPU ~ 14000 uOPS / Core.
190+
191+
## Scylla configuration parameters
192+
193+
- `scylla.hosts` (**required**)
194+
- A list of Scylla nodes to connect to.
195+
- No default. Usage: `-p scylla.hosts=ip1,ip2,ip3,...`
196+
197+
* `scylla.port`
198+
199+
- CQL port for communicating with Scylla cluster.
200+
This port must be the same on all cluster nodes.
201+
- Default is `9042`.
202+
203+
- `scylla.keyspace`
204+
205+
- keyspace name - must match the keyspace for the table created (see above).
206+
See https://docs.scylladb.com/getting-started/ddl/#create-keyspace-statement for details.
207+
- Default value is `ycsb`
208+
209+
- `scylla.username` and `scylla.password`
210+
211+
- Optional user name and password for authentication.
212+
- See https://docs.scylladb.com/operating-scylla/security/enable-authorization/ for details.
213+
214+
* `scylla.readconsistencylevel`
215+
* `scylla.writeconsistencylevel`
216+
217+
* Default value is `QUORUM`
218+
- Consistency level for reads and writes, respectively.
219+
See the [Scylla documentation](https://docs.scylladb.com/glossary/#term-consistency-level-any) for details.
220+
221+
* `scylla.maxconnections`
222+
* `scylla.coreconnections`
223+
224+
* Defaults for max and core connections can be found here:
225+
https://github.com/scylladb/java-driver/tree/latest/manual/pooling.
226+
227+
* `scylla.connecttimeoutmillis`
228+
* `scylla.readtimeoutmillis`
229+
* `scylla.useSSL`
230+
231+
* Default value is false.
232+
- To connect with SSL set this value to true.
233+
234+
* `scylla.tracing`
235+
* Default is false
236+
* https://docs.scylladb.com/using-scylla/tracing/
237+
238+
- `scylla.tokenaware`
239+
- Enable token awareness
240+
- Default value is false.
241+
242+
- `scylla.tokenaware_local_dc`
243+
- Restrict Round Robin child policy with the local dc nodes
244+
- Default value is empty.
245+
246+
- `scylla.lwt`
247+
- Use LWT for operations
248+
- Default is false.

0 commit comments

Comments
 (0)