跳到主要内容

Pisanix v0.2.0 Released !

· 5 分钟阅读
Maxwell Miao
Jiandong Wu
Bo Wang
Zhuo Li

Database Mesh

Database Mesh-oriented solutions for an easy-to-use, good-to-use, and practical user experience.

Pisanix version 0.2.0 was recently released. The newly released one supports dynamic read/write splitting. More details below.

Introducing dynamic read/write splitting

Introduction

Read/write splitting is one of the most commonly used solutions for MySQL's high availability. It improves query performance and reduces server load in practical scenarios. On top of the static rules of v0.1.1, dynamic read/write splitting is added in this release.

Read/write splitting rules need to be configured when it comes to splitting with dynamic awareness. Pisa-Proxy performs SQL routing according to the rules. As shown in Figure 1.1, the Pisa-Proxy backend will start four monitors to sense the backend cluster status.

Monitor Reconcile will calculate and aggregate the data reported by the Monitor and draw the final state of the backend cluster. Then Monitor Reconcile sends the state information to RulesMatch through the channel. RulesMatch dynamically adjusts the backend data source list once it receives the message.

The concepts included above are:

  • Node: Backend database node.
  • RulesMatch: RulesMatch engine matches with the SQL query statements received by Pisa-Proxy based on the written rule set.
  • TargetRole: A TargetRole group matched by the RulesMatch engine. Each TargetRole group may contain one or more nodes.
  • LoadBalance: The load balance module selects an appropriate node from the TargetRole group according to the corresponding algorithm.
  • TargetInstance: Nodes selected by the LoadBalance module.
  • Discovery: Discovery type, which corresponds to the high availability strategy used by the backend data source, such as MHA, RDS, MGR, etc. The newly released version mainly supports MHA.
  • Monitor: It refers to the backend detector module of Pisa-Proxy, which mainly relies on four kinds of Monitors in MHA.
    • Connect Monitor: detect database connectivity.
    • Ping Monitor: detect whether the database is healthy.
    • Replication Lag Monitor: detect the latency status of primary-secondary replication.
    • Read Only Monitor: detect the roles of primary-secondary databases.

Read/write splitting configuration

The configuration mode of dynamic read/write splitting is the same as that of the static one. The configuration items of dynamic read/write splitting are as follows:

ParameterTypeDependency or notDefault ValueDescription
userstringYesNoneDetector module checks the username of SQL statements.
passwordstringYesNoneDetector module checks the password of SQL statements.
monitor_periodu64Yes1000The period (ms) by which detector module updates and senses the backend data source status.
connect_periodu64Yes1000Connect Monitor detection period (ms)
connect_timeoutu64Yes6000Connect Monitor detection timeout (ms)
connect_failure_thresholdu64Yes1Number of retries when Connect Monitor detection fails
ping_periodu64Yes1000Ping Monitor detection period (ms)
ping_timeoutu64Yes6000Ping Monitor detection timeout (ms)
ping_failure_thresholdu64Yes1Number of retries when Ping Monitor detection fails.
replication_lag_periodu64Yes1000Replication Lag Monitor detection period (ms)
replication_lag_timeoutu64Yes6000Replication Lag Monitor detection timeout (ms)
replication_lag_failure_thresholdu64Yes1Number of retries when Replication Lag Monitor detection fails.
max_replication_lagu64Yes10000User-defined maximum primary/secondary latency threshold (ms)
read_only_periodu64Yes1000Read Only detection period (ms)
read_only_timeoutu64Yes6000Read Only detection timeout (ms)
read_only_failure_thresholdu64Yes3Number of retries when Read Only Monitor detection fails.

CRD configuration sample:

apiVersion: core.database-mesh.io/v1alpha1
kind: TrafficStrategy
metadata:
name: catalogue
namespace: demotest
spec:
selector:
matchLabels:
source: test
loadBalance:
readWriteSplitting:
dynamic:
defaultTarget: readwrite
discovery:
masterHighAvailability:
connectionProbe:
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
monitorPeriod: 1000
pingProbe:
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
readOnlyProbe:
failureThreshold: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
replicationLagProbe:
failureThreshold: 3
maxReplicationLag: 3
periodMilliseconds: 1000
timeoutMilliseconds: 6000
user: monitor
password: monitor
rules:
- algorithmName: roundrobin
name: write-rule
regex:
- ^insert
target: readwrite
type: regex
- algorithmName: roundrobin
name: read-rule
regex:
- ^select
target: read
type: regex

Pisanix v0.2.0 Description

New features

  • Pisa-Controller
    • Support dynamic read/write splitting in the TrafficStrategy CRD ReadWriteSplitting field #208
  • Pisa-Proxy
    • Support dynamic read/write splitting #204
    • Add the sub-command: daemonsidecar #190

Enhancements

  • Refactor config files of Pisa-Proxy #182
  • Complete the SHOW SQL statement parsing #183
  • Add code coverage checks to Pisa-Controller #192
  • Enable reconnecting when backend data source fails to be connected #215

Improvements

  • Pisa-Controller
    • Fix webhook tls #221
  • Pisa-Proxy
    • Fix the request failure to switch MySQL authentication #170
    • Handle exceptions of EOF package of MySQL protocol #166
    • Fix the Charset character set #154
    • Fix the environment variables injection #223

Others

There are 62 PRs in this release. Thanks to the following contributors:

  • mlycore
  • xuanyuan300
  • wbtlb
  • windghoul
  • lltgo
  • tuichenchuxin
  • dongzl

🔗Download link: https://github.com/database-mesh/pisanix/releases/tag/v0.2.0

Community Call

Building an open source community needs help from everywhere, no matter it's code or documentation, issues or pull requests, community thanks all of your efforts.

At present, there are some ways to join the community:

Mailing Listhttps://groups.google.com/g/database-mesh
Dev Meetings (Starting Feb 16th, 2022), Bi-weekly Wednesday 9:00AM PSThttps://meet.google.com/yhv-zrby-pyt
Dev Meetings APAC Friendly (Starting April 27th, 2022), Bi-weekly APAC Wednesday 9:00PM GMT+8https://meeting.tencent.com/dm/6UXDMNsHBVQO
Wechat Brokerpisanix
Slackhttps://join.slack.com/t/databasemesh/shared_invite/zt-19rhvnxkz-USjZ~am~ghd_Q0q~8bAJXA
Meetings Noteshttps://bit.ly/39Fqt3x

Feel free to talk !