redis-plus-plus icon indicating copy to clipboard operation
redis-plus-plus copied to clipboard

[QUESTION] Shared Connection pool for redis between services

Open Purushoth24051999 opened this issue 2 months ago • 3 comments

Hi, I have tried to create a common connection Pool for multiple services by passing Redis class object through shared memory (IPC). But I cannot use this shared Redis object in other services except in service where connections are created. It throws "Reading Access Violation" error

Is it possible to create a Common Redis connection pool between services

Note: All these services are running in single machine

Purushoth24051999 avatar May 06 '24 09:05 Purushoth24051999

I'm not familiar with shared memory. However, after some searching, I found this link says that class with virtual pointer cannot work with shared memory.

Redis class has 2 shared_ptr data members, which might have virtual pointer, e.g. it's a derived class.

In a word, you cannot use Redis class with shared memory.

By the way, why not use different Redis object for different processes?

sewenew avatar May 08 '24 05:05 sewenew

I'm not familiar with shared memory. However, after some searching, I found this link says that class with virtual pointer cannot work with shared memory.

Redis class has 2 shared_ptr data members, which might have virtual pointer, e.g. it's a derived class.

In a word, you cannot use Redis class with shared memory.

By the way, why not use different Redis object for different processes?

In my case I'm supposed to create as many process user requests. Since redis has maximum connection limit which has a default value 10000, creating seperate connection for each process might exceed the limit and becomes a costly process for my application

Since several modules in my project share common redis server I not supposed to alter max connection limit of redis. That's why I tried using it

Purushoth24051999 avatar May 09 '24 16:05 Purushoth24051999

I have achieved my requirement through creating a connection pool in parent service and child processes will request parent to perform redis operations through uv_tcp_t from libuv library

Purushoth24051999 avatar May 09 '24 16:05 Purushoth24051999

I'm supposed to create as many process user requests

This is not a good idea. You'd better reuse the connection.

Since you've solved the problem, I'll close this issue. If you still have problem with it, feel free to reopen it.

Regards

sewenew avatar May 10 '24 05:05 sewenew