DEV Community

lechat
lechat

Posted on • Updated on

You sure you will go with Laravel Horizon?

You sure you will go with Laravel horizon? In some cases, you shouldn't. Especially when you use Redis cluster.

Horizon doesn't work with Redis cluster

Horizon doesn't work with Redis cluster if it has multiple shards. But this is not mentioned in the doc. You will notice it when you increase number of shards of Redis cluster, or when you find this issue. As a workaround, I tried hash tag keys, but Laravel horizon still didn't work alongside Redis cluster with mutiple shards.

Laravel queues work with Redis cluster?

Meanwhile, queues of Laravel seems working with Redis cluster. It's confusing to me. Please note that I haven't tested queues alongside Redis cluster with multiple shards, so actually I don't know if it really works, but queues seems better bet.

Even if you go with laravel queues, if you use database driver with MySQL that is older than 8.0, it might cause deadlocks. I think this is not mentioned in the doc too.

You cannot use multi/exec/watch/unwatch in Redis cluster with multiple shards (at least with predis)

You know, to keep data consistency, you sometimes must use watch/unwatch/multi/exec (to start something like transaction) to save dave data in Redis. But this doesn't work in redis cluster. It might work in your dev environment that uses single Redis node but not in production that uses Redis cluster with multiple shards.

Conclusion

In some situations, queues is a better bet.

Top comments (1)

Collapse
 
daison12006013 profile image
Daison Cariño • Edited

You cannot use multi/exec/watch/unwatch in Redis cluster with multiple shards (at least with predis)

No, you can thru a blocking connection.

We're using redis cluster and I was able to modify the classes written in laravel horizon, check it out daison/laravel-horizon-cluster