Skip to content

Commit 2f3732a

Browse files
passing connect timeout and slots refresh interval
1 parent 2d29e9e commit 2f3732a

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

js/lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function parseArgs() {
3030
.option('rand-seed', { default: 12345 })
3131
.option('subscriber-prefix', { default: 'channel-' })
3232
.option('oss-cluster-api-distribute-subscribers', { default: false })
33+
.option('slot-refresh-interval', { default: -1 })
3334
.option('print-messages', { default: false })
3435
.option('verbose', { default: false })
3536
.option('measure-rtt-latency', { default: false })

js/lib/redisManager.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ async function runBenchmark(argv) {
4747
let clients = [];
4848
let nodeAddresses = [];
4949
let slotClientMap = new Map();
50+
console.log(`Using ${argv['slot-refresh-interval']} slot-refresh-interval`);
51+
console.log(`Using ${argv['redis-timeout']} redis-timeout`);
5052

5153
if (argv['oss-cluster-api-distribute-subscribers']) {
5254
const cluster = new Redis.Cluster(
@@ -60,7 +62,9 @@ async function runBenchmark(argv) {
6062
redisOptions,
6163
scaleReads: 'master',
6264
enableReadyCheck: true,
63-
lazyConnect: false
65+
lazyConnect: false,
66+
connectTimeout: argv['redis-timeout'],
67+
slotsRefreshInterval: argv['slot-refresh-interval']
6468
}
6569
);
6670

@@ -77,11 +81,11 @@ async function runBenchmark(argv) {
7781
port,
7882
username: argv.user || undefined,
7983
password: argv.a || undefined,
80-
connectTimeout: argv['redis-timeout'],
81-
commandTimeout: argv['redis-timeout'],
8284
maxRetriesPerRequest: 1,
8385
enableReadyCheck: true,
84-
lazyConnect: false
86+
lazyConnect: false,
87+
connectTimeout: argv['redis-timeout'],
88+
slotsRefreshInterval: argv['slot-refresh-interval']
8589
});
8690

8791
// Save one entry per slot
@@ -147,7 +151,9 @@ async function runBenchmark(argv) {
147151
console.log(`Reconnect interval for ${subscriberName}: ${reconnectInterval}ms`);
148152
}
149153

150-
console.log(`${subscriberName} subscribing to ${channels.length} channels.`);
154+
if (clientId % 100 === 0 || clientId === argv.clients) {
155+
console.log(`${subscriberName} subscribing to ${channels.length} channels.`);
156+
}
151157

152158
promises.push(
153159
subscriberRoutine(
@@ -163,7 +169,8 @@ async function runBenchmark(argv) {
163169
totalMessagesRef,
164170
totalSubscribedRef,
165171
totalConnectsRef,
166-
argv.verbose
172+
argv.verbose,
173+
argv.cliens
167174
)
168175
);
169176
}

js/lib/subscriber.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ async function subscriberRoutine(
1515
totalMessagesRef,
1616
totalSubscribedRef,
1717
totalConnectsRef,
18-
verbose
18+
verbose,
19+
totalClients
1920
) {
2021
let pubsub = null;
2122
let reconnectTimer = null;
@@ -143,9 +144,13 @@ async function subscriberRoutine(
143144
const check = setInterval(async () => {
144145
if (!isRunningRef.value) {
145146
clearInterval(check);
146-
console.log(`[${clientName}] Triggering shutdown...`);
147+
const clientId = parseInt(clientName.split('#')[1], 10);
148+
const shouldLog = clientId % 100 === 0 || clientId === totalClients;
149+
150+
if (shouldLog) console.log(`[${clientName}] Triggering shutdown...`);
151+
147152
await shutdown();
148-
console.log(`[${clientName}] Shutdown complete.`);
153+
if (shouldLog) console.log(`[${clientName}] Shutdown complete.`);
149154
resolve();
150155
}
151156
}, 500);

0 commit comments

Comments
 (0)