Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save oliver-zehentleitner/82e407955b3c09ca25382069bf5cd5fa to your computer and use it in GitHub Desktop.

Select an option

Save oliver-zehentleitner/82e407955b3c09ca25382069bf5cd5fa to your computer and use it in GitHub Desktop.
Grafana Cloud k6 hot-market ramp test for stressing one replicated UBDCC DepthCache market and identifying its REST API degradation point.
import http from 'k6/http';
import { check } from 'k6';
const BASE_URL = __ENV.BASE_URL || 'http://YOUR_UBDCC_IP';
const EXCHANGE = __ENV.EXCHANGE || 'binance.com';
const MARKET = __ENV.MARKET || 'ETHBTC';
const LIMIT = __ENV.LIMIT || '100';
export const options = {
cloud: {
distribution: {
frankfurt: { loadZone: 'amazon:de:frankfurt', percent: 100 },
},
},
scenarios: {
hot_market_ramp: {
executor: 'ramping-arrival-rate',
startRate: 10,
timeUnit: '1s',
preAllocatedVUs: 100,
maxVUs: 1000,
stages: [
{ target: 25, duration: '1m' },
{ target: 50, duration: '1m' },
{ target: 100, duration: '1m' },
{ target: 250, duration: '1m' },
{ target: 500, duration: '1m' },
{ target: 0, duration: '30s' },
],
},
},
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<1000'],
},
};
export default function () {
const endpoint = Math.random() < 0.5 ? 'get_asks' : 'get_bids';
const url =
`${BASE_URL}/${endpoint}` +
`?exchange=${EXCHANGE}` +
`&market=${MARKET}` +
`&limit_count=${LIMIT}`;
const res = http.get(url, {
timeout: '5s',
tags: {
endpoint,
exchange: EXCHANGE,
market: MARKET,
limit: LIMIT,
test_type: 'hot_market',
},
});
check(res, {
'status is 200': (r) => r.status === 200,
'body is not empty': (r) => r.body && r.body.length > 10,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment