PHP redis session handler - changing number of servers - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, October 27, 2023

PHP redis session handler - changing number of servers

I am using phpredis as a session handler (https://github.com/phpredis/phpredis). My current connection string looks like this:

session.save_path = "tcp://10.0.1.11:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5,
tcp://10.0.1.12:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5"

but i need to add more redis servers and move existing sessions among them.

My new connection string will look like this:

session.save_path = "tcp://10.0.1.11:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5,
tcp://10.0.1.12:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5,
tcp://10.0.1.13:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5,
tcp://10.0.1.14:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5,
tcp://10.0.1.15:7005?weight=1&timeout=0.2&persistent=1&read_timeout=0.5"

so there will be 3 more servers and sessions distribution by key will change with number of servers.

How can i move existing sessions from old servers to new servers to have each one on right server then? Are there any existing tools for this? Has anyone had a similar problem and have a ready solution for it?



source https://stackoverflow.com/questions/77369189/php-redis-session-handler-changing-number-of-servers

No comments:

Post a Comment