-
Notifications
You must be signed in to change notification settings - Fork 0
/
http-jsonapi-vector-crud.yaml
217 lines (191 loc) · 10.6 KB
/
http-jsonapi-vector-crud.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
min_version: "5.17.3"
# Example command line
# Against AstraDB
# nb5 -v http-jsonapi-vector-crud docscount=1000 threads=20 jsonapi_host=Your-AstraDB-Host auth_token=Your-AstraDB-Token jsonapi_port=443 protocol=https path_prefix=/api/json namespace=Your-Keyspace
# Against local JSON API
# nb5 -v http-jsonapi-vector-crud jsonapi_host=localhost docscount=1000 threads=20
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud docscount=10000 threads=100 jsonapi_host=73f6cab6-8b09-4f19-92f4-7749210ba9d1-us-west-2.apps.astra-dev.datastax.com auth_token=AstraCS:MQogsfOpJhOmSBNhwXqKSfbk:aea3bbe705a9bb976626a6b88f8735296bc2a633b913fd392d8a88e125f1cf72 jsonapi_port=443 protocol=https path_prefix=/api/json namespace=photography
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud --report-csv-to ./ docscount=1000 threads=20 jsonapi_host=608a376b-d779-4b4b-bc2e-fb136dafff75-europe-west4.apps.astra-dev.datastax.com auth_token=AstraCS:MQogsfOpJhOmSBNhwXqKSfbk:aea3bbe705a9bb976626a6b88f8735296bc2a633b913fd392d8a88e125f1cf72 jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks9
# --report-csv-to metrics_directory
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud --report-prompush-to http://127.0.0.1:8428/api/v1/import/prometheus/metrics/job/nosqlbench/instance/zen_brahmagupta docscount=1000 threads=20 jsonapi_host=608a376b-d779-4b4b-bc2e-fb136dafff75-europe-west4.apps.astra-dev.datastax.com auth_token=AstraCS:MQogsfOpJhOmSBNhwXqKSfbk:aea3bbe705a9bb976626a6b88f8735296bc2a633b913fd392d8a88e125f1cf72 jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks9
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud --docker-metrics-at http://127.0.0.1:8428/api/v1/import/prometheus/metrics/job/nosqlbench/instance/zen_brahmagupta docscount=1000 threads=20 jsonapi_host=608a376b-d779-4b4b-bc2e-fb136dafff75-europe-west4.apps.astra-dev.datastax.com auth_token=AstraCS:MQogsfOpJhOmSBNhwXqKSfbk:aea3bbe705a9bb976626a6b88f8735296bc2a633b913fd392d8a88e125f1cf72 jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks9
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud docscount=1000 threads=20 jsonapi_host=608a376b-d779-4b4b-bc2e-fb136dafff75-europe-west4.apps.astra-dev.datastax.com auth_token=AstraCS:MQogsfOpJhOmSBNhwXqKSfbk:aea3bbe705a9bb976626a6b88f8735296bc2a633b913fd392d8a88e125f1cf72 jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks9 --docker-metrics
# Local
# Prod
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud docscount=10000 threads=100 jsonapi_host=a32c9d78-6948-491f-b843-9edb39ce1b0b-us-east-2.apps.astra.datastax.com auth_token=AstraCS:ZBXmMhtJWQHIlIaRLhCrfYvh:bf3220b3e553dac99fbc203e502820f0233386d2dd56ccd2d16b9a6c89e5fd4f jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks0
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud --report-prompush-to http://127.0.0.1:8428/api/v1/import/prometheus/metrics/job/nosqlbench/instance/zen_brahmagupta docscount=10000 threads=100 jsonapi_host=a32c9d78-6948-491f-b843-9edb39ce1b0b-us-east-2.apps.astra.datastax.com auth_token=AstraCS:ZBXmMhtJWQHIlIaRLhCrfYvh:bf3220b3e553dac99fbc203e502820f0233386d2dd56ccd2d16b9a6c89e5fd4f jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks0
# java -jar ~/nb5.jar -v http-jsonapi-vector-crud --docker-metrics-at http://127.0.0.1:8428/api/v1/import/prometheus/metrics/job/nosqlbench/instance/zen_brahmagupta docscount=10000 threads=100 jsonapi_host=a32c9d78-6948-491f-b843-9edb39ce1b0b-us-east-2.apps.astra.datastax.com auth_token=AstraCS:ZBXmMhtJWQHIlIaRLhCrfYvh:bf3220b3e553dac99fbc203e502820f0233386d2dd56ccd2d16b9a6c89e5fd4f jsonapi_port=443 protocol=https path_prefix=/api/json namespace=testks0
#Dev
description: >2
This workload emulates vector CRUD operations for Stargate JSON API.
It requires a data set file (default vector-dataset.txt), where contains vectors of size 1536
1536 is a standard vector size that openAI embedding generates, using this size for benchmark
scenarios:
default:
# schema: run driver=http tags==block:schema threads==1 cycles==UNDEF
write: run driver=http tags==name:"write.*" cycles===TEMPLATE(write-cycles,TEMPLATE(docscount,500)) threads=auto errors=timer,warn
# read: run driver=http tags==name:"read.*" cycles===TEMPLATE(read-cycles,TEMPLATE(docscount,500)) threads=auto errors=timer,warn
update: run driver=http tags==name:"update.*" cycles===TEMPLATE(update-cycles,TEMPLATE(docscount,500)) threads=auto errors=timer,warn
# delete: run driver=http tags==name:"delete.*" cycles===TEMPLATE(delete-cycles,TEMPLATE(docscount,500)) threads=auto errors=timer,warn
bindings:
# To enable an optional weighted set of hosts in place of a load balancer
# Examples
# single host: jsonapi_host=host1
# multiple hosts: jsonapi_host=host1,host2,host3
# multiple weighted hosts: jsonapi_host=host1:3,host2:7
weighted_hosts: WeightedStrings('<<jsonapi_host:jsonapi>>')
# spread into different spaces to use multiple connections
space: HashRange(1,<<connections:20>>); ToString();
# http request id
request_id: ToHashedUUID(); ToString();
# autogenerate auth token to use on API calls using configured uri/uid/password, unless one is provided
token: Discard(); Token('<<auth_token:>>','<<uri:http://localhost:8081/v1/auth>>', '<<uid:cassandra>>', '<<pswd:cassandra>>');
seq_key: Mod(<<docscount:500>>); ToString() -> String
random_key: Uniform(0,<<docscount:500>>); ToString() -> String
vector_json: HashedLineToString('<<dataset:vector-dataset.txt>>');
blocks:
schema:
ops:
# create-namespace:
# method: POST
# uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1
# Accept: "application/json"
# X-Cassandra-Request-Id: "{request_id}"
# X-Cassandra-Token: "{token}"
# Content-Type: "application/json"
# ok-body: ".*\"ok\":1.*"
# body: >2
# {
# "createNamespace": {
# "name": "<<namespace:jsonapi_vector_crud_namespace>>"
# }
# }
delete-collection:
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
body: >2
{
"deleteCollection": {
"name": "<<collection:jsonapi_vector_crud_collection>>"
}
}
create-collection:
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"ok\":1.*"
# vector mush be enabled when creating collection
body: >2
{
"createCollection": {
"name": "<<collection:jsonapi_vector_crud_collection>>",
"options": {
"vector": {
"size": 1536
}
}
}
}
write:
ops:
write-insert-one-vector:
params:
ratio: 5
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>/<<collection:jsonapi_vector_crud_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: '.*\"insertedIds\":\[.*\].*'
body: >2
{
"insertOne" : {
"document" : {
"_id" : "{seq_key}",
"$vector" : {vector_json}
}
}
}
read:
ops:
find-one-by-vector-projection:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>/<<collection:jsonapi_vector_crud_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"findOne": {
"sort" : {"$vector" : {vector_json}},
"projection" : {"$vector" : 1}
}
}
find-by-vector-projection:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>/<<collection:jsonapi_vector_crud_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"find": {
"sort" : {"$vector" : {vector_json}},
"projection" : {"$vector" : 1, "$similarity" : 1},
"options" : {
"limit" : 10
}
}
}
update:
ops:
find-one-update-vector:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>/<<collection:jsonapi_vector_crud_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"data\".*"
body: >2
{
"findOneAndUpdate": {
"sort" : {"$vector" : {vector_json}},
"update" : {"$set" : {"status" : "active"}},
"options" : {"returnDocument" : "after"}
}
}
delete:
ops:
delete-document:
space: "{space}"
method: POST
uri: <<protocol:http>>://{weighted_hosts}:<<jsonapi_port:8181>><<path_prefix:>>/v1/<<namespace:jsonapi_vector_crud_namespace>>/<<collection:jsonapi_vector_crud_collection>>
Accept: "application/json"
X-Cassandra-Request-Id: "{request_id}"
X-Cassandra-Token: "{token}"
Content-Type: "application/json"
ok-body: ".*\"deletedCount\":[0,1].*"
body: >2
{
"findOneAndDelete": {
"sort" : {"$vector" : {vector_json}}
}
}