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

Twemproxy support #54

Closed
TMiNus opened this issue Mar 31, 2016 · 9 comments
Closed

Twemproxy support #54

TMiNus opened this issue Mar 31, 2016 · 9 comments
Assignees
Milestone

Comments

@TMiNus
Copy link

TMiNus commented Mar 31, 2016

I am trying to add twemproxy support for the library but I have hit a wall because the Servers API from StackExchange.Redis is not available if the proxy option is on and CacheManager relies heavily on this API for example to detect the features available in the particular endpoint (lua, etc..). Also the pub/sub feature of Redis is not supported so the backplane cannot be set :(

@TMiNus
Copy link
Author

TMiNus commented Mar 31, 2016

A crazy idea, can we make the BlackPlane feature open to customs pub/sub back-ends like we do with the Serializer or the Logger.

@MichaCo
Copy link
Owner

MichaCo commented Apr 1, 2016

A crazy idea, can we make the BlackPlane feature open to customs pub/sub back-ends like we do with the Serializer or the Logger

It is already, since the beginning. BaseBackplane is in Core

@MichaCo
Copy link
Owner

MichaCo commented Apr 1, 2016

Regarding twemproxy support. I guess in most cases where APIs are not available, the features using those APIs must be disabled and/or fall back to defaults if possible, if proxy is enabled.

Should be possible to identify through the redis configuration proxy type?

@TMiNus
Copy link
Author

TMiNus commented Apr 1, 2016

Well actually StackExchange.Redis just support Twemproxy so either you have that one or you don't have one at all

@TMiNus
Copy link
Author

TMiNus commented Apr 1, 2016

Any gotchas in the implementation of a different pub sub system for CacheManager?

@MichaCo
Copy link
Owner

MichaCo commented Apr 1, 2016

Well actually StackExchange.Redis just support Twemproxy so either you have that one or you don't have one at all

I know, just saying, CacheManager would have to disable certain features if proxy is enabled and not try to identify features and such. Not planning to implement that soon though.

Any gotchas in the implementation of a different pub sub system for CacheManager

Just look at the redis based implementation, it is pretty straight forward. Depends on the system you are using and how you want to serialize the messages I guess

@MichaCo MichaCo self-assigned this Apr 27, 2017
@MichaCo MichaCo added this to the 1.0.2 milestone Apr 27, 2017
@MichaCo
Copy link
Owner

MichaCo commented Apr 27, 2017

Finally working on adding support for Twemproxy in 1.0.2.
As far as I can tell right now, some things will not work if Twemproxy is used.
It will be limited, but hey, at least it kinda works ;)

MichaCo added a commit that referenced this issue Apr 27, 2017
…UseTwemProxy`,. Added the option to by code, json and xml configuration variants... Added another new config option to set an explicit compatibiliy mode to a certain Redis version (to disable LUA for example). Refactored the redis configuration a little
@MichaCo
Copy link
Owner

MichaCo commented Apr 27, 2017

@TMiNus
In 07f1db9 I added Twemproxy support, maybe you could give that a try and test it with the beta packages (1.0.2-beta-1510+).

The following things are not working because it is not supported in that mode:

  • Redis Backplane and keyspace events (as Pub/Sub is not supported with Twemproxy)
  • Clear and Count (as Twemproxy doesn't let me access the servers list)
  • cache.Update and all variants of Update might throw an exception if LUA scripting is not available (e.g. running against Redis 2.4 behind Twemproxy)

Lua scripting works, I had to add a switch though, to disable preloading of the lua scripts. I cannot preload them again because of the not supported Servers collection.
In Twemproxy mode, the script will be passed along with any EVAL command, which works pretty well.
That enables access to all normal cache methods (put, get, add, remove, update...) with Twemproxy.

If Lua is not available though, Update will not be supported as Twemproxy doesn't allow the commands I'm using in no-script mode...

Also, I cannot determine the version of Redis running behind Twemproxy which makes it impossible to access the available features. So, in case someone has to use Redis 2.4 for example (which doesn't have Lua support), they can set a new property via configuration StrictCompatibilityModeVersion to restrict the compatibility mode to that version.

Overall I'm pretty happy with the implementation.
Let me know what you think and happy testing ;)

@TMiNus
Copy link
Author

TMiNus commented May 7, 2017

@MichaCo Awesome commit :) I have reviewed the commit and the code and I am very happy with the final result too, it seems pretty close to what I did back in the day, although my version was a little more hacky

You deserve a 🥇 Keep the good work!!. We can close this ticket. I will report any issues in a new ticket :)

@MichaCo MichaCo closed this as completed Jun 3, 2017
@MichaCo MichaCo modified the milestones: 1.0.2, 1.1.0 Jun 5, 2017
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