Skip to main content

Pisanix v0.1.1 Released !

· 5 min read
Maxwell Miao
Jiandong Wu
Bo Wang
Zhuo Li

Pisanix v0.1.1 is now released three weeks after Pisanix v0.1.0 was released. This new version supports read/write splitting and fixes some problems of the old version.

Pisanix v0.1.1 Description

New Features

  • Pisa -Controller
    • Add ReadWriteSplitting configuration to TrafficStrategy CRD
  • Pisa-Proxy
    • Introduce MetricsManager and MetricsCollector, laying a foundation for processing Metrics later.
    • Add sql_under_processingmetric as Gauge, referring to the number of SQL under processing
    • Support static read-write splitting rules
    • Support TCL statement parsing
    • Add show databases,show tables, and create database statements parsing

Improvements

  • Pisa-Controller
    • Fix ApiService json parsing error, resulting in that namespace cannot be deleted. #34
    • Support Regex array for CircuitBreak, ConcurrencyControl and ReadWriteSplitting. #123 #124
    • Rename sidecar name to pisa-proxy. #72
    • Add default host as 0.0.0.0 and port as 3306 to MySQL type VirtualDatabase. #68
    • Add server_version to Pisa-Proxy, referring to the MySQL version. #111
  • Pisa-Proxy
    • Support default admin port as 5591, which can be used to obtain metrics. #121
    • Fix the packet processing exceptions when the PREPARE statement is too long. #73
    • Fix SQL parsing ability. #98 #104

Others

Introducing Read-Write Splitting

Read-write splitting is one of the most commonly used MySQL solutions in the industry. In actual scenarios, it can improve query performance and reduce server load. The general structure is as follows:

Read-write splitting is part of the traffic strategies in Pisa-Proxy.

Currently, Pisa-Proxy supports two kinds of read-write splitting solutions:

  • Static read-write splitting: no backend awareness of database role change.
  • Dynamic read-write splitting (coming): backend awareness of the primary and secondary databases change.

Currently, both solutions require the configuration of read-write splitting rules. The read-write splitting rule refers to that Pisa-Proxy needs to match the SQL statement queried with the configured rule. If the match succeeds, the SQL statement is routed to the corresponding node according to the rule. If the match fails, the SQL statement is routed to the configured default node.

There are several concepts included:

  • Node: the backend database node.
  • RulesMatch: The RulesMatch engine matches the SQL query statements received by Pisa-Proxy by the compiled rule set.
  • TargetRole: The TargetRole group matched by the rule matching engine. Each TargetRole group may contain one or more nodes.
  • LoadBalance: The load balancer module will select an appropriate node from the TargetRole group according to corresponding algorithms.
  • TargetInstance: nodes selected from the LoadBalance module.

The implementation logic is as follows:

Read-Write Splitting Configuration

PropertyValue TypeDependency or notDefault ValueImplication
staticobjectNoNoStatic R/W splitting type
dynamicobjectNoNoDynamic R/W splitting configuration

Static read-write splitting configuration

PropertyValue TypeDependency or notDefault ValueImplication
defaultTargetenumNoNoThe target group of default routing
rulesarray{rule}YesNoRead-write splitting rule

Read-Write Splitting Rule Description

Currently, read-write splitting rules can only be matched through RegEx. The rule configuration description is as follows:

PropertyValue TypeDependency or notDefault ValueImplication
namestringYesNoRule name
typestringYesNoThe routing type belongs to RegEx, and the value here is regex.
regexarray{string}YesNoSpecific regex, used to match SQL statements
targetenumYesNoThe TargetRole group that is routed to, corresponding to the value of database-mesh.io/role in DatabaseEndpoint Annotations.
algorithmNameenumYesNoThe name of the load balancer algorithm used for the machine lists that are routed to the role group.

Note: the Enum values above are respectively:

  • TargetRole Enum value
    • read
    • readwrite
  • algorithName Enum value
    • random
    • roundrobin

Sample

The configuration of a complete TrafficStrategy CRD is as follows:

apiVersion: core.database-mesh.io/v1alpha1
kind: TrafficStrategy
metadata:
name: test
namespace: default
spec:
selector:
matchLabels:
source: test
loadBalance:
readWriteSplitting:
static:
defaultTarget: read # or readwrite
rules:
- name: read-rule
type: regex
regex:
- "^select"
target: read # readwrite
algorithmName: random # lb algorithm
- name: write-rule
type: regex
regex:
- "^insert"
target: readwrite
algorithmName: roundrobin

The configuration of a complete DatabaseEndpoint CRD is as follows:

apiVersion: core.database-mesh.io/v1alpha1
kind: DatabaseEndpoint
metadata:
annotations:
database-mesh.io/role: read # or readwrite
labels:
source: test
name: mysql
namespace: default
spec:
database:
MySQL:
db: test
host: mysql.default
password: root
port: 3306
user: root

Community Call

The new version contains 47 PRs and thanks to all the contributors:

  • mlycore
  • xuanyuan300
  • wbtlb
  • tuichenchuxin
  • windghoul
  • TeslaCN

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

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 !