Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use \RedisSentinel instead of Credis #146

Open
eschultz-magix opened this issue Mar 11, 2021 · 5 comments
Open

Use \RedisSentinel instead of Credis #146

eschultz-magix opened this issue Mar 11, 2021 · 5 comments

Comments

@eschultz-magix
Copy link

The usages of a Redis library are very inconsistent.

Having 1 Redis server without sentinel --> phpredis with \Redis
Having X Redis server in a cluster --> not supported
Having X Redis server with sentinel --> Credis in standalone mode

In Sentinel mode, one of the Sentinel instances are picked, getMasterAddrByName() is called and then a connection is established to the master where all all/write operations are done like in normal Redis mode.

Credis uses phpredis by default if available, but phpredis also has a \RedisSentinel class which has the getMasterAddrByName() function.

TL;DR: Credis is only used in Sentinel mode and can get replaced by phpredis, which is required by QueuedTracking anyway.

@tsteur
Copy link
Member

tsteur commented Mar 11, 2021

Thanks for creating the issue @eschultz-magix I'm not so much into the topic right now but I think a while back sentinel mode wouldn't work with phpredis. This might have changed.

@tsteur
Copy link
Member

tsteur commented Mar 11, 2021

@eschultz-magix would there be any particular advantage of using one or the other?

@eschultz-magix
Copy link
Author

@tsteur I guess, it would be great not to mix them up. Matomo requires the phpredis extension to be installed if you want to use redis as backend cache. Credis always checks if the extension is installed and fallbacks to phpredis. So there are no advantages, instead there is an additional check + library. In Sentinel model Credis forces its own implementation to communicate with the Sentinel server and with the Redis master server.

So at the end there are two different ways to communicate with Redis: phpredis (Matomo and QueuedTracking in Non-Sentinel mode) and Credis (QueuedTracking in Sentinel mode).

Using Credis will only make sense if you want to support old phpredis extensions without the \RedisSentinel class.

@eschultz-magix
Copy link
Author

@tsteur The RedisSentinel class is available since phpredis 5.2.0

@tsteur
Copy link
Member

tsteur commented Mar 14, 2021

Thanks for this @eschultz-magix didn't know RedisSentinel existed. We could prefer that one over Credis which we'd ideally still keep as a backup to not break backwards compatibility as not everyone can install extensions although in Matomo 5 we could think about removing Credis and fall back to MySQL instead although there be no harm to still keep supporting Credis I suppose besides having to keep dependency up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants