robdesilets's avatar

Moving from Lumen to Octane: Question about Redis / Redis Sentinel

Hi All,

Right now we have a main Laravel application that we use for our web site dashboard and then many smaller Lumen applications that handle very high volume requests to our servers (each Lumen application is running on their own virtual servers).

Even though it seems like Lumen will be around for a while, I would like to move to Octane as it seems more modern.

My thought is that I can merge all of the routes I currently have for the various Lumen applications into the main Laravel application and run Octane (using Swoole) on the servers that are currently running Lumen.

We use Redis extensively with Redis Sentinel that monitors all of the replicas and if a replica goes down it will automatically promote a replica to the master.

So here is what I am trying to figure out:

Right now in Lumen for each request when the Redis Service Provider starts it will get the current master from Sentinel and then for that entire request it will read/write to that node (eg. redis01, redis02, etc).

As I understand Octane, which makes sense, the Service Providers and will start up when the octane servers starts and stay in memory for the duration of that server run.

However, doesn't that mean that the Redis Service Provider starts up, it will get the current master from Sentinel, and keep that in memory. So in the event that master went down and switched to another node (e.g from redis01 to redis02) the entire system would go down because at this point Redis is pointing at a server that is no longer around, completely negating the point of Sentinel switching to a new master.

Edited to add:

I see this in the docs but not sure what it means:

Octane will automatically handle resetting any first-party framework state between requests.

This would be somewhat hackish, but I could create an Octane timer that runs every 5 seconds, and check the current Redis master against a saved variable of the master (grab the master when the worker boots) and if it changes, I could reload the workers using php artisan octane:reload. But that would mean for the time between the changing of the Redis master until I detected and restarted the workers, the system would be essentially down.

Thanks!

-Rob

0 likes
0 replies

Please or to participate in this conversation.