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

Redis sentinel #14

Open
holidaycottages opened this issue Nov 21, 2014 · 1 comment
Open

Redis sentinel #14

holidaycottages opened this issue Nov 21, 2014 · 1 comment

Comments

@holidaycottages
Copy link

Hello, I want to use a redis setup that consists of a master and some slaves, also I want to configure in my infrastructure redis sentinel, so HA can be achieved.

I believe in stackexchange.redis that can accept multiple redis instances and it will work out what is the master and the slave.

If we use your session state provider can we do the same thing?

So instead of specifying one redis instance, we pass in multiple and it then will use the master for writing to and if the master fails and then is rolled over to one of the slaves then the application using the session state wont try and connect or write to the original master as that would potentially be down or a read only slave.

Hope I am making some sense there! Your advice would be appreciated.

@leewang0
Copy link
Owner

leewang0 commented Dec 2, 2014

Sorry I didn't see this sooner. Yes, that is possible. You should take a look at RedisSessionProvider.Config.RedisConnectionConfig.GetSERedisServerConfig. The KeyValuePair<string, ConfigurationOptions> that is the return type is the same ConfigurationOptions that is defined in StackExchange.Redis. Since that object has logic in it for specifying multiple server addresses, you should be fine defining something like this:

// this method gets run by RedisSessionProvider every time it reads or writes to redis
RedisConnectionConfig.GetSERedisServerConfig = (HttpContextBase context) =>
{
    // specify any additional sentinel logic here if you want
    return new KeyValuePair<string, ConfigurationOptions>("DefaultSessConfig", ConfigurationOptions.Parse(MyHost0 + "," + MyHost1));
};

Also, you may want to take replication lag into account (if any exists).

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

No branches or pull requests

2 participants