Reader and writer endpoints for Redis #43128
Replies: 4 comments 4 replies
-
Look at databases.php, by default you have a cache and a session store, pointing at the same redis instance, but you should already be able to add multiple redis instances either in cloud or single mode. Just pass the name of the store. https://laravel.com/docs/9.x/cache#accessing-multiple-cache-stores |
Beta Was this translation helpful? Give feedback.
-
Hitting this issue now. We have a Redis cluster (cluster mode disabled) in AWS. Our metrics graphs show that all traffic is being sent to the primary endpoint. This is (i guess) expected, since we are only connecting to the primary node.
Since most if not all our Redis usage is the session driver, we have very little control over how that is done. So we are faced with these courses of action:
|
Beta Was this translation helpful? Give feedback.
-
You raise a good point. Adding support for multiple Redis hosts in Laravel similar to database connections would be beneficial, especially for configuring read replicas and improving performance/scalability. Here are a few ways Laravel could potentially implement multi-host Redis support: Allow defining separate read and write hosts in the Redis configuration file, like you demonstrated. Laravel could then automatically send read operations to the read hosts and write operations to the write host. |
Beta Was this translation helpful? Give feedback.
-
just to bring the conversation up. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, Laravel supports a single endpoint for Redis; however, many cloud providers "provide" or projects "need" to have separate endpoints for reading and writing data to Redis.
Can we look to add multi-host support for Redis in laravel, just like database connection?
Database:
[ 'read' => [ 'host' => [ '192.168.1.1', '196.168.1.2', ], ], 'write' => [ 'host' => [ '196.168.1.3', ], ],
Redis (Currently):
'host' => env('REDIS_HOST', '127.0.0.1'),
Redis (Requesting):
'host' => [ 'read' => [ 'host' => [ '192.168.1.1', '196.168.1.2', ], ], 'write' => [ 'host' => [ '196.168.1.3', ], ],
Beta Was this translation helpful? Give feedback.
All reactions