Skip to content

fix(client): cache subsequent clients #2963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2025

Conversation

nkaradzhov
Copy link
Collaborator

@nkaradzhov nkaradzhov commented May 14, 2025

we dont need to recreate a client if
its config hasnt changed

fixes #2954

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

we dont need to recreate a client if
its config hasnt changed

fixes redis#2954
@nkaradzhov
Copy link
Collaborator Author

using the following test script we can see reasonable numbers

import { createClient, createClientPool, createCluster } from './packages/client'


const n = 200
const start1 = performance.now();
for (let i = 0; i < n; i++) {
  createClient();
}
console.log(`createClient(${n})`, performance.now() - start1);

const start2 = performance.now();
for (let i = 0; i < n; i++) {
  createClientPool();
}
console.log(`createClientPool(${n})`, performance.now() - start2);

const start3 = performance.now();
for (let i = 0; i < n; i++) {
 createCluster()
}
console.log(`createCluster(${n})`, performance.now() - start3);

Copy link
Member

@bobymicroby bobymicroby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nkaradzhov nkaradzhov merged commit 6f961bd into redis:master May 14, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

createClient in v5 is much slower than in v4
2 participants