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
- Docs
- The first blog:https://www.pisanix.io/blog
- Update CRD description:https://www.pisanix.io/docs/v0.1.1/UseCases/kubernetes
- Add read-write splitting description:https://www.pisanix.io/docs/v0.1.1/Features/readwritesplitting
- Add versions: For now, v0.1.0 and v0.1.1 documents are available.
- Charts
- Update to 0.1.1
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
Property | Value Type | Dependency or not | Default Value | Implication |
---|---|---|---|---|
static | object | No | No | Static R/W splitting type |
dynamic | object | No | No | Dynamic R/W splitting configuration |
Static read-write splitting configuration
Property | Value Type | Dependency or not | Default Value | Implication |
---|---|---|---|---|
defaultTarget | enum | No | No | The target group of default routing |
rules | array{rule} | Yes | No | Read-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:
Property | Value Type | Dependency or not | Default Value | Implication |
---|---|---|---|---|
name | string | Yes | No | Rule name |
type | string | Yes | No | The routing type belongs to RegEx, and the value here is regex. |
regex | array{string} | Yes | No | Specific regex, used to match SQL statements |
target | enum | Yes | No | The TargetRole group that is routed to, corresponding to the value of database-mesh.io/role in DatabaseEndpoint Annotations. |
algorithmName | enum | Yes | No | The 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 List | https://groups.google.com/g/database-mesh |
Dev Meetings (Starting Feb 16th, 2022), Bi-weekly Wednesday 9:00AM PST | https://meet.google.com/yhv-zrby-pyt |
Dev Meetings APAC Friendly (Starting April 27th, 2022), Bi-weekly APAC Wednesday 9:00PM GMT+8 | https://meeting.tencent.com/dm/6UXDMNsHBVQO |
Wechat Broker | pisanix |
Slack | https://join.slack.com/t/databasemesh/shared_invite/zt-19rhvnxkz-USjZ~am~ghd_Q0q~8bAJXA |
Meetings Notes | https://bit.ly/39Fqt3x |
Feel free to talk !