Skip to content

Commit c821f4b

Browse files
committed
Add RPC load tests
1 parent c24d88f commit c821f4b

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

k6/RPCGETSingle.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Rate } from "k6/metrics";
2+
import { check, group, sleep } from 'k6';
3+
import http from 'k6/http';
4+
5+
const URL = "http://" + __ENV.HOST;
6+
7+
const RATE = (function(){
8+
if(__ENV.VERSION == 'v701'){
9+
switch(__ENV.HOST){
10+
case 'c5xlarge': return 2400;
11+
case 't3axlarge': return 1600;
12+
case 't3anano': return 1500;
13+
default: return 1000;
14+
}
15+
}
16+
else switch(__ENV.HOST){
17+
case 'c5xlarge': return 3000;
18+
case 't3axlarge': return 2300;
19+
case 't3anano': return 2100;
20+
default: return 1000;
21+
}
22+
})();
23+
24+
export let options = {
25+
discardResponseBodies: true,
26+
scenarios: {
27+
constant_request_rate: {
28+
executor: 'constant-arrival-rate',
29+
rate: RATE,
30+
timeUnit: '1s',
31+
duration: '30s',
32+
preAllocatedVUs: 100,
33+
maxVUs: 600,
34+
}
35+
},
36+
thresholds: {
37+
'failed requests': ['rate<0.1'],
38+
'http_req_duration': ['p(95)<1000']
39+
}
40+
};
41+
42+
const myFailRate = new Rate('failed requests');
43+
44+
export default function() {
45+
let res = http.get(URL + "/rpc/ret_artists?select=*&artist_id=eq.3");
46+
myFailRate.add(res.status !== 200);
47+
}

k6/RPCGETSingleEmbed.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Rate } from "k6/metrics";
2+
import { check, group, sleep } from 'k6';
3+
import http from 'k6/http';
4+
5+
const URL = "http://" + __ENV.HOST;
6+
7+
const RATE = (function(){
8+
if(__ENV.VERSION == 'v701'){
9+
switch(__ENV.HOST){
10+
case 'c5xlarge': return 1100;
11+
case 't3axlarge': return 850;
12+
case 't3anano': return 600;
13+
default: return 1000;
14+
}
15+
}
16+
else switch(__ENV.HOST){
17+
case 'c5xlarge': return 1200;
18+
case 't3axlarge': return 1000;
19+
case 't3anano': return 700;
20+
default: return 1000;
21+
}
22+
})();
23+
24+
export let options = {
25+
discardResponseBodies: true,
26+
scenarios: {
27+
constant_request_rate: {
28+
executor: 'constant-arrival-rate',
29+
rate: RATE,
30+
timeUnit: '1s',
31+
duration: '30s',
32+
preAllocatedVUs: 100,
33+
maxVUs: 600,
34+
}
35+
},
36+
thresholds: {
37+
'failed requests': ['rate<0.1'],
38+
'http_req_duration': ['p(95)<1000']
39+
}
40+
};
41+
42+
const myFailRate = new Rate('failed requests');
43+
44+
export default function() {
45+
let res = http.get(URL + "/rpc/ret_albums?select=album_id,title,artist_id,track(*,genre(*))&artist_id=eq.127");
46+
myFailRate.add(res.status !== 200);
47+
}

k6/RPCSimple.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Rate } from "k6/metrics";
2+
import { check, group, sleep } from 'k6';
3+
import http from 'k6/http';
4+
5+
const URL = "http://" + __ENV.HOST;
6+
7+
const RATE = (function(){
8+
if(__ENV.VERSION == 'v701'){
9+
switch(__ENV.HOST){
10+
case 'c5xlarge': return 2400;
11+
case 't3axlarge': return 1600;
12+
case 't3anano': return 1600;
13+
default: return 1500;
14+
}
15+
}
16+
else switch(__ENV.HOST){
17+
case 'c5xlarge': return 3000;
18+
case 't3axlarge': return 2200;
19+
case 't3anano': return 2000;
20+
default: return 1000;
21+
}
22+
})();
23+
24+
export let options = {
25+
discardResponseBodies: true,
26+
scenarios: {
27+
constant_request_rate: {
28+
executor: 'constant-arrival-rate',
29+
rate: RATE,
30+
timeUnit: '1s',
31+
duration: '30s',
32+
preAllocatedVUs: 100,
33+
maxVUs: 600,
34+
}
35+
},
36+
thresholds: {
37+
'failed requests': ['rate<0.1'],
38+
'http_req_duration': ['p(95)<1000']
39+
}
40+
};
41+
42+
const myFailRate = new Rate('failed requests');
43+
44+
export default function() {
45+
//let res = http.get(URL + "/rpc/add_them1?a=1&b=2&c=3&d=4&e=5");
46+
let res = http.get(URL + "/rpc/add_them2?a=1&b=2&c=3&d=4&e=5&v=0");
47+
//let res = http.get(URL + "/rpc/add_them3?v=1&v=2&v=3&v=4&v=5");
48+
myFailRate.add(res.status !== 200);
49+
}

sql/chinook.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Modified for postgrest-benchmark:
1919
Summary of Changes:
2020
- Removed employee table indexes and constraints
21+
- Added add_them, ret_albums and ret_artists functions
2122
********************************************************************************/
2223

2324

@@ -23861,3 +23862,15 @@ ALTER TABLE "film_actor" ADD PRIMARY KEY ("actor_id", "film_id");
2386123862
alter table employee drop constraint pk_employee cascade;
2386223863
drop index ifk_employee_reports_to;
2386323864
drop sequence employee_employee_id_seq cascade;
23865+
23866+
create or replace function ret_albums() returns setof album as $$
23867+
select * from album
23868+
$$ language sql;
23869+
23870+
create or replace function ret_artists() returns setof artist as $$
23871+
select * from artist
23872+
$$ language sql;
23873+
23874+
create or replace function add_them(a int, b int, c int, d int, e int) returns int as $$
23875+
select a + b + c + d + e;
23876+
$$ language sql;

0 commit comments

Comments
 (0)