ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

Feature Request: Pooling

Open Tomato6966 opened this issue 3 years ago • 2 comments

Add a Option when creating a Redis for: pool: { min: number = 10, max: number = 250 }

This increases production, not having to code it manually with e.g. https://npmjs.org/generic-pool

It would just add a couple functions in all execution methods:

// example:
async function executeRedisCommand(method, ...extras) {
  const clientOfPool = await redis.pool.acquire();
  const res = clientOfPool[method](...extras);
  await redis.pool.release(conn);
  return res;
}

Thanks!

Tomato6966 avatar Aug 27 '22 10:08 Tomato6966

What commands are you running? Have you tried https://github.com/luin/ioredis#autopipelining ?

TysonAndre avatar Oct 30 '22 00:10 TysonAndre

Hi @TysonAndre , Reading autopipelining docu:

When using Redis Cluster, one pipeline per node is created. Commands are assigned to pipelines according to which node serves the slot. A pipeline will thus contain commands using different slots but that ultimately are assigned to the same node. Note that the same slot limitation within a single command still holds, as it is a Redis limitation.

To make sure i understand, autopipieline is supported with any key that i use right? multiple keys (even in same node) are scattered among different hash slot (According to key) - so this sill works? if some keys (in same node) are scattered in 3 hashslot, there wil be one pipeline with 3 commands?

what are the drawbacks or when not to use autopipelining ?

Will it be more beneficial to create pooling? (or in addition to autopipelining) multiple connections working on same redis will work fast? or delay other connections?

thanks, Tal

taltal78 avatar Dec 15 '24 08:12 taltal78