-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Document/Understand how to use new mongo read preference feature. #3960
Comments
@davimacedo @flovilmart feedback welcome.... |
@acinader please find my comments:
@flovilmart any ideas?
Best! |
I closed my pr, we can work on your additions: #3963 which look good. I had a few little nits. I don't think that general rules like: 'run counts on the secondary' will work. here's an example. let's say that you create and save an object with a particular attribute, and then you need to count the total # of those objects. If all counts are on the secondary and there's any lag, you'll get the wrong count -- for some applications that may well be unacceptable. But in other places, where you are not just adding right before counting, going to the secondary is possible and therefore should be done to help spread load. I think the only real question in the case is how should reading from the secondary be done in the api's. should it be: a. Note that "b." above mimics exactly the mongo javascript api. |
@davimacedo @TylerBrock I added a pr for the start for docs: parse-community/docs#449 can you take a look and add comments on the pr of what else/additional examples could help?? |
About the general rule the idea is to allow the user to select from which counts, geoqueries, etc will read in the parse server initialization (by default it will be primary) and this general rule can always be overriden per query using API or the trigger. query.find({readPreference: 'secondary'}) is what I have already done. I will take a look in the docs right now. I've just fixed the PR with your feedback. |
I think @davimacedo mentioned this elsewhere but the thinking was to dip our toe in the water with this one and then potentially expand the scope beyond beforeFind. EDIT: whoops, should have refreshed the page before adding my feedback, didn't see you all had been discussing already. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
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 abeforeFind
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:
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:
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?
The text was updated successfully, but these errors were encountered: