配置代理策略
Redis 企业软件 |
---|
Redis Enterprise Software (RS) 提供高性能数据访问 通过管理和优化对分片的访问的代理进程 在 RS 集群中。每个节点都包含一个代理进程。 每个代理可以是主动的并接收传入流量,也可以是被动的 并等待故障转移。
代理策略
数据库可以具有以下代理策略之一:
代理策略 | 描述 |
---|---|
单 | 只有一个代理绑定到数据库。这是默认的数据库配置,在大多数使用案例中都是可取的。 |
所有主分片 | 有多个代理绑定到数据库,托管数据库主分片的每个节点上一个代理。此模式适用于需要多个代理的大多数使用案例。 |
所有节点 | 有多个代理绑定到数据库,集群中的每个节点上都有一个代理,无论节点上是否有来自此数据库的分片。此模式应仅在特殊情况下使用,例如使用负载均衡器。 |
数据库配置
可以使用 rladmin bind 为数据库配置代理策略。
警告:任何导致现有代理 unbounded 可能会导致现有客户端连接断开连接。
您可以运行 rladmin 来控制和查看代理的现有设置 配置。
cluster 上的 info 命令返回 分片和非分片(单个分片)数据库。
$ rladmin info cluster
cluster configuration:
repl_diskless: enabled
default_non_sharded_proxy_policy: single
default_sharded_proxy_policy: single
default_shards_placement: dense
default_shards_overbooking: disabled
default_fork_evict_ram: enabled
default_redis_version: 3.2
redis_migrate_node_threshold: 0KB (0 bytes)
redis_migrate_node_threshold_percent: 8 (%)
redis_provision_node_threshold: 0KB (0 bytes)
redis_provision_node_threshold_percent: 12 (%)
max_simultaneous_backups: 4
watchdog profile: local-network
You can configure the proxy policy using the
bind
command in
rladmin. The following command is an example that changes the bind
policy for a database named "db1" with an endpoint id "1:1" to "All
Master Shards" proxy policy.
rladmin bind db db1 endpoint 1:1 policy all-master-shards
The next command performs the same task using the database id in place of the name. The id of this database is "1".
rladmin bind db db:1 endpoint 1:1 policy all-master-shards
Note:
You can find the endpoint id for the endpoint argument by running
status command for rladmin. Look for the endpoint id information under
the ENDPOINT section of the output.
Reapply policies after topology changes
If you want to reapply the policy after topology changes, such as node restarts,
failovers and migrations, run this command to reset the policy:
rladmin bind db db:<ID> endpoint <endpoint id> policy <all-master-shards|all-nodes>
This is not required with single policies.
Other implications
During the regular operation of the cluster different actions might take
place, such as automatic migration or automatic failover, which change
what proxy needs to be bound to what database. When such actions take
place the cluster attempts, as much as possible, to automatically change
proxy bindings to adhere to the defined policies. That said, the cluster
attempts to prevent any existing client connections from being
disconnected, and hence might not entirely enforce the policies. In such
cases, you can enforce the policy using the appropriate rladmin
commands.
About multiple active proxy support
RS allows multiple databases to be created. Each database gets an
endpoint (a unique URL and port on the FQDN). This endpoint receives all
the traffic for all operations for that database. By default, RS binds
this database endpoint to one of the proxies on a single node in the
cluster. This proxy becomes an active proxy and receives all the
operations for the given database. (note that if the node with the
active proxy fails, a new proxy on another node takes over as part of
the failover process automatically).
In most cases, a single proxy can handle a large number of operations
without consuming additional resources. However, under high load,
network bandwidth or a high rate of packets per second (PPS) on the
single active proxy can become a bottleneck to how fast database
operation can be performed. In such cases, having multiple active
proxies, across multiple nodes, mapped to the same external database
endpoint, can significantly improve throughput.
With the multiple active proxies capability, RS enables you to configure
a database to have multiple internal proxies in order to improve
performance, in some cases. It is important to note that, even though
multiple active proxies can help improve the throughput of database
operations, configuring multiple active proxies may cause additional
latency in operations as the shards and proxies are spread across
multiple nodes in the cluster.
Note:
When the network on a single active proxy becomes the bottleneck,
you might also look into enabling the multiple NIC support in RS. With
nodes that have multiple physical NICs (Network Interface Cards), you
can configure RS to separate internal and external traffic onto
independent physical NICs. For more details, refer to Multi-IP &
IPv6.
Having multiple proxies for a database can improve RS's ability for fast
failover in case of proxy and/or node failure. With multiple proxies for
a database, there is no need for a client to wait for the cluster
to spin up another proxy and a DNS change in most cases, the client
just uses the next IP in the list to connect to another proxy.
On this page