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 for read replica #18

Open
tyriis opened this issue May 28, 2019 · 3 comments
Open

support for read replica #18

tyriis opened this issue May 28, 2019 · 3 comments

Comments

@tyriis
Copy link

tyriis commented May 28, 2019

For my daily work, it would be very nice to have an option to define read replicas.
A possible way can be to add a flag to the query execution, to mark a query as read-only, so it is not needed to have a high amount of logic for this feature. On the other hand side, the developer is able to decide what queries to route to the replica.

@holdfenytolvaj
Copy link
Owner

This again, definitely sounds like an interesting feature, how would be the ideal api look like for you?

@tyriis
Copy link
Author

tyriis commented Jun 2, 2019

This is a real good question :)

I use raw SQL queries all the time, so not sure if it fulfill all the needs.
Currently, I have worked out a temporary solution by just creating a second instance, with a different host. As a developer i have to decide what query to send where, this is not really smart, but works for me so far.

To come back to the question, I think something inside the connection options, could add additional replica servers. F.e. replicas: [{connectionOptions}, ...] where all values from the parent connectionOptions are used and can be overwritten in the replicas[n].connectionOptions.

The other part would be a smart query detector, that is able to determine if a select is made or a write operation (so all read operations can be routed to the replica and all write to the default). As an easier to achieve, 1st iteration, you can let the developer decide when using raw queries, if its a read or write. F.e. with an optional flag (useReplica?: boolean). If no replica is set and Flag is set it should fall back to the master.

I hope it helps, and please let me know if you have a smarter solution/idea.

@holdfenytolvaj
Copy link
Owner

I'm going on vacation soon, but in June-July I will work on it.

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