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
Implement a proxy module with manual failover #2625
Comments
Requested by ICQ |
Please move to 1.7.8 |
In progress, but already opened for comments and discussion. Why?
Main solved problems
APIProxy is a module, and can be configured like this: proxy = require('proxy')
proxy.cfg{
replicaset = {
{ uri = <instance URI>, is_master = <boolean> },
...
},
-- Options, keept from storage --
listen
readahead,
log,
log_nonblock,
log_format
} Proxy on Architecture
Connecting, authorizationAll proxy internals can be implemented inside IProto thread. Only IProto thread when started, knows which port is proxy, and to which storages it On connect a proxy for each proxy-to-storage connection saves salt - name it If there is no a connection under this user, then create a new one. Note: if a proxy has out of date passwords, then authorization can be Sync translationIf a proxy-to-storage connection serves one client-to-proxy connection, then When a proxy-to-storage connection serves multiple client-to-proxy connections,
QueuingConsider one proxy-to-storage connection. To prevent mixing parts of multiple When a client socket with no available data becomes available for reading, it To speed up Storage and proxy allianceThe main feature of the proxy is ability to merge a proxy and a storage. If in |
@kostja comments:
|
https://github.com/moonlibs/apex already implements proxy with failover, role-aware request balancing, health ping checks and lua-namespace autoload proxying. |
We might want to implement override of IPROTO_(SELECT|INSERT|...) instead. |
After thinking about it for some time, I don't believe this will be useful. For sharded tarantool, vshard already takes care of this. Even if we put it before (multiple) vshard-routers, this proxy will fail to handle the whole traffic, unless it's multi-threaded. |
This is supposed to be present in every tarantool instance, so as many threads as iproto threads in all instances you have. I don't see how it's possible to make RAFT work without it. |
@kostja I mean that it will be mostly useless for clients if designed as written above. Proxying authentication and iproto is only useful when the client is working with only one instance of Tarantool. And working with single instance makes it impossible to scale horizontally. If we subtract the actual proxying and only implement it for regular net.box calls between a router and storage, it may be useful for RAFT. But still, RAFT is not on the horizon anytime soon, as far as I know. As for vshard, it already can implement such logic in "callrw". |
@knazarov the idea with this patch is that eventually you will add vshard router functions into iproto. What you're suggesting is that since you can't do it yet it's useless. That would be a pity to stop this work only because it doesn't as is meets your present day needs. |
The description and design by @Gerold103 doesn't say anything about the fact that it's needed for vshard, or the plans to add vshard calls to iproto. So I'm only making assumptions from what I read, or can deduce from my current knowledge. The original description only talks about client -> storage connections. Af for vshard, I doubt the usefulness of proxying it for a few reasons:
So, in general I see exposing current vshard API as useless, and would instead like to see a high-level API for client libraries to work with. (The API that has at least CRUD-level querying capabilities) If you think otherwise, please share your reasoning. |
Let's talk about read/write queries for elastic, clustered storage for a minute. The target scheme we need to come to is client -> correct storage instance. For this, the client needs to be sharding topology aware. However, not all clients are sharding-topology aware, and there are times when topology changes. So buckets are being moved around. For these clients and times, iproto should be able to bounce the sharded write/read on client's behalf. |
When I was mentioning adding vshard router functions to iproto, I didn't mean exposing a new API. I meant iproto should be able to route a query to the right bucket automatically if it arrived at a wrong storage instance. |
And yes, the goal is to move all routing logic to iproto, be it for RAFT or for sharding. It won't isolate this logic in iproto alone, it's impossible: imagine you run a stored procedure on a storage node, eventually we'll want to select from a remote bucket from it. And as you are rightfully pointing out, it is not the best idea to route a request to a random node, so client will have to be topology aware as well. This counts for at least 3 places where we will do the routing. The way I view iproto routing function is:
|
Imagine operating a heterogeneous cluster, i.e. a cluster you're trying to upgrade from 3.0 to 4.0. In 4.0, your routing logic may be different from 3.0, so at 4.0 nodes you'll need to behave differently depending on whether the bucket is on old or new node. It's impossible you'll be able to fix old clients and 3.0 net.box to handle it. |
BTW, @Gerold103 write-up + comments about "some kostja's comments which I did not understand" doesn't pass as a complete spec to me :) Why not make a yet another round of RFC discussion about this item and iron out all wrinkles? |
Implement a tarantool module which would proxy traffic to a master-master configuration and fail over automatically. Right now this is done in https://github.com/tarantool/sentinel, we should take it on board.
The proxy has to be built-in.
API
Failover, manual:
proxy:fail_over_to(uri)
How should we forward authentication?
How should we detect which node is a master and which is a replica?
The text was updated successfully, but these errors were encountered: