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

Support scaleReads #119

Closed
idahogurl opened this issue Feb 25, 2021 · 4 comments
Closed

Support scaleReads #119

idahogurl opened this issue Feb 25, 2021 · 4 comments
Assignees
Labels
feature New functionality or improvement

Comments

@idahogurl
Copy link

idahogurl commented Feb 25, 2021

Support plan

  • is this issue currently blocking your project? Yes
  • is this issue affecting a production system? Yes

Context

  • node version: 10.x
  • module version: 5.0.2
  • environment (e.g. node, browser, native): Node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi application
  • any other relevant information:

What problem are you trying to solve?

Our web site is having show-stopping performance issues and we are trying to setup a second Redis instance that is a read-only.

catbox-redis supports clusters but it does not support the Redis option of scaleReads. I found you closed #61 as you determined using a custom Redis client was sufficient. According to the documentation, a custom client must:

  • be manually started and stopped,
  • be compatible with the ioredis module API, and
  • expose the status property that must be set to 'ready' when connected

I was able to get the start to work but @hapijs/hapi handles all the situations where you'd need to stop/disconnect the Redis client. A custom client is not sufficient because of the manual stopping. Here is the code I have thus far with using a custom client. Here is what I have thus far.

https://gist.github.com/idahogurl/6f5acd5205c132089eea96fd055b092d

Do you have a new or modified API suggestion to solve the problem?

Yes, #78 was closed but it can be done differently. ioredis supports clusters and if you pass in scaleReads it will treat the first Redis node as the primary and then the other as secondaries. To have our setup for a readonly you set scaleReads to slave

@idahogurl idahogurl added the feature New functionality or improvement label Feb 25, 2021
@Nargonath
Copy link
Member

If I understand correctly, you want the option scaleReads to be passed to redis from the plugin options, don't you? Does it need any further development from this plugin to use such option or just passing it solves your problem? If the latter, have you tried passing it already? From what I can see here:

.unknown();
unknown keys are allowed in the Joi schema so you should be able to provide options that are not mentioned in catbox-redis documentation.

@idahogurl
Copy link
Author

idahogurl commented Feb 26, 2021

@Nargonath Thanks for the reply! I'll try it again. I attempted without and I got a validation error.

@idahogurl
Copy link
Author

@Nargonath I tried with the latest package and it did work. Unfortunately we are not using @hapi/hapi@20. I cloned this repository and did a yarn link. It fails to connect but according to this redis/ioredis#1003 I have to be on the EC2 box. I will mark the issue as closed. We will have to do some upgrades. Thank you!!

@Nargonath
Copy link
Member

You're welcome @idahogurl . I'm glad I could help. 😉

@Nargonath Nargonath self-assigned this Feb 27, 2021
Nargonath added a commit that referenced this issue Feb 27, 2021
In the follow up of the issue #119, I thought it would be cool to document the plugin options pass through behavior.
devinivy pushed a commit that referenced this issue Feb 27, 2021
In the follow up of the issue #119, I thought it would be cool to document the plugin options pass through behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

2 participants