Skip to content

Commit 042bfdc

Browse files
Merge pull request #30 from redis-performance/bench_fix
fix ioredis benchmark, utilize cluster client fully
2 parents 4c8d3c8 + 8a22bab commit 042bfdc

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

js/ioredis/lib/redisManager.js

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,10 @@ async function runBenchmark(argv) {
7373
}
7474
);
7575

76-
// Fetch slot info to build map
77-
const slots = await cluster.cluster('slots');
78-
if (!slots || slots.length === 0) {
79-
throw new Error('Cluster has no slot assignments. Check node health.');
80-
}
8176

82-
// Create a standalone client for each slot range
83-
for (const [startSlot, endSlot, [ip, port]] of slots) {
84-
const client = new Redis({
85-
host: ip,
86-
port,
87-
username: argv.user || undefined,
88-
password: argv.a || undefined,
89-
maxRetriesPerRequest: 1,
90-
enableReadyCheck: true,
91-
lazyConnect: false,
92-
connectTimeout: argv['redis-timeout'],
93-
slotsRefreshInterval: argv['slot-refresh-interval']
94-
});
9577

96-
// Save one entry per slot
97-
for (let slot = startSlot; slot <= endSlot; slot++) {
98-
slotClientMap.set(slot, client);
99-
}
100-
101-
nodeAddresses.push(`${ip}:${port}`);
102-
clients.push(client);
103-
}
78+
clients.push(cluster);
79+
10480
console.log(`Cluster mode - using ${nodeAddresses.length} unique nodes`);
10581
} else {
10682
const client = new Redis(redisOptions);
@@ -153,14 +129,7 @@ async function runBenchmark(argv) {
153129
const publisherName = `publisher#${clientId}`;
154130
let client;
155131

156-
if (argv.mode === 'spublish' && argv['oss-cluster-api-distribute-subscribers']) {
157-
// For sharded publish in cluster mode, get the appropriate client for the first channel
158-
const slot = clusterKeySlot(channels[0]);
159-
client = slotClientMap.get(slot);
160-
} else {
161-
// For regular publish or non-cluster, round-robin assignment
162-
client = clients[clientId % clients.length];
163-
}
132+
client = clients[0]
164133

165134
if (argv.verbose) {
166135
console.log(`Publisher ${clientId} targeting channels ${channels}`);

js/ioredis/package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)