-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
I want to be able to send some queries to the secondary. My use case is something like: if i know that that a "set of related queries" or a cloud function is just going to read and not write to the db, then I want to send those queries to the secondary.
The thinking being that an app can scale better if read traffic can go to secondaries, cause one can always add more secondaries to handle load.
In looking at the new secondary read feature in parse-server 2.5.0 introduced in #3865 I couldn't really figure out how I could use. I looked at the unit tests and could only see how the read pref was set to SECONDARY in a beforeFind hook, which is by class, not by query, so I'd be setting all queries for that class to the secondary which isn't what i think(?) I want.
It would seem to me that what I'd want to be able to do is something like:
new Parse.Query('Foo').find({ useMasterKey: true, readPreference: 'SECONDARY' })
So I figured I'd test that out and here are the changes I needed to make in order to be able to make a Rest Query use the secondary, see #3959
So my questions:
- Is my premise somehow flawed as to what I want to use the secondary for?
- is there a way to do this already with the 2.5.0 release and I'm just missing it?
- does it seem like i'm on the right track?
If it does seem like I am on the right track, I can finish this up and add documentation as well as make any change to the js sdk to support that might be necessary?